Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

Amazon ECS and EKS Hands-On Interview Questions: AWS CLI, kubectl and Real Debugging (50 Questions)

This page has 50 hands-on interview questions on Amazon ECS and Amazon EKS, with full answers. Most answers show the exact AWS CLI or kubectl command, sample output, and what the output tells you. The basics of tasks, services, pods and roles are in Set 1; here we practise using and fixing them.

1. An everyday example: a shipping port

Why do hands-on container questions matter?

Container problems are found in command output: a stopped reason, a service event, a pod event. Interviewers for DevOps and SRE roles often ask "which command would you run first?" Knowing the commands and how to read them shows real experience.

Think of a shipping port. Containers are the boxes, the task definition or pod spec is the packing list, and ECS or EKS is the port authority that decides which ship (server) carries which box. When a box is rejected, the port writes a reason on a slip. Your job is to read that slip.

How to use this page

  • Practise in a test account with a small ECS Fargate service and a small EKS cluster.
  • Delete the EKS cluster when done, because the control plane is charged per hour.
  • All names and IDs here are examples, such as account 111122223333.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. How do you find why an ECS task stopped, using the CLI? Fresher

List recently stopped tasks, then describe one.

aws ecs list-tasks --cluster shop --service-name web --desired-status STOPPED --query "taskArns[0]" --output text

Output:

arn:aws:ecs:ap-south-1:111122223333:task/shop/0a1b2c3d4e5f
aws ecs describe-tasks --cluster shop --tasks 0a1b2c3d4e5f --query "tasks[].[stoppedReason,containers[].[name,exitCode,reason]]"

Output:

["Essential container in task exited", [["web", 1, null]]]

The main container exited with code 1, so the application crashed. Read its logs in CloudWatch next. Stopped tasks are visible only for a short time, so check quickly or capture events with EventBridge.

Q2. How do you read the recent events of an ECS service? Fresher
aws ecs describe-services --cluster shop --services web --query "services[].events[:3].[createdAt,message]" --output text

Output:

2026-11-20T10:05:12  (service web) has reached a steady state.
2026-11-20T10:01:40  (service web) registered 2 targets in (target-group web-tg)
2026-11-20T10:00:55  (service web) has started 2 tasks: (task 0a1b...) (task 9f8e...).

The service started two tasks, registered them with the load balancer and is now stable.

Messages such as "unable to place a task" or "failed ELB health checks" point you straight to the problem.

Q3. How do you restart all tasks of an ECS service without changing the task definition? Fresher
aws ecs update-service --cluster shop --service web --force-new-deployment

ECS starts a new deployment with the same task definition. New tasks start and old ones stop, following the deployment settings.

Uses:

  • Pick up a new image pushed with the same tag (better: use unique tags).
  • Reload secrets that are read only at task start.
  • Move tasks off a bad host.
Q4. Which CPU and memory sizes can a Fargate task use? Fresher

Fargate supports fixed combinations. The memory you can pick depends on the CPU size. For example:

  • 0.25 vCPU (256 CPU units): 0.5, 1 or 2 GB.
  • 0.5 vCPU: 1 to 4 GB.
  • 1 vCPU: 2 to 8 GB.
  • Larger sizes go up to 16 vCPU with up to 120 GB (check current limits).

If you set a combination that is not allowed, registering or running the task fails with a validation error.

Size from real usage: Container Insights shows CPU and memory used per task.

Q5. What does the "essential" flag mean in an ECS container definition? Fresher

If a container marked essential: true stops, ECS stops the whole task.

  • The main application container should be essential.
  • Helper containers, such as a one-time init container, can be non-essential, so the task keeps running after they finish.

Example: a task with an app container (essential) and a log router sidecar. If the app crashes, the task stops and the service replaces it.

Use dependsOn with conditions (START, COMPLETE, SUCCESS, HEALTHY) to control start order between containers.

Q6. How do you add a container health check to an ECS task definition? Fresher

