Lesson 2 of 3 Troubleshooting Deployments and Operations

Analysing Failed Processes in Auto Scaling, Amazon ECS and Amazon EKS

Compute platforms report failures in their own ways: Auto Scaling activity history, ECS stopped reasons and service events, Kubernetes pod states and events. This lesson explains where to find the evidence for each platform and how to interpret the most common failure messages, so that incidents involving scaling and containers can be diagnosed quickly.

Learning outcomes

After completing this lesson, you will be able to:

  • Diagnose Auto Scaling failures from activity history, health replacement events and lifecycle hook behaviour.
  • Interpret ECS stopped reasons, exit codes and service events for failed tasks and deployments.
  • Interpret Kubernetes pod states and events on Amazon EKS, including Pending, ImagePullBackOff, CrashLoopBackOff and OOMKilled.
  • Identify the logs and metrics that support container troubleshooting.

Auto Scaling Failures

The activity history of an Auto Scaling group records every launch and termination with its cause and status, and failed activities include the error message. EventBridge receives EC2 Instance Launch Unsuccessful and EC2 Instance Terminate Unsuccessful events for automated alerting. Common situations are summarised below.

SymptomEvidenceCause
Capacity does not increaseDesired capacity at maximumMaximum too low
Launches failActivity history: InsufficientInstanceCapacity, vCPU limit exceeded, invalid AMI, insufficient IPs, permissions on KMS-encrypted volumesCapacity, quotas, launch template errors, KMS key policy
Instances launched and terminated repeatedlyActivity history: instances replaced as unhealthy shortly after launchHealth check grace period too short, or application failing ELB health checks
Instances stuck in Pending:WaitLifecycle stateA launch lifecycle hook waiting for CompleteLifecycleAction until its heartbeat timeout
Unbalanced AZsRebalancing activitiesCapacity unavailable in an AZ; rebalancing in progress

A failure launching instances with encrypted EBS volumes is a common trap: the Auto Scaling service-linked role must be allowed to use the customer managed KMS key in the key policy, otherwise instances terminate immediately with a client error.

Amazon ECS Failures

ECS records why each task stopped. The stopped reason and each container's exit code and reason appear in the console and in DescribeTasks output for about an hour after the task stops, and ECS task state change events in EventBridge preserve them longer. Service events describe scheduler activity, such as being unable to place tasks. Container logs in CloudWatch Logs show application errors, and Container Insights shows resource usage.

Stopped reason or eventMeaning and typical fix
CannotPullContainerErrorImage not found or not accessible: wrong URI or tag, missing ECR permissions on the task execution role, or no route to ECR (NAT or VPC endpoints for ECR API, ECR DKR and S3)
ResourceInitializationError: unable to pull secrets or registry authTask execution role lacks Secrets Manager, Parameter Store or KMS permissions, or no network path to those services
Essential container in task exitedThe application exited; check the exit code and container logs
Exit code 137 or OutOfMemoryErrorContainer killed for exceeding its memory limit; raise memory or fix the leak
Exit code 1 or other non-zeroApplication error, often configuration or a missing dependency
Task failed ELB health checksWrong health check path or port, slow start-up (add a grace period), or security groups blocking the load balancer
Service event: unable to place a task because no container instance met all of its requirementsInsufficient CPU, memory or ports on EC2 capacity, or placement constraints
Deployment circuit breaker rolled backNew tasks repeatedly failed to reach a steady state
Sort into groups

Decode the ECS stop reason

Exam skills 5.3.2

Match each ECS stop reason with its likely cause.

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

Amazon EKS Failures

Kubernetes reports problems through pod status and events, read with kubectl get pods, kubectl describe pod (which lists events) and kubectl logs, including --previous for a restarted container. Container Insights and control plane logs in CloudWatch provide history. Common states are explained below.

Pod state or eventMeaningTypical causes
Pending (FailedScheduling)No node can run the podInsufficient CPU or memory, node selectors or taints, autoscaler limits, no IP addresses available
ImagePullBackOff or ErrImagePullThe image cannot be pulledWrong image name, node role lacks ECR permissions, no route to the registry
CrashLoopBackOffThe container starts and exits repeatedlyApplication error, bad configuration, failing liveness probe
OOMKilledThe container exceeded its memory limitLimit too low or a memory leak
Running but not ReadyReadiness probe failingApplication not ready, wrong probe path or port
Node NotReadyNode unhealthyKubelet or networking problems, resource exhaustion
AccessDenied from AWS SDK in a podPod has no or wrong AWS credentialsMissing EKS Pod Identity association or IRSA annotation, or role trust policy

Cluster access problems, such as kubectl returning Unauthorized, usually mean the IAM principal has no access entry or the wrong access policy for the namespace. IP exhaustion with the VPC CNI appears as pods stuck creating with errors about assigning IP addresses.

Match the pairs

Decode the pod status

Exam skills 5.3.2

Match each Kubernetes pod status with its likely cause.

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

A Service That Never Becomes Healthy

A new ECS service on Fargate in private subnets never reaches its desired count. Tasks appear briefly and stop, and the deployment circuit breaker rolls back.

  1. Read the stopped reason

    DescribeTasks shows ResourceInitializationError: unable to pull secrets.

  2. Check permissions

    The task execution role has secretsmanager:GetSecretValue on the secret, and the secret uses the AWS managed key, so permissions are adequate.

  3. Check the network

    The subnets have no NAT gateway, and the VPC has endpoints only for ECR and S3, so the task cannot reach Secrets Manager.

  4. Fix

    Add an interface endpoint for Secrets Manager (and CloudWatch Logs, which the awslogs driver also needs); the next deployment reaches a steady state.

Check yourself

Pods in an EKS deployment show CrashLoopBackOff. Which commands give the most direct evidence?

Show answer

kubectl describe pod for events and the last state with exit code, and kubectl logs --previous to read the output of the crashed container.

Exam Tips

Remember for the exam

  • Auto Scaling activity history shows launch and termination failures; encrypted volumes need the Auto Scaling service-linked role in the KMS key policy.
  • ECS: CannotPullContainerError (image, permissions or network), ResourceInitializationError (secrets or logs access), exit code 137 (out of memory), ELB health check failures.
  • EKS: Pending (scheduling or capacity), ImagePullBackOff, CrashLoopBackOff, OOMKilled; use kubectl describe, logs --previous and events.
  • Private subnets need VPC endpoints or NAT for ECR, S3, Secrets Manager and CloudWatch Logs.