Challenge, Medium,  on  Kubernetes

Place One Pod per Node Without Using a DaemonSet

Scenario

You are working in the aws-ecr namespace on a Kubernetes cluster with two worker nodes.

An application must be deployed with three replicas, but the design requires that no more than one Pod runs on the same worker node.

A DaemonSet must not be used to achieve this behavior.


Tasks

  1. Create a Deployment named ecr-deployment with 3 replicas in the aws-ecr namespace.
  2. Apply the following labels to the Deployment and Pod template:
    • app: ecr-app
    • tier: backend
  3. Configure the Deployment with two containers:
    • eks-container1 using image public.ecr.aws/docker/library/httpd:alpine
    • eks-container2 using image public.ecr.aws/eks-distro/kubernetes/pause:3.10.1
  4. There should only ever be one Pod from that Deployment running on a single worker node. Use topologyKey: kubernetes.io/hostname for this.
  5. Verify the scheduling result:
    • Two Pods should be in the Running state
    • One Pod should remain in the Pending state

🧪 Test Cases

Level up your Server Side game — Join 20,000 engineers who receive insightful learning materials straight to their inbox