Add healthCheck to the container definition:

Output:

"healthCheck": {
  "command": ["CMD-SHELL", "curl -f http://localhost:8080/health || exit 1"],
  "interval": 30, "timeout": 5, "retries": 3, "startPeriod": 60 }

ECS runs the command inside the container every 30 seconds. After 3 failures, the container is unhealthy and an essential unhealthy container causes the task to be replaced.

The command needs the tool (curl here) inside the image. startPeriod gives slow apps time to start.

Q7. How do you see the logs of an ECS Fargate service from the terminal? Fresher

If the task uses the awslogs driver, logs are in the log group set in the task definition.

aws logs tail /ecs/web --follow --since 15m

Output:

2026-11-20T10:12:01 ecs/web/0a1b2c3d4e5f Listening on port 8080
2026-11-20T10:12:30 ecs/web/0a1b2c3d4e5f ERROR could not connect to db:5432

The log stream name includes the container name and task ID, so you can see which task logged the error. Here the app cannot reach the database.

Q8. How do you connect kubectl to an EKS cluster? Fresher

Use the AWS CLI to write a kubeconfig entry:

aws eks update-kubeconfig --region ap-south-1 --name shop-eks

Output:

Added new context arn:aws:eks:ap-south-1:111122223333:cluster/shop-eks to /home/dev/.kube/config
kubectl get nodes

Output:

NAME                                       STATUS   ROLES    AGE   VERSION
ip-10-0-1-25.ap-south-1.compute.internal   Ready    <none>   3d    v1.33.1-eks-1234567

kubectl now talks to the cluster, and one node is ready. Your IAM identity must have access to the cluster (through an access entry) or you get "You must be logged in to the server (Unauthorized)".

Q9. How do you see the Kubernetes version and endpoint of an EKS cluster with the AWS CLI? Fresher
aws eks describe-cluster --name shop-eks --query "cluster.[version,status,endpoint,resourcesVpcConfig.endpointPublicAccess]" --output text

Output:

1.33  ACTIVE  https://ABC123.gr7.ap-south-1.eks.amazonaws.com  True

The cluster runs Kubernetes 1.33, is active, and its API endpoint is reachable from the internet (public access is on).

For production, restrict public access to known CIDRs or use private endpoint access only.

Q10. How do you list the most recent events in a Kubernetes namespace? Fresher
kubectl get events -n shop --sort-by=.lastTimestamp | tail -5

Output:

2m   Warning   FailedScheduling   pod/web-7d9c-abcde   0/3 nodes are available: 3 Insufficient memory.
1m   Normal    Pulled             pod/api-5f6b-xyz12   Successfully pulled image

The web pod cannot be scheduled because no node has enough free memory for its request.

Events are the fastest way to see scheduling, image pull and probe problems. They are kept only for a short time.

Q11. What are EKS add-ons, and how do you list them? Fresher

EKS add-ons are AWS-managed installs of important cluster software, such as the Amazon VPC CNI, CoreDNS, kube-proxy, the EBS CSI driver and the Pod Identity agent.

aws eks list-addons --cluster-name shop-eks

Output:

{"addons": ["coredns", "kube-proxy", "vpc-cni", "eks-pod-identity-agent"]}

four add-ons are managed by EKS. You can update them with a CLI call, and EKS checks version compatibility.

Q12. How do you check CPU and memory use of pods in EKS? Fresher

Install the Kubernetes Metrics Server (it is available as an add-on), then:

kubectl top pods -n shop

Output:

NAME              CPU(cores)   MEMORY(bytes)
web-7d9c-abcde    250m         310Mi
api-5f6b-xyz12    40m          120Mi

The web pod uses a quarter of a CPU and 310 MiB of memory right now.

Compare this with the pod's requests and limits. The HPA also needs Metrics Server for CPU-based scaling.

Q13. How do you roll back a Kubernetes Deployment to the previous version? Fresher
kubectl rollout history deployment/web -n shop

Output:

