Lesson 2 of 2 Amazon EKS

Deploying and Rolling Back Workloads on Amazon EKS with Manifests

This lesson explains the Kubernetes manifests a developer writes for Amazon EKS, how a Deployment performs and reverses a rolling update, how probes protect a rollout, and how pods receive AWS permissions.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the parts of a Deployment and a Service manifest.
  • Explain how maxSurge and maxUnavailable control a rolling update.
  • Distinguish readiness, liveness and startup probes.
  • Describe how EKS Pod Identity and Fargate profiles apply to pods.

Deployment and Service manifests

A manifest is a YAML file that declares the desired state of Kubernetes objects. Kubernetes continuously works to make the cluster match it, so deploying a new version means changing the image in the manifest and applying it again. The following manifest runs three replicas of an API and exposes them inside the cluster.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: orders-api
spec:
  replicas: 3
  selector:
    matchLabels: {app: orders-api}
  strategy:
    type: RollingUpdate
    rollingUpdate: {maxSurge: 1, maxUnavailable: 0}
  template:
    metadata:
      labels: {app: orders-api}
    spec:
      serviceAccountName: orders-api
      containers:
        - name: api
          image: 111122223333.dkr.ecr.eu-west-1.amazonaws.com/orders-api:3f9c2ab
          ports: [{containerPort: 8080}]
          resources:
            requests: {cpu: 250m, memory: 512Mi}
          readinessProbe:
            httpGet: {path: /ready, port: 8080}
            periodSeconds: 5
          livenessProbe:
            httpGet: {path: /health, port: 8080}
            initialDelaySeconds: 15
---
apiVersion: v1
kind: Service
metadata:
  name: orders-api
spec:
  selector: {app: orders-api}
  ports: [{port: 80, targetPort: 8080}]

The selector links the Deployment and the Service to pods with the label app: orders-api. Resource requests let the scheduler place pods on nodes with enough capacity. To expose the Service outside the cluster, an Ingress handled by the AWS Load Balancer Controller creates an Application Load Balancer.

Applying, rolling out and rolling back

Access to the cluster is configured with aws eks update-kubeconfig --name cluster, and the caller's IAM principal must be granted Kubernetes permissions, usually through an EKS access entry. The following commands deploy and manage a release.

aws eks update-kubeconfig --name prod-cluster --region eu-west-1
kubectl apply -f orders-api.yaml                       # create or update the objects
kubectl rollout status deployment/orders-api           # wait for the rolling update to finish
kubectl rollout history deployment/orders-api          # list previous revisions
kubectl rollout undo deployment/orders-api             # return to the previous revision

A rolling update creates new pods and removes old ones in steps. maxSurge sets how many extra pods may run above the replica count, and maxUnavailable how many may be unavailable. With maxSurge: 1 and maxUnavailable: 0, as above, capacity never drops: a new pod must become ready before an old one is removed. If new pods never become ready, the rollout stalls rather than replacing the healthy pods, and kubectl rollout undo returns to the previous revision.

Match the pairs

Release commands

Exam skills 3.3.2 · 3.3.7

Match each command with what it does in a release.

Log in to try this activity Interactive activities are free with an account.

Probes and safe rollouts

Probes tell Kubernetes about a container's state, and a rolling update relies on them. The three probe types answer different questions, as the following table shows.

ProbeQuestionWhen it fails
ReadinessCan this pod serve traffic now?The pod is removed from the Service's endpoints; the rollout waits
LivenessIs this container stuck?The container is restarted
StartupHas the application finished starting?Liveness and readiness checks wait until it succeeds; the container is restarted if it never does

A readiness probe that checks the application's dependencies stops traffic from reaching a pod that cannot serve it. A liveness probe that is too aggressive restarts slow-starting containers in a loop, which a startup probe or a longer initial delay prevents.

Sort into groups

Which probe?

Exam skills 4.2.5

Choose the Kubernetes probe for each health question.

Log in to try this activity Interactive activities are free with an account.

Permissions and compute for pods

Pods receive AWS permissions through EKS Pod Identity, which associates an IAM role with a Kubernetes service account, or through IAM roles for service accounts (IRSA). The Deployment above runs as the orders-api service account, so only its pods receive that role's permissions, rather than every pod sharing the node's role. Configuration and secrets come from ConfigMaps and Secrets, or from Secrets Manager through a CSI driver.

Pods can run on managed node groups, on nodes that EKS Auto Mode provisions, or on AWS Fargate: a Fargate profile selects pods by namespace and labels, and each matching pod runs in its own isolated Fargate compute, with no nodes to manage.

Worked example

A rollout that stalls

After kubectl apply with a new image, kubectl rollout status waits and never completes. Users notice no errors.

The developer runs kubectl get pods and sees one new pod that is running but not ready, while the three old pods are still serving. kubectl describe pod shows that the readiness probe fails: the new version expects a CACHE_URL setting that was not added to the ConfigMap.

Because maxUnavailable is 0, no old pod was removed and users were unaffected. The developer runs kubectl rollout undo, adds the missing setting to the ConfigMap in the same commit as the image change, and redeploys.

Check yourself

A rolling update stalls with one new pod that is running but never ready. Are users affected if maxUnavailable is 0?

Show answer

No. With maxUnavailable: 0, old pods are removed only after new pods become ready, so the old pods keep serving traffic while the rollout waits.

Exam Tips

Remember for the exam

  • Deploy or update on EKS: kubectl apply -f with the new image in the manifest.
  • Rolling update with no capacity loss: maxUnavailable 0 and maxSurge of at least 1.
  • Roll back a Deployment: kubectl rollout undo.
  • Readiness probes control traffic and rollout progress; liveness probes restart stuck containers.
  • Give one workload AWS permissions: EKS Pod Identity or IRSA on its service account.