Lesson 1 of 2 Amazon EKS

Running Kubernetes Workloads on Amazon EKS

This lesson explains how Amazon Elastic Kubernetes Service (Amazon EKS) runs the Kubernetes control plane for you, so teams that use Kubernetes can run workloads on AWS without managing it themselves.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how pods run on managed node groups, self-managed instances or Fargate.
  • Distinguish pod-level scaling from node-level scaling.
  • Explain how EKS Pod Identity and IAM roles for service accounts give each pod its own permissions.
  • Choose between Amazon EKS and Amazon ECS.

Running workloads

Workloads run as pods on worker nodes from managed node groups, self-managed EC2 instances or Fargate. A pod is one or more containers that share a network address and storage, and it is the smallest unit Kubernetes schedules. Workloads are described with Kubernetes manifests, YAML files that declare the desired state, deployed with kubectl or Helm, and usually use images from ECR.

Developers rarely create pods directly. A Deployment declares how many replicas of a pod should run and which image they use; Kubernetes keeps that number running and, when the image changes, replaces pods gradually in a rolling update. Pods are replaced often and change address, so a Service gives a set of pods one stable name and address and spreads requests across them. ConfigMaps and Secrets hold configuration and sensitive values outside the image and supply them as environment variables or files. An Ingress exposes services to clients outside the cluster; on EKS, the AWS Load Balancer Controller creates an Application Load Balancer for it.

Probes tell Kubernetes about a container's health. A liveness probe that fails causes the container to be restarted, and a readiness probe that fails removes the pod from its Service until it is ready, so traffic does not reach a pod that is still starting. The following table summarises these objects.

Kubernetes objectPurpose
DeploymentManages replicated pods and rolling updates
ServiceGives pods a stable network endpoint
ConfigMap, SecretSupply configuration and secrets
IngressWith the AWS Load Balancer Controller, creates an Application Load Balancer
Liveness and readiness probesDecide when containers restart and when they receive traffic

Scaling

EKS scales at two levels, and both are usually needed. The Horizontal Pod Autoscaler changes the number of pod replicas in a Deployment to keep a metric, such as average CPU utilisation, near a target. Adding pods helps only if the cluster has room for them; pods that cannot be placed wait in a pending state.

Node scaling adds and removes the EC2 instances that run the pods. The Cluster Autoscaler adjusts the size of the Auto Scaling groups behind node groups when pods are pending or nodes are underused. Karpenter instead launches individual instances of the size and type that the pending pods need, which usually reacts faster and wastes less capacity. EKS Auto Mode lets AWS manage node provisioning and scaling entirely, and pods on Fargate need no node scaling at all. The following table summarises the tools.

What scalesTool
PodsHorizontal Pod Autoscaler, based on metrics such as CPU
NodesKarpenter or the Cluster Autoscaler; EKS Auto Mode manages nodes for you
Sort into groups

Scale pods and nodes

Exam skills 4.3.1 · 3.3.2

Choose the EKS scaling tool for each situation.

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

AWS permissions for pods

Pods get AWS permissions through EKS Pod Identity or IAM roles for service accounts (IRSA), which uses AssumeRoleWithWebIdentity. Each application gets its own least-privilege role instead of sharing the node's role.

The following diagram shows each application's pods receiving their own role.

AWS permissions for EKS pods. Through EKS Pod Identity, or IAM roles for service accounts, which uses AssumeRoleWithWebIdentity, each application's pods receive their own least-privilege role, so the orders pods can read the orders table and the reports pods can read the reports bucket. Relying on the node's role would give every pod on the node the same permissions.
Per-application roles keep a compromised pod from using another application's permissions.

EKS or ECS?

Amazon EKS and Amazon ECS both run containers on EC2 or Fargate, so the choice depends on the orchestration model rather than on the compute. ECS is an AWS-specific orchestrator with fewer concepts and deep integration with other AWS services, and it has no charge for the control plane. It suits teams that want to run containers on AWS with the least operational effort.

EKS runs standard Kubernetes, so it suits teams that already use Kubernetes, need its ecosystem of tools such as Helm charts and operators, or want workloads that can move between AWS, other clouds and on-premises clusters. The cost is greater complexity and an hourly charge for each cluster. The following table summarises the choice.

ChooseWhen
ECSYou want simpler, AWS-native container orchestration
EKSYou need Kubernetes APIs, tooling or portability
Worked example

Giving one pod access to S3

A pod on EKS must read from one S3 bucket. The quick solution, adding S3 permissions to the node's IAM role, would give every pod on every node that access.

ApproachScope of access
Permissions on the node instance roleEvery pod on the node: too broad
Access keys in a Kubernetes secretLong-term keys to rotate and protect: avoid
EKS Pod Identity (or IRSA) for the pod's service accountOnly pods using that service account

With Pod Identity, the developer creates a role trusting the Pod Identity service, associates it with the service account, and the AWS SDK in the pod picks up the credentials automatically. Readiness probes ensure the pod receives traffic only once it is ready.

Check yourself

When should a team choose EKS rather than ECS?

Show answer

When it already uses Kubernetes or needs Kubernetes tools and portability. ECS is simpler to run for teams without Kubernetes experience.

Exam Tips

Remember for the exam

  • To give a pod its own AWS permissions, use EKS Pod Identity or IRSA.
  • Kubernetes APIs and tooling point to EKS; simpler AWS-native containers point to ECS.
  • To expose pods through an ALB, use an Ingress with the AWS Load Balancer Controller.
  • To scale pods on CPU, use the Horizontal Pod Autoscaler.