REVISION  CHANGE-CAUSE
4         image web:1.4.0
5         image web:1.5.0
kubectl rollout undo deployment/web -n shop
kubectl rollout status deployment/web -n shop

Output:

deployment "web" successfully rolled out

The Deployment went back to revision 4 (image 1.4.0) and all pods are updated.

In GitOps setups, also revert the change in Git, or the tool will apply the bad version again.

Q14. How do you check which task definition revision an ECS service is running? Fresher
aws ecs describe-services --cluster shop --services web --query "services[].deployments[].[status,taskDefinition,runningCount,desiredCount]" --output text

Output:

PRIMARY  arn:aws:ecs:ap-south-1:111122223333:task-definition/web:42  4  4

One deployment (PRIMARY) runs revision 42 with all 4 tasks up.

During a rollout you see two lines: PRIMARY (new) and ACTIVE (old), with their running counts. That tells you how far the deployment has progressed.

Q15. What is Container Insights, and how do you turn it on for an ECS cluster? Fresher

Container Insights collects CPU, memory, network and storage metrics and performance logs for clusters, services and tasks in CloudWatch.

aws ecs update-cluster-settings --cluster shop --settings name=containerInsights,value=enabled

New metrics for the cluster appear in CloudWatch. An enhanced observability mode gives more detail.

It is charged as custom metrics and logs, so turn it on where you need it and check the cost.

Q16. What is ECS Anywhere? Fresher

ECS Anywhere lets you run ECS tasks on your own servers or VMs outside AWS, such as in a data centre or factory.

  • You install the SSM agent and ECS agent on the server and register it.
  • You manage it from the same ECS console and APIs as cloud tasks.
  • Launch type is EXTERNAL.

Use case: data that must stay on premises, or a step in a migration to AWS. Load balancer integration and some features available in AWS are not supported in the same way.

Q17. What does kubectl get pods -o wide add, and why is it useful on EKS? Fresher
kubectl get pods -n shop -o wide

Output:

NAME             READY  STATUS   IP           NODE
web-7d9c-abcde   1/1    Running  10.0.1.143   ip-10-0-1-25.ap-south-1.compute.internal

You can see the pod's IP address and which node runs it.

On EKS with the VPC CNI, the pod IP is a real VPC IP from the subnet. This helps when you check security groups, VPC flow logs or which node has a problem.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q18. What is the ECS deployment circuit breaker? Mid level

The circuit breaker watches a rolling deployment. If new tasks keep failing to start or to pass health checks, it marks the deployment failed and, with rollback on, returns the service to the last working deployment.

aws ecs update-service --cluster shop --service web --deployment-configuration "deploymentCircuitBreaker={enable=true,rollback=true}"

A bad image will no longer leave the service stuck in a loop of failing tasks.

You can also add CloudWatch alarms to the deployment configuration, so high errors trigger rollback even if tasks start fine.

Q19. What do minimumHealthyPercent and maximumPercent control in an ECS rolling update? Mid level

For a service with desired count 4:

  • minimumHealthyPercent 100 and maximumPercent 200: ECS starts 4 new tasks first, then stops old ones. No capacity drop, but needs room for 8 tasks.
  • minimumHealthyPercent 50 and maximumPercent 100: ECS stops 2 old tasks, starts 2 new, then repeats. No extra capacity needed, but you run at half capacity during the update.

Choose based on spare capacity and how much reduced capacity users can tolerate. On Fargate, extra capacity is usually easy to get.

Q20. An ECS Fargate task is stuck in PROVISIONING or fails with "ResourceInitializationError". What do you check? Mid level

These errors happen before your container starts.

  • Network: the task subnet needs a route to ECR, S3 (for image layers), CloudWatch Logs and Secrets Manager, through a NAT gateway or VPC endpoints.
  • Subnet IPs: each Fargate task needs an ENI and an IP. A full subnet blocks new tasks.
  • Secrets: the execution role must be allowed to read the referenced secrets and the KMS key.
  • Log group: it must exist, or the execution role must be able to create it.
