📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Explain the Kubernetes basics a .NET developer needs: pods, deployments, ReplicaSets, services, ingress (and the Gateway API), ConfigMaps and secrets. How does a request reach your ASP.NET Core container, and how does configuration get into it?

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.

Intermediate Theory Intermediate aks configuration containers devops ingress kubernetes

🎯 Key points

  • Pod = smallest unit, one or more containers sharing network and volumes; disposable
  • Deployment manages ReplicaSets: desired replicas, rolling updates, rollback
  • Service = stable virtual IP and DNS name load-balancing to ready pod endpoints by label selector
  • Request path: cloud load balancer (Azure LB) → ingress/gateway controller (TLS, host/path routing) → Service → ready pod :8080 → Kestrel
  • Gateway API (GatewayClass, Gateway, HTTPRoute) is the successor to Ingress; ingress-nginx is retired (maintenance ended March 2026)
  • ConfigMap and Secret mounted as env vars or files; map to IConfiguration with __
  • Secrets are only base64 by default; use Key Vault CSI driver or Workload Identity
  • Liveness, readiness and startup probes map to ASP.NET Core health checks

⏱ 30-second answer

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.

🗣 Full answer (senior)

How I would answer this in an interview

"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 undo goes 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 call http://orders-api. To get traffic in from outside, an Ingress resource (or, on newer clusters, a Gateway API HTTPRoute) tells a controller to route api.example.com.au/orders to 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 to MapHealthChecks endpoints.

Configuration comes from ConfigMaps and Secrets, either as environment variables, where ConnectionStrings__Default becomes ConnectionStrings:Default in IConfiguration, 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."


The core objects

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

Probes and ASP.NET Core

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

Production example

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.

🔍 What the interviewer is checking

Checks that the candidate understands the core Kubernetes objects and how a .NET app fits into them, not just kubectl commands.

Green flags

  • Explains deployment → ReplicaSet → pod and the role of services
  • Maps probes to ASP.NET Core health checks and keeps dependencies out of liveness
  • Knows secrets are only base64 and mentions Workload Identity / Key Vault
  • Aware of Gateway API as the successor to Ingress

Red flags

  • Calls pods by IP or thinks pods are long-lived
  • Puts database checks in liveness probes
  • Thinks Kubernetes secrets are encrypted by default

📚 Learn in depth

1. The control loop

 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.

2. The request path

 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.

3. Ingress versus Gateway API (2026)

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.

4. Rolling updates

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.

5. Configuration and secrets

  • Env vars from a ConfigMap: read at start only; changing the ConfigMap needs a pod restart.
  • Files from a ConfigMap volume: updated in place after a delay (not for subPath mounts); AddJsonFile(..., reloadOnChange: true) or AddKeyPerFile can pick them up.
  • Secrets: base64 in etcd. Enable encryption at rest, restrict RBAC, and prefer external stores: Microsoft Entra Workload ID lets a pod's service account federate to a managed identity so DefaultAzureCredential reaches Key Vault with no stored secret.

Try it yourself

  1. Create a local cluster with kind or Docker Desktop and apply the manifests below.
  2. Run kubectl get pods -w while you change the image tag; watch the rolling update.
  3. Make /healthz/ready return 503 and see the pod disappear from kubectl get endpointslices.
  4. kubectl exec a debug pod and curl http://orders-api to see service DNS.
  5. Change a ConfigMap value used as an env var and confirm the pod doesn't see it until restarted.

💻 Code

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();

⚠ Common mistakes

  • Mistake: Calling pods directly by IP. Why it is wrong: Pod IPs change on every reschedule. Instead: Call the service DNS name.
  • Mistake: Checking the database in the liveness probe. Why it is wrong: A database outage makes every pod fail liveness and restart in a loop, turning a partial outage into a full one. Instead: Liveness checks the process only; dependencies go in readiness, if at all.
  • Mistake: Treating Kubernetes secrets as encrypted. Why it is wrong: They are base64-encoded and readable by anyone with get secret RBAC. Instead: Encrypt etcd, restrict RBAC, and use Workload Identity with Key Vault.
  • Mistake: Expecting a ConfigMap change to reach running pods via env vars. Why it is wrong: Env vars are set at container start. Instead: Roll the deployment (a checksum annotation in Helm does this) or mount as files with reload.
  • Mistake: Running a single replica of a production API. Why it is wrong: Every node drain or rollout causes downtime. Instead: At least 2 replicas, a PodDisruptionBudget and maxUnavailable: 0.
  • Mistake: No readiness probe. Why it is wrong: Traffic arrives while the app is still warming up, causing 502s during every rollout. Instead: A readiness probe on a health endpoint.
  • Mistake: Building new clusters on retired ingress controllers. Why it is wrong: No security patches. Instead: A supported Gateway API implementation or the platform's managed ingress.

🏛 Senior insight: trade-offs

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.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions rolling updates or SIGTERM Why: Checks they can drain in-flight requests during a rolling deploy
    How to answer

    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.

  2. When: Candidate mentions readiness probes Why: Checks whether they would put downstream dependencies in readiness checks
    How to answer

    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.

    • Check local prerequisites; handle dependency failures in the request path with timeouts, circuit breakers and fallbacks.
    • Exceptions: a dependency that belongs to this instance only (a sidecar, a per-pod cache warm-up), or a prerequisite without which the instance can serve nothing at all and the failure is instance-specific.
    • Liveness is narrower still: only a stuck process.

    The trade-off is against the SLO: serving degraded responses usually costs less error budget than having zero ready pods.

  3. When: Candidate says they would run the API on AKS Why: Checks they can justify AKS over Container Apps or App Service
    How to answer

    I choose by how much platform the team wants to run:

    • App Service: one or a few web apps, always on, deployment slots, almost no ops. Paid per plan instance.
    • Azure Functions: event-driven or spiky work (queues, timers, blobs); Flex Consumption scales per event and to zero.
    • Container Apps: containerised microservices on managed Kubernetes with KEDA scaling, revisions and scale to zero, without touching the cluster.
    • AKS: full Kubernetes when you need its API, custom networking or many services and have a platform team.

    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.

↩ Usually asked after

More in Containers

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me