Library

Volume 1 · Containers & Kubernetes

Notebook
Sign in

Section 29

AKS/EKS Specifics

1,193 words · about 5 min

29.1 Networking: CNI vs. Kubenet (AKS-focused, concepts generalize to EKS’s VPC CNI)

Model IP Allocation Best For Trade-off
Azure CNI Every pod gets a routable IP directly from the VNet subnet Large enterprises needing strict VNet integration, direct pod-to-on-prem connectivity, NSG rules targeting individual pod IPs Consumes VNet IP space fast — risk of address exhaustion in large clusters
Azure CNI Overlay Nodes get VNet IPs; pods get IPs from a separate private overlay CIDR Large microservice deployments where IP exhaustion is a real risk, but VNet integration is still wanted Slightly more networking complexity, pod IPs aren’t directly routable outside the cluster
Kubenet Nodes get VNet IPs; pods get IPs from a separate CIDR, NAT’d for egress Smaller/simpler clusters, minimal VNet IP consumption Extra routing hop, some Azure features (e.g., certain NSG-per-pod scenarios) don’t work

EKS equivalent decision: AWS VPC CNI (every pod gets a routable VPC IP — same IP exhaustion risk as Azure CNI, mitigated with prefix delegation and custom secondary CIDRs) versus alternate CNIs like Cilium for larger clusters needing more IP-efficient overlay networking plus eBPF-based policy enforcement.

29.2 Identity: Workload Identity (AKS) / IRSA (EKS)

# AKS — Entra Workload ID: annotate the ServiceAccount, not the pod
apiVersion: v1
kind: ServiceAccount
metadata:
  name: inference-sa
  annotations:
    azure.workload.identity/client-id: "<managed-identity-client-id>"
  labels:
    azure.workload.identity/use: "true"
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: inference-api }
spec:
  template:
    metadata:
      labels:
        azure.workload.identity/use: "true"
    spec:
      serviceAccountName: inference-sa
      containers:
        - name: inference-api
          image: myregistry/inference-api:v2.1
# EKS — IRSA: IAM role trust policy scoped to the OIDC provider + service account
apiVersion: v1
kind: ServiceAccount
metadata:
  name: inference-sa
  annotations:
    eks.amazonaws.com/role-arn: "arn:aws:iam::123456789012:role/inference-service-role"

Why this matters: a specific pod assumes a specific cloud-native identity (Managed Identity / IAM role) and authenticates directly to Bedrock/SageMaker/Key Vault/S3 — no static credential exists anywhere in the cluster, config, or image.

29.3 Virtual Nodes / Serverless Bursting (AKS) and Fargate Profiles (EKS)

AKS Virtual Nodes: AKS + ACI (Azure Container Instances)
  - Burst pods onto ACI in seconds when node pool capacity is exhausted
  - No VM boot time — near-instant serverless compute for sudden spikes

EKS Fargate Profiles:
  - Run specific namespaces/pods on Fargate instead of EC2 node groups
  - No node management at all for those workloads, but no GPU support on Fargate

29.4 Governance: Azure Policy for Kubernetes / OPA Gatekeeper

# OPA Gatekeeper constraint — require resource limits on every container
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredResources
metadata:
  name: require-resource-limits
spec:
  match:
    kinds:
      - apiGroups: ["apps"]
        kinds: ["Deployment"]
  parameters:
    limits: ["cpu", "memory"]

Azure Policy for Kubernetes is built on OPA Gatekeeper under the hood and lets you enforce cluster-wide guardrails declaratively — e.g., “no privileged containers,” “images must come from an approved registry,” “every pod must have resource limits” — evaluated as an admission webhook so non-compliant manifests are rejected before they’re ever scheduled.

29.5 Scaling: Multi-Layered Approach

1. Pod level:          HPA (CPU/memory) or KEDA (event-driven, e.g. queue depth)
2. Node level:          Cluster Autoscaler adds/removes VM nodes as pod demand changes
3. Instant burst:       Virtual Nodes (AKS/ACI) or Fargate (EKS) for sudden spikes
                        where waiting for a VM to boot isn't acceptable