aws ecs describe-tasks --cluster shop --tasks 0a1b2c3d4e5f --query "tasks[].stoppedReason" --output text

Output:

ResourceInitializationError: unable to pull secrets or registry auth: ... i/o timeout

A network path to Secrets Manager or ECR is missing.

Q21. Which VPC endpoints does a Fargate task in a private subnet with no NAT gateway need? Mid level

For a typical task that pulls from ECR, writes logs and reads secrets:

  • com.amazonaws.<region>.ecr.api (interface)
  • com.amazonaws.<region>.ecr.dkr (interface)
  • com.amazonaws.<region>.s3 (gateway), because image layers are stored in S3
  • com.amazonaws.<region>.logs (interface) for CloudWatch Logs
  • com.amazonaws.<region>.secretsmanager or ssm (interface) if the task uses secrets

Interface endpoints need private DNS on and a security group that allows HTTPS (443) from the tasks.

Add other endpoints for any AWS service the app itself calls, such as sts, sqs or dynamodb (gateway).

Q22. Why do ECS tasks sometimes drop requests during deployments, and how do you fix it with stopTimeout? Mid level

When ECS stops a task, it sends SIGTERM to the container and waits for stopTimeout (30 seconds by default on Fargate, configurable up to 120 seconds). After that it sends SIGKILL.

Requests are dropped if:

  • The app ignores SIGTERM and is killed mid-request.
  • The load balancer deregistration delay is longer than stopTimeout.

Fix:

  • Handle SIGTERM: stop accepting new work, finish current requests, then exit.
  • Make sure the app is PID 1 or uses an init process (initProcessEnabled) so signals reach it.
  • Align deregistration delay with stopTimeout.
Q23. How can an application in an ECS task see which credentials it is using? Mid level

ECS gives the task role credentials through a local endpoint. The SDK finds it with the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.

Inside the container (for example with ECS Exec):

aws sts get-caller-identity

Output:

{"Account": "111122223333", "Arn": "arn:aws:sts::111122223333:assumed-role/web-task-role/0a1b2c3d4e5f"}

The app is using web-task-role, the task role. If you see a different role (such as the EC2 instance role on the EC2 launch type), the task role is missing or the SDK is old.

Q24. How do you route ECS container logs to more than one destination? Mid level

Use FireLens. It adds a Fluent Bit (or Fluentd) sidecar container as the log router.

  • The app container uses the awsfirelens log driver.
  • The router sends logs to CloudWatch Logs, S3 through Firehose, OpenSearch or a third-party tool, based on its configuration.
  • You can filter or change logs before sending, for example drop health check lines.

Example use: errors go to CloudWatch for alarms, and all logs go to S3 for cheap long-term storage.

Q25. How do you mount an EFS file system in an ECS Fargate task? Mid level

In the task definition:

Output:

"volumes": [{"name": "uploads", "efsVolumeConfiguration": {"fileSystemId": "fs-0abc1234", "transitEncryption": "ENABLED", "authorizationConfig": {"accessPointId": "fsap-0def5678", "iam": "ENABLED"}}}]

And in the container: "mountPoints": [{"sourceVolume": "uploads", "containerPath": "/app/uploads"}].

Also needed:

  • The EFS security group must allow NFS (2049) from the task security group.
  • Mount targets in the task subnets' AZs.
  • With iam ENABLED, the task role needs EFS client permissions.

Use EFS when several tasks must share files; it is not for databases.

Q26. What do the EKS access entries do, and how do you give a role admin access to a cluster? Mid level

Access entries map IAM users or roles to Kubernetes permissions through the EKS API, instead of editing the old aws-auth ConfigMap.

aws eks create-access-entry --cluster-name shop-eks --principal-arn arn:aws:iam::111122223333:role/platform-admins
aws eks associate-access-policy --cluster-name shop-eks --principal-arn arn:aws:iam::111122223333:role/platform-admins --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy --access-scope type=cluster

