Core Kubernetes objects for .NET developers (pod, deployment, ReplicaSet, service, ingress and Gateway API, ConfigMap, secret, probes), the request path to an ASP.NET Core container, and how configuration and secrets are injected.
Kubernetes runs containers from declarative desired state. A pod is the smallest unit: one or more containers sharing an IP and volumes, and it is disposable. A deployment says "run 3 replicas of this image" and manages ReplicaSets to do rolling updates and rollbacks. A service gives those changing pods a stable DNS name and virtual IP and load-balances across them. Ingress (or the newer Gateway API) routes external HTTP traffic and terminates TLS.
Configuration comes from ConfigMaps and secrets, injected as environment variables or files, which ASP.NET Core reads through IConfiguration. Probes call your health endpoints.
The trade-off: huge flexibility and portability, at the cost of a lot of moving parts to run.
"Kubernetes is a reconciliation engine. I write YAML describing what I want, the API server stores it in etcd, and controllers keep nudging reality towards it. For a .NET API I write a Deployment: the image tag, three replicas, resource requests and limits, environment variables and probes. The deployment creates a ReplicaSet, which creates pods. A pod is one or more containers that share a network namespace and volumes, and it is cattle: if a node dies, the pod is replaced elsewhere with a new IP. When I change the image tag, the deployment creates a new ReplicaSet and does a rolling update, and
kubectl rollout undogoes back.Because pod IPs change, I put a Service in front. It selects pods by label and gives them one stable virtual IP and DNS name, like
orders-api.orders.svc.cluster.local, so other services callhttp://orders-api. To get traffic in from outside, an Ingress resource (or, on newer clusters, a Gateway APIHTTPRoute) tells a controller to routeapi.example.com.au/ordersto that service and terminate TLS. So a request goes: load balancer, ingress or gateway controller, service, one ready pod, Kestrel on port 8080. Only pods passing their readiness probe receive traffic, which is why I map probes toMapHealthChecksendpoints.Configuration comes from ConfigMaps and Secrets, either as environment variables, where
ConnectionStrings__DefaultbecomesConnectionStrings:DefaultinIConfiguration, or mounted as files. The mistake I see is believing Kubernetes secrets are secure on their own: they are base64, not encrypted, unless the cluster encrypts etcd and RBAC is tight. On AKS I'd rather use Workload Identity to reach Key Vault directly, or the Key Vault CSI driver."
| Object | What it is | .NET analogy |
|---|---|---|
| Pod | One or more containers, shared IP and volumes | One running process instance |
| ReplicaSet | Keeps N identical pods running | A pool of instances |
| Deployment | Manages ReplicaSets, rolling updates, rollback | App Service deployment + scale-out |
| Service (ClusterIP) | Stable virtual IP and DNS, load-balances to ready pods | Internal load balancer |
| Ingress / Gateway API | External HTTP(S) routing and TLS | Reverse proxy (YARP, Front Door) |
| ConfigMap | Non-secret configuration | appsettings.{Env}.json / env vars |
| Secret | Sensitive values (base64-encoded) | User secrets / Key Vault |
| Namespace | Grouping, RBAC and quota boundary | Resource group |
| Probe | Question it answers | Endpoint | On failure |
|---|---|---|---|
| Startup | Has the app finished starting? | /healthz/live |
Keep waiting, then restart |
| Liveness | Is the process stuck? | /healthz/live (no dependency checks) |
Restart container |
| Readiness | Can it take traffic now? | /healthz/ready |
Remove from service endpoints |
We ran an orders API as a deployment with 3 replicas behind a ClusterIP service and an ingress on AKS in Australia East. A bad config value made new pods fail readiness during a rollout; because maxUnavailable was 0, the old pods kept serving and no customer saw an error. We fixed the ConfigMap and the rollout completed in about 2 minutes.
Checks that the candidate understands the core Kubernetes objects and how a .NET app fits into them, not just kubectl commands.
Green flags
Red flags
kubectl apply -f deploy.yaml
│
▼
API server ──▶ etcd (desired state)
│
├─▶ Deployment controller ─▶ creates ReplicaSet
├─▶ ReplicaSet controller ─▶ creates Pods
├─▶ Scheduler ─▶ picks a node (requests vs free capacity)
└─▶ kubelet on node ─▶ pulls image, starts container, runs probes
Nothing is imperative: each controller watches objects and acts to close the gap between spec and status.
Client ─▶ Azure Load Balancer ─▶ Ingress/Gateway controller pod
─▶ Service (ClusterIP, kube-proxy/eBPF rules) ─▶ ready Pod IP:8080 ─▶ Kestrel
A service's EndpointSlices list only pods whose readiness probe passes. kube-proxy (iptables/IPVS) or an eBPF data plane such as Cilium translates the service IP to a pod IP. DNS comes from CoreDNS: <service>.<namespace>.svc.cluster.local.
Ingress is a simple API whose behaviour depends heavily on controller-specific annotations. The Gateway API (GatewayClass, Gateway, HTTPRoute) is its role-oriented successor: platform teams own Gateways, app teams own routes, and features such as header matching, traffic splitting and cross-namespace routing are in the spec. The community ingress-nginx controller has been retired (maintenance ended in March 2026), so new clusters should use a Gateway API implementation, or on AKS a supported managed option such as Application Gateway for Containers. Check the current AKS guidance before choosing.
strategy.rollingUpdate.maxSurge and maxUnavailable control how many extra or missing pods are allowed. With maxUnavailable: 0, Kubernetes waits for new pods to be ready before removing old ones. On termination, the pod gets SIGTERM, is removed from endpoints (asynchronously), and after terminationGracePeriodSeconds (30 s by default) gets SIGKILL. ASP.NET Core's host stops accepting new requests and drains in-flight ones on SIGTERM; a short preStop sleep covers the endpoint propagation delay.
subPath mounts); AddJsonFile(..., reloadOnChange: true) or AddKeyPerFile can pick them up.DefaultAzureCredential reaches Key Vault with no stored secret.kind or Docker Desktop and apply the manifests below.kubectl get pods -w while you change the image tag; watch the rolling update./healthz/ready return 503 and see the pod disappear from kubectl get endpointslices.kubectl exec a debug pod and curl http://orders-api to see service DNS.A deployment, service and configuration for a .NET 10 API:
apiVersion: v1
kind: ConfigMap
metadata:
name: orders-api-config
data:
ASPNETCORE_ENVIRONMENT: Production
Orders__MaxPageSize: "100" # becomes Orders:MaxPageSize in IConfiguration
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders-api
spec:
replicas: 3
selector:
matchLabels: { app: orders-api }
strategy:
rollingUpdate: { maxSurge: 1, maxUnavailable: 0 }
template:
metadata:
labels:
app: orders-api
azure.workload.identity/use: "true" # Workload Identity: no secrets for Key Vault/SQL
spec:
serviceAccountName: orders-api
containers:
- name: api
image: crordersprod.azurecr.io/orders-api:1.4.2
ports: [{ containerPort: 8080 }]
envFrom: [{ configMapRef: { name: orders-api-config } }]
resources:
requests: { cpu: 250m, memory: 256Mi }
limits: { memory: 512Mi }
startupProbe: { httpGet: { path: /healthz/live, port: 8080 }, failureThreshold: 30, periodSeconds: 2 }
livenessProbe: { httpGet: { path: /healthz/live, port: 8080 }, periodSeconds: 10 }
readinessProbe: { httpGet: { path: /healthz/ready, port: 8080 }, periodSeconds: 5 }
---
apiVersion: v1
kind: Service
metadata:
name: orders-api
spec:
selector: { app: orders-api }
ports: [{ port: 80, targetPort: 8080 }]
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: orders-api
spec:
parentRefs: [{ name: public-gateway, namespace: gateway-system }]
hostnames: ["api.example.com.au"]
rules:
- matches: [{ path: { type: PathPrefix, value: /orders } }]
backendRefs: [{ name: orders-api, port: 80 }]
The matching health endpoints in ASP.NET Core:
using Microsoft.Extensions.Diagnostics.HealthChecks;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy(), tags: ["live"])
.AddSqlServer(builder.Configuration.GetConnectionString("Default")!, tags: ["ready"]);
var app = builder.Build();
// Liveness: only 'is the process responsive'. Never check dependencies here,
// or a database outage restarts every pod.
app.MapHealthChecks("/healthz/live", new() { Predicate = r => r.Tags.Contains("live") });
app.MapHealthChecks("/healthz/ready", new() { Predicate = r => r.Tags.Contains("ready") });
app.Run();
get secret RBAC. Instead: Encrypt etcd, restrict RBAC, and use Workload Identity with Key Vault.maxUnavailable: 0.As a .NET developer on Kubernetes, my job is to make the app a good citizen: start fast, expose honest health endpoints, shut down gracefully on SIGTERM, read config from the environment and log to stdout. The platform team owns the cluster; I own the manifest or chart for my service. If no platform team exists, I seriously question whether we need raw Kubernetes rather than Azure Container Apps, which gives deployments, revisions, ingress and KEDA without a cluster to run.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| AKS | Many services, platform team, need CRDs/operators | Upgrades, node patching, ingress, people | Few services, no Kubernetes skills |
| Azure Container Apps | Microservices without cluster ops | Less control, no raw Kubernetes API | Need custom controllers or service mesh |
| App Service | One to a few web apps | Least flexible scaling | Event-driven scale to zero |
I measure rollout success (failed rollouts per month), restart counts, and p95 latency during deployments.
On SIGTERM, Kubernetes removes the pod from endpoints and signals the container at roughly the same time, but endpoint removal takes a few seconds to reach every node and ingress. So I fail readiness as soon as ApplicationStopping fires and add a preStop sleep of about 5–10 s so routing catches up. I let the host finish in-flight requests within HostOptions.ShutdownTimeout (30 s by default since .NET 8), and keep terminationGracePeriodSeconds longer than the preStop delay plus the shutdown timeout. Background services must honour the stopping token. I verify with a load test during a rolling deploy: zero 5xx.
Mostly no. Readiness should say whether this instance can serve traffic: started, warmed up, not shutting down. If it checks a shared database or another service, one dependency outage marks every pod unready, discovery removes them all, and a partial outage (some endpoints still worked, cached reads still worked) becomes a total one.
The trade-off is against the SLO: serving degraded responses usually costs less error budget than having zero ready pods.
I choose by how much platform the team wants to run:
The trade-off is control versus operations: each step towards AKS gives more control and more work. I start with the simplest option that meets the requirements and move only when I hit a concrete limit.
Last updated 23 Nov 2026.