29.6 Observability

  • Azure Monitor Container Insights / CloudWatch Container Insights — scrape node/pod metrics automatically.
  • Application Insights / X-Ray with OpenTelemetry — application-level distributed tracing across the API Gateway → pod → database chain.
  • Prometheus + Grafana (self-hosted or Azure Managed Prometheus / Amazon Managed Prometheus) — the cloud-agnostic standard for cluster and app metrics.

29.7 Interview Q&A

Q1: How do you handle networking and IP management in AKS?

A: The core decision is Azure CNI versus Kubenet. For a large enterprise with strict VNet integration requirements — every pod needs a routable IP from the Azure subnet, direct on-prem connectivity via ExpressRoute, NSGs targeting individual pods — I choose Azure CNI. But IP exhaustion is a real risk in large microservice deployments with hundreds of pods, so in that case I use Azure CNI Overlay or Kubenet: nodes still get VNet IPs, but pods get addresses from a separate, non-VNet-consuming CIDR space. The EKS equivalent trade-off is VPC CNI (routable pod IPs, same exhaustion risk, mitigated with prefix delegation) versus an overlay CNI like Cilium for very large clusters.

Q2: How do you manage security and secrets for pods running in AKS or EKS?

A: I never store secrets or connection strings in the cluster as plain ConfigMaps or even native Secrets. My standard is Key Vault (or Secrets Manager) paired with Workload Identity (AKS) or IRSA (EKS) — the modern replacement for Pod Identity/instance-profile-on-node patterns. This lets a specific pod assume a specific Managed Identity/IAM role and authenticate directly to Azure/AWS services without a single static credential existing in the code, image, or cluster. For governance across the whole cluster, I enforce policy with Azure Policy for Kubernetes (AKS) or OPA Gatekeeper (portable, also usable on EKS) — things like “no privileged containers,” “images only from the approved registry,” “every deployment must declare resource limits” — enforced at admission time so violations are rejected, not just flagged after the fact.

Q3: How do you handle scaling in AKS/EKS for unpredictable traffic?

A: Multi-layered. At the pod level, HPA for CPU/memory-based scaling, or KEDA when scaling should track queue depth (SQS, Kafka, Service Bus) — KEDA is also the only path to scale-to-zero. At the node level, once HPA wants more pods than the node pool has capacity for, Cluster Autoscaler adds nodes automatically — but that’s on the order of a minute or more for a VM to boot. For genuinely instantaneous bursts where I can’t wait on VM boot time, I integrate Virtual Nodes backed by ACI (AKS) or Fargate profiles (EKS) for serverless, near-instant compute that bypasses the node pool entirely. GPU workloads are the exception — neither ACI Virtual Nodes nor Fargate support GPU, so GPU bursting still depends on Cluster Autoscaler with a pre-provisioned buffer or a fast-boot GPU-optimized node image.

Q4: How do you monitor and observe a distributed system running on AKS/EKS?

A: Observability has to be built in from day one, not bolted on. I enable Azure Monitor Container Insights or CloudWatch Container Insights to get node/pod metrics automatically with no app code changes. For application-level distributed tracing — essential in a microservices/agentic system — I instrument with OpenTelemetry feeding Application Insights or X-Ray, which gives me a full end-to-end transaction map: a failed request can be traced from the API Gateway, through specific pods, down to the database query or the LLM call that actually failed. I standardize on Prometheus-compatible metrics (Managed Prometheus on either cloud) plus Grafana dashboards so the same dashboards and alerting rules are portable if we ever run a hybrid or multi-cloud footprint.

Top buzzwords to know cold for AKS/EKS interviews: Azure CNI / Kubenet / VPC CNI, Workload Identity / IRSA, KEDA, Azure Policy for Kubernetes / OPA Gatekeeper, Virtual Nodes / ACI / Fargate.