Anyone assuming platform-admins is cluster admin. Use namespace scope and view or edit policies for developers.

Access entries are visible and auditable with the AWS API, which makes mistakes easier to find and fix.

Q27. How do you turn on EKS control plane logs, and which log types exist? Mid level

Log types: api, audit, authenticator, controllerManager and scheduler.

aws eks update-cluster-config --name shop-eks --logging '{"clusterLogging":[{"types":["api","audit","authenticator"],"enabled":true}]}'

These logs are sent to CloudWatch Logs under /aws/eks/shop-eks/cluster.

Audit logs show who did what in the Kubernetes API (for example who deleted a deployment). Authenticator logs help debug login problems. Logs cost money, so pick the types you need.

Q28. A node shows NotReady in EKS. How do you investigate? Mid level
kubectl describe node ip-10-0-2-40.ap-south-1.compute.internal | sed -n '/Conditions/,/Addresses/p'

Output:

MemoryPressure   True   KubeletHasInsufficientMemory
Ready            False  KubeletNotReady

The node ran out of memory and the kubelet is unhealthy.

Other checks:

  • EC2 status checks and console output for the instance.
  • The kubelet and container runtime logs on the node (through SSM).
  • The VPC CNI pod (aws-node) on that node: if it fails, the node may not become Ready.
  • Disk pressure from images or logs.

In managed node groups or Karpenter, you can cordon, drain and replace the node instead of fixing it by hand.

Q29. How do you update an EKS managed add-on such as the VPC CNI? Mid level

Find compatible versions first:

aws eks describe-addon-versions --addon-name vpc-cni --kubernetes-version 1.33 --query "addons[].addonVersions[0].addonVersion" --output text

Output:

v1.20.1-eksbuild.1
aws eks update-addon --cluster-name shop-eks --addon-name vpc-cni --addon-version v1.20.1-eksbuild.1 --resolve-conflicts PRESERVE

EKS updates the add-on and keeps your custom settings (PRESERVE). Version numbers here are examples.

Update add-ons as part of every cluster upgrade, in a test cluster first.

Q30. How do you check if your own identity is allowed to do something in Kubernetes? Mid level

Use kubectl auth can-i:

kubectl auth can-i delete deployments -n shop

Output:

no
kubectl auth can-i get pods -n shop --as system:serviceaccount:shop:web

Output:

yes

You cannot delete deployments in shop. The web service account can read pods.

This is quick for checking RBAC changes before a developer reports "Forbidden" errors.

Q31. What is Karpenter consolidation, and what risk does it bring? Mid level

Karpenter can consolidate nodes: it moves pods off under-used nodes and removes them, or replaces several nodes with a cheaper one, to save cost.

Risk: pods are evicted and restarted more often.

Protect workloads with:

  • PodDisruptionBudgets so not too many replicas stop at once.
  • The karpenter.sh/do-not-disrupt annotation for pods that must not be moved, such as long jobs.
  • Disruption budgets and schedules in the NodePool, for example no consolidation during business peaks.
  • Graceful shutdown in the app.
Q32. What is EKS standard support versus extended support for Kubernetes versions? Mid level

Each Kubernetes minor version on EKS has a standard support period (currently about 14 months after it is released on EKS). After that, it enters extended support for about 12 more months, which has an extra hourly charge for the cluster.

After extended support ends, EKS automatically upgrades the control plane.

Practical point: plan upgrades every few months so you stay in standard support. Check the EKS version calendar for exact dates of your version.

Q33. How do you see which image tags are running across all pods in a namespace? Mid level
kubectl get pods -n shop -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}'

Output:

web-7d9c-abcde	111122223333.dkr.ecr.ap-south-1.amazonaws.com/web:1.5.0
web-7d9c-fghij	111122223333.dkr.ecr.ap-south-1.amazonaws.com/web:1.4.0

Two pods of the same app run different versions, so a rollout may be stuck or half finished.

Check with kubectl rollout status and the Deployment events.

Q46. How do you run a one-off database migration task on ECS before a deployment? Mid level

Run a standalone task with the new image and a command override:

aws ecs run-task --cluster shop --launch-type FARGATE --task-definition web:43 --network-configuration "awsvpcConfiguration={subnets=[subnet-0a1b2c3d],securityGroups=[sg-0abc1234]}" --overrides '{"containerOverrides":[{"name":"web","command":["python","manage.py","migrate"]}]}'

Then wait and check the exit code:

aws ecs wait tasks-stopped --cluster shop --tasks 7c8d9e0f
aws ecs describe-tasks --cluster shop --tasks 7c8d9e0f --query "tasks[].containers[].exitCode" --output text

Output:

0

The migration finished successfully, so the pipeline can update the service. A non-zero code should stop the pipeline.

Q47. How do you set a Kubernetes liveness, readiness and startup probe correctly for a slow Java app on EKS? Mid level
  • startupProbe: gives the app time to start (for example failureThreshold 30 with periodSeconds 10 = up to 5 minutes). Other probes wait until it passes.
  • readinessProbe: decides if the pod receives traffic. Point it at a health endpoint that checks the app is ready.
  • livenessProbe: restarts the container if it is stuck. Keep it simple and do not check dependencies such as the database, or a database blip restarts every pod.

Output:

startupProbe: {httpGet: {path: /health, port: 8080}, failureThreshold: 30, periodSeconds: 10}

Wrong probes are a common cause of CrashLoopBackOff and failed rollouts.

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q34. An ECS deployment is stuck: new tasks start, but old tasks never stop. Why? Senior
  • New tasks are not passing load balancer health checks, so ECS will not stop old tasks below minimumHealthyPercent. Check target health and the health check path and port.
  • The new tasks are healthy in ECS but the ALB health check grace period is too short or too long.
  • There is not enough capacity to place the extra tasks on the EC2 launch type (check "unable to place a task" events).
  • A container health check fails because the tool used in the check is not in the image.

Read service events and target health together. Turn on the circuit breaker so this ends in a rollback instead of hanging.

Q35. Pods on EKS randomly fail DNS lookups under load. How do you troubleshoot? Senior
  • Check CoreDNS pods: CPU, restarts and logs.
kubectl -n kube-system top pods -l k8s-app=kube-dns
  • Scale CoreDNS (more replicas, or the cluster proportional autoscaler), and spread replicas across nodes and AZs.
  • Check the VPC DNS resolver limit: each network interface can send a limited number of packets per second to the Amazon DNS server. Too many lookups from one node can be throttled.
  • Reduce lookups: use NodeLocal DNSCache, and full names with a trailing dot or a lower ndots setting to avoid many search domain lookups.
  • Check security groups allow DNS (UDP and TCP 53) between pods and CoreDNS.
Q36. How do you give different security groups to different pods on the same EKS node? Senior

Use security groups for pods (with the VPC CNI). A SecurityGroupPolicy assigns security groups to pods selected by labels.

Example: only pods labelled app=payments get the security group that RDS allows, so other pods on the same node cannot reach the database.

Points:

  • Supported on many Nitro instance types; pods use branch network interfaces.
  • There are limits per instance type on these interfaces.
  • Kubernetes network policies are another layer for pod-to-pod rules inside the cluster.
Q37. An EKS cluster upgrade is planned. Which commands and checks do you run before the control plane upgrade? Senior
  • Check deprecated APIs that the new version removes (tools such as kubent or pluto, and EKS upgrade insights).
aws eks list-insights --cluster-name shop-eks --filter '{"categories":["UPGRADE_READINESS"]}' --query "insights[].[name,insightStatus.status]" --output text

Output:

Deprecated APIs removed in Kubernetes v1.34  PASSING
  • Check add-on versions that support the target version.
  • Check node versions: nodes may be at most a few minor versions behind the control plane (check the current skew policy).
  • Back up manifests (they are in Git if you use GitOps).
  • Upgrade a test cluster first, then production control plane, add-ons, then nodes.
Q38. How would you run a batch job of 10,000 containers once a night at the lowest risk? Senior
  • Use AWS Batch (on Fargate or EC2) or Step Functions Distributed Map running ECS tasks, rather than starting tasks in a script loop.
  • Use queues and job retries for failures, with limits on parallel jobs so databases are not overloaded.
  • Make each job idempotent with a job ID.
  • Use Spot capacity for cost with on-demand fallback, and checkpoint long jobs.
  • Monitor job success rate and duration; alarm if the batch is not finished by a deadline.
  • Store input and output in S3 with clear prefixes per run.
Q39. How do you find which pods are being OOMKilled across an EKS cluster? Senior
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"/"}{.metadata.name}{"\t"}{.status.containerStatuses[*].lastState.terminated.reason}{"\n"}{end}' | grep OOMKilled

Output:

shop/web-7d9c-abcde	OOMKilled

The web pod's container was killed for using more memory than its limit.

Next:

  • Compare actual memory use (kubectl top, Container Insights) with the limit.
  • Raise the limit or fix the memory use (cache size, leaks, JVM heap settings that ignore container limits).
  • Alarm on restart counts so you find this before users do.
Q40. How do you move an ECS service from the EC2 launch type to Fargate with no downtime? Senior
  • Check the task definition works on Fargate: awsvpc network mode, supported CPU and memory sizes, no host paths or privileged mode, Linux platform version.
  • Register a new revision with requiresCompatibilities FARGATE.
  • Option A: use a capacity provider strategy to shift the same service gradually from the EC2 capacity provider to FARGATE.
  • Option B: create a new Fargate service behind the same target group (or a second target group with weighted ALB rules) and shift traffic.
  • Watch errors and latency, then remove the EC2 capacity.

Update security groups because tasks now have their own ENIs.

Q41. Developers ask for kubectl access to production EKS. How do you design it safely? Senior
  • Use IAM Identity Center roles mapped through access entries; no long-lived IAM users.
  • Give read-only (view) access by default, namespace-scoped.
  • Changes go through GitOps (Argo CD or Flux) and pull requests, not kubectl apply by hand.
  • Break-glass admin role with approval, short sessions and alerts when used.
  • Turn on audit logs and review them.
  • Restrict the API endpoint to the corporate network or VPN.

This gives developers visibility to debug without risky manual changes.

Q42. An ECS service on EC2 instances cannot place tasks: "no container instance met all of its requirements". How do you fix it? Senior

The message lists the reason, for example insufficient memory, insufficient CPU, or a port already in use.

  • Insufficient resources: scale the cluster. With a capacity provider and managed scaling, ECS adds instances automatically.
  • Port conflict: with bridge or host mode and a fixed host port, only one task per instance can use that port. Use dynamic host ports or awsvpc mode.
  • Placement constraints that no instance matches (instance type, attribute, AZ).
  • Instances not registered: check the ECS agent is running and the instance role is correct.
Q43. How do you prove which version of the image is running in production for an audit? Senior
  • Deploy by image digest (sha256), not only by tag, or record the digest of each tag at deploy time.
aws ecs describe-tasks --cluster shop --tasks 0a1b2c3d4e5f --query "tasks[].containers[].[image,imageDigest]" --output text

Output:

111122223333.dkr.ecr.ap-south-1.amazonaws.com/web:1.5.0  sha256:9f86d081884c7d65...
  • Make ECR tags immutable so 1.5.0 cannot be overwritten.
  • Keep pipeline records linking commit, build, digest and deployment.
  • Sign images and verify signatures at deploy time.
Q44. A Fargate service needs to handle 5 times more traffic for one hour daily. How do you scale it reliably? Senior
  • Scheduled scaling: raise the minimum task count shortly before the known peak and lower it after.
  • Target tracking on a good metric, such as ALB request count per target, for unexpected changes.
  • Check limits: Fargate task quotas (vCPU-based), subnet IPs, database connections.
  • Make tasks start fast: small images, quick health check readiness.
  • Load test the peak once with real data.
  • Alarm if running count stays below desired count, which signals capacity or start-up problems.
Q45. What steps do you take when an EKS worker node is suspected to be compromised? Senior
  • Isolate: cordon the node, apply a restrictive security group, and keep the instance for forensics (do not terminate yet).
  • Capture evidence: EBS snapshots, memory if possible, and logs (GuardDuty Runtime Monitoring findings, audit logs, VPC flow logs).
  • Check what the pods on it could access: their IAM roles (Pod Identity or IRSA) and service account tokens; rotate credentials those workloads used.
  • Drain workloads to clean nodes.
  • Find the entry point: vulnerable image, exposed service, privileged pod.
  • Fix and harden: patched AMIs, no privileged pods, network policies, IMDS hop limit 1.
Q48. After a deployment, ECS tasks are healthy but users see 5xx errors from the ALB. How do you narrow it down? Senior
  • Check ALB metrics: HTTPCode_Target_5XX (app errors) versus HTTPCode_ELB_5XX (load balancer errors such as 502 or 503).
  • If target 5xx: read the new tasks' logs, compare errors per task definition revision, and roll back if the new version is the cause.
  • If ELB 502: connection resets or wrong target port; check the container port mapping and keep-alive timeouts.
  • Check that the health check endpoint does not hide real failures (a static /health that is always 200 while /api fails).
  • Add an alarm-based rollback to the deployment configuration for next time.
Q49. How do you design EKS node capacity for a mix of web pods, GPU jobs and Spot-tolerant batch jobs? Senior
  • Separate pools: Karpenter NodePools (or managed node groups) for general on-demand, GPU instances and Spot.
  • Taints on GPU and Spot nodes, with tolerations only on pods that should run there.
  • Node selectors or affinity so batch pods prefer Spot and web pods stay on on-demand.
  • Diversify Spot instance types and AZs so interruptions affect fewer pods.
  • PodDisruptionBudgets for web workloads; checkpointing for batch.
  • Requests set correctly, so bin-packing is accurate and nodes are not wasted.
Q50. A team pushed a new image with the same tag, and half the ECS tasks run old code. Why, and how do you prevent it? Senior

Why: ECS resolves a tag to an image digest when each task starts. Tasks started before the push still run the old digest. A service that was not redeployed keeps old tasks; tasks started later get the new image. So versions mix.

Prevent:

  • Use a unique tag per build (commit SHA or version) and register a new task definition revision for every release.
  • Turn on tag immutability in ECR.
  • Deploy through the pipeline, which updates the service to the new revision and waits for a steady state.

Then every task in a deployment runs the same code.

5. Frequently asked questions

Should I learn the ECS CLI or kubectl first?

Learn the one your target job uses. Many AWS-focused companies use ECS; many product companies use EKS. The debugging ideas (events, logs, health checks, roles) are the same.

Do interviewers expect me to write YAML from memory?

Not every line. They expect you to know the main fields: image, ports, resources, probes, environment and secrets, and to read a manifest correctly.

What is a good practice project?

Deploy one app on ECS Fargate behind an ALB with a canary or rolling update, then deploy the same app on EKS with an Ingress, an HPA and Pod Identity.

6. Quick revision

  • ECS: check stoppedReason on tasks and events on the service first.
  • aws ecs update-service --force-new-deployment restarts tasks with the same task definition.
  • Deployment circuit breaker rolls back failed ECS deployments automatically.
  • EKS: aws eks update-kubeconfig, then kubectl get events --sort-by=.lastTimestamp.
  • kubectl rollout undo returns a Deployment to the previous version.

This page is one part of the complete AWS interview question set. Open the full list here: All 2052 AWS interview questions.