Skip to main content

Running Kubernetes Workloads on Amazon EKS

Run production Kubernetes on Amazon EKS: pick node types, understand the VPC CNI, add EBS and EFS storage, and give pods AWS access with IRSA.

Overview and What You Will Learn

Amazon EKS is AWS's managed Kubernetes service. AWS runs and patches the control plane across multiple Availability Zones, and you choose the worker compute that runs your pods. Choose EKS over ECS when your team already uses Kubernetes tooling such as Helm or ArgoCD, or when you need portability across clouds and on-premises.

In this lab, you will:

  • Create an EKS cluster with a managed node group and an OIDC provider using eksctl
  • Deploy and scale a workload with kubectl
  • Give a pod least-privilege AWS access with IRSA and prove it with an STS call
  • Clean up so the cluster stops billing

Why This Matters in Production

Picture a platform team at a payments company like Razorpay. Their deployment flow is built on Helm charts, ArgoCD, Prometheus and a service mesh, and every one of those tools speaks the Kubernetes API. EKS lets them run all of it on AWS without rewriting anything. The security stake is just as real: by default every pod on a node can use the node's IAM role, so one compromised pod inherits every permission the node holds. IRSA removes that blast radius.

Core Principles

How to Choose Between ECS and EKS

ECS is the simpler, AWS-only option, while EKS is the open Kubernetes standard with a steeper learning curve.

Choose When
EKS Your team knows Kubernetes, you are migrating on-premises clusters, or multi-cloud matters
ECS You are starting fresh and want the simplest AWS-native container service
Remember

In exam questions, the word "Kubernetes" points to EKS, while "simple AWS-native containers" points to ECS.

What AWS Manages and What You Manage

AWS runs the Kubernetes API server, etcd, scheduler and controller manager across multiple AZs, backed by a 99.95% control plane SLA. You manage the worker compute, unless you use Fargate.

flowchart TD subgraph AWS[AWS managed] CP[Control plane
API server and etcd] end subgraph VPC[Your VPC private subnets] MNG[Managed node group
EC2 workers] FG[Fargate profile
no nodes] POD[(Pods with
real VPC IPs)] end CP -->|Schedules| MNG CP -->|Schedules| FG MNG --> POD FG --> POD classDef aws fill:#F97316,color:#FFFFFF classDef compute fill:#326CE5,color:#FFFFFF classDef pod fill:#D1FAE5,color:#1E293B class CP aws class MNG,FG compute class POD pod
Which Node Type Should You Use

Managed Node Groups suit most production workloads, because AWS handles provisioning and AMI updates through rolling upgrades.

Node type Who manages EC2 Storage and pricing
Managed Node Group AWS provisions, you pick sizes EBS, EFS, Spot
Self-Managed Nodes You, including custom AMIs EBS, EFS, Spot
Fargate Profile Nobody, it is serverless EFS only, no Spot
How the VPC CNI Gives Every Pod a Real IP

EKS uses the AWS VPC CNI plugin, so every pod receives a real IP address from your subnet instead of an overlay address. Pods are reachable directly inside the VPC, and security groups can be applied to pods, so an RDS instance can allow traffic from a pod's security group.

Common Mistake

Using small subnets for EKS. Each pod consumes a VPC IP, so a /27 subnet fills up fast. Use /20 or larger subnets, or enable prefix delegation on the VPC CNI.

How to Add Storage with CSI Drivers

Install a CSI driver and define a StorageClass. EBS gives one pod a dedicated block volume, and EFS gives many pods a shared file system.

YAML
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-gp3
provisioner: ebs.csi.aws.com
parameters:
type: gp3
encrypted: "true"
volumeBindingMode: WaitForFirstConsumer
YAML
# StorageClass using EFS (shared storage, many pods at once)
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: efs-sc
provisioner: efs.csi.aws.com
parameters:
provisioningMode: efs-ap
fileSystemId: fs-0abc123456789def
directoryPerClaim: "true"
Storage Access mode Works on Fargate
EBS ReadWriteOnce No
EFS ReadWriteMany Yes
Remember

If a Fargate pod needs persistent storage, the answer is always EFS, because EBS cannot attach to Fargate.

How IRSA Gives Pods Least-Privilege AWS Access

IRSA (IAM Roles for Service Accounts) maps a Kubernetes service account to an IAM role through the cluster's OIDC provider, so each pod gets only the permissions it needs. Without it, all pods on a node share the node's instance profile.

sequenceDiagram participant P as Pod participant S as AWS STS participant A as AWS service P->>S: Present service account token S-->>P: Temporary role credentials P->>A: Call API with credentials A-->>P: Response

The role's trust policy ties it to one service account through the sub condition:

JSON
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789012:oidc-provider/oidc.eks.ap-south-1.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.eks.ap-south-1.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:sub": "system:serviceaccount:devops-namespace:orders-service-account"
}
}
}]
}

The service account then carries the role ARN as an annotation, and any pod that sets serviceAccountName to it receives that role:

YAML
apiVersion: v1
kind: ServiceAccount
metadata:
name: orders-service-account
namespace: devops-namespace
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/devops-orders-pod-role
Tip

EKS Pod Identity is the newer alternative to IRSA. It skips the per-cluster OIDC trust setup and is worth evaluating for new clusters, but IRSA remains widely deployed and is still the one to know first.

Which Add-ons and Controllers Run Your Cluster

EKS add-ons are components AWS can install and upgrade for you: CoreDNS (service DNS), kube-proxy (Service routing rules), the VPC CNI (pod networking) and the EBS and EFS CSI drivers. The AWS Load Balancer Controller is installed separately, usually with Helm, and creates an ALB when you apply an Ingress and an NLB for a LoadBalancer Service.

YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: devops-ingress
namespace: devops-namespace
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
spec:
ingressClassName: alb
rules:
- host: api.devops-network.in
http:
paths:
- path: /orders
pathType: Prefix
backend:
service:
name: orders-service
port:
number: 80

Detailed Step-by-Step Practical Lab

This lab creates billable resources: the EKS control plane bills per hour, plus the EC2 nodes. Finish the cleanup step in the same sitting. You need the AWS CLI, kubectl and eksctl installed, with credentials that can create EKS, EC2 and IAM resources.

  1. Create the cluster with a managed node group. The --with-oidc flag creates the OIDC provider that IRSA needs, which eksctl does not do by default. It takes 15 to 20 minutes:
Bash
export AWS_REGION=ap-south-1
export CLUSTER=mumbai-prod-cluster
eksctl create cluster \
--name $CLUSTER \
--region $AWS_REGION \
--nodegroup-name mumbai-prod-nodes \
--node-type t3.medium \
--nodes 2 --nodes-min 2 --nodes-max 5 \
--with-oidc
  1. Point kubectl at the cluster and confirm both nodes are Ready:
Bash
aws eks update-kubeconfig --region $AWS_REGION --name $CLUSTER
kubectl get nodes -o wide
  1. Deploy nginx, then check that pod IPs come from your VPC range because of the VPC CNI:
Bash
kubectl create deployment devops-api --image=nginx --replicas=2
kubectl expose deployment devops-api --port=80 --type=ClusterIP
kubectl get pods -o wide
  1. Scale the deployment and watch the new pods start:
Bash
kubectl scale deployment devops-api --replicas=4
kubectl rollout status deployment devops-api
kubectl logs -l app=devops-api --tail=5
  1. Create a service account bound to an IAM role with read-only S3 access:
Bash
eksctl create iamserviceaccount \
--name s3-reader-sa \
--namespace default \
--cluster $CLUSTER \
--region $AWS_REGION \
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
--approve
# Look for the eks.amazonaws.com/role-arn annotation
kubectl describe serviceaccount s3-reader-sa
  1. Prove the difference. A pod using the new service account assumes the IRSA role, while a pod on the default service account falls back to the node's role:
Bash
# Uses IRSA: the ARN shows an assumed-role created for s3-reader-sa
kubectl run irsa-test --rm -i --restart=Never \
--image=amazon/aws-cli \
--overrides='{"spec":{"serviceAccountName":"s3-reader-sa"}}' \
--command -- aws sts get-caller-identity
# Default service account: the ARN shows the shared node instance role
kubectl run node-role-test --rm -i --restart=Never \
--image=amazon/aws-cli \
--command -- aws sts get-caller-identity
  1. Clean up. Delete the Service first so any load balancer it created is removed before the VPC:
Bash
kubectl delete deployment devops-api
kubectl delete svc devops-api
eksctl delete cluster --name $CLUSTER --region $AWS_REGION

Production Best Practices & Common Pitfalls

Common Mistake

Letting pods use the node's EC2 instance profile for AWS access. A compromised pod then holds everything the node can do. Use IRSA or Pod Identity so each workload gets its own narrow role.

Tip

Use eksctl for cluster creation and management. One command sets up the VPC, subnets, node group and IAM roles, where raw aws eks calls take many steps.

Security

The cluster API endpoint is public by default. Restrict it to known CIDR ranges or make it private-only for production, and enable control plane logging for audit and debugging.

  • Use Managed Node Groups for standard workloads. Self-managed nodes add operational work without a benefit in most cases.
  • Plan subnet sizes up front. The VPC CNI assigns one VPC IP per pod, so retrofitting a larger subnet is painful.
  • Create the OIDC provider at cluster creation. IRSA depends on it, and forgetting it is the most common reason a pod cannot assume its role.
  • Use the AWS Load Balancer Controller for Ingress. The old in-tree cloud provider load balancer path is legacy.
  • Use EFS for anything a Fargate pod must persist. EBS cannot attach to Fargate.
  • Pin and test Kubernetes upgrades. Upgrade the control plane first, then the node groups and add-ons, in a non-production cluster before production.

Quick Reference & Troubleshooting Commands

Command Description
eksctl create cluster --with-oidc Create a cluster with the IRSA OIDC provider
aws eks update-kubeconfig --region ap-south-1 --name NAME Point kubectl at a cluster
aws eks list-addons --cluster-name NAME List installed EKS add-ons
aws eks list-nodegroups --cluster-name NAME List managed node groups
kubectl get nodes -o wide Check node status and IPs
kubectl describe pod POD Inspect scheduling events and errors
kubectl logs POD --follow Stream container logs
Problem Likely cause Fix
Pods stuck in Pending No node has free capacity Add nodes or run Cluster Autoscaler or Karpenter
Pod cannot call an AWS service Missing OIDC provider or wrong role ARN Check the service account annotation and OIDC provider
Pods fail to get an IP Subnet out of free addresses Use larger subnets or enable prefix delegation
Node shows NotReady Node failed its health check Run kubectl describe node NAME and check the kubelet
ImagePullBackOff Wrong image URI or missing ECR permission Verify the image URI and the node role's ECR access

Resources

AWS Direct Connect vs VPN: Run Both as Failover

AWS Direct Connect vs VPN: Run Both as Failover

Run AWS Direct Connect as primary and Site-to-Site VPN as BGP failover. Size the backup, set route preference and test it before an outage does.

10 min read•Aug 2026
Lambda vs Fargate vs EC2 Spot: The Cost Crossover

Lambda vs Fargate vs EC2 Spot: The Cost Crossover

Lambda vs Fargate vs EC2 Spot, at the crossover where Lambda stops being cheaper — 2026 pricing, invocation thresholds, and interruption math.

5 min read•Aug 2026
Secrets Manager vs Parameter Store vs Vault

Secrets Manager vs Parameter Store vs Vault

Secrets Manager vs Parameter Store vs Vault: cost math, rotation, dynamic secrets and a decision flow, plus the Vault, IBM and OpenBao licensing context.

10 min read•Aug 2026
AWS VPC Security: Hardening Every Layer

AWS VPC Security: Hardening Every Layer

Harden your AWS VPC in layers: subnets, Security Groups, NACLs, Flow Logs, endpoints, and IAM conditions, with CLI examples for production.

10 min read•Jul 2026
Event-Driven Architecture on AWS Explained

Event-Driven Architecture on AWS Explained

Build event-driven systems on AWS with SQS, SNS, EventBridge and Kinesis: fan-out, DLQs, idempotent consumers and queue-based scaling.

11 min read•Jul 2026
S3 vs RDS vs DynamoDB: Choosing AWS Storage

S3 vs RDS vs DynamoDB: Choosing AWS Storage

Choosing S3, RDS, or DynamoDB wrong costs you in performance, cost, and scalability. Here is a practical decision guide based on your actual access patterns.

5 min read•Jul 2026
AWS Cost Optimisation: 8 Actions That Cut Bills

AWS Cost Optimisation: 8 Actions That Cut Bills

Cut your AWS bill without re-architecting: eight ordered steps from anomaly alerts and tagging to rightsizing, VPC endpoints, Savings Plans and Spot.

11 min read•Jul 2026
EC2 vs Lambda vs Fargate: Choosing AWS Compute

EC2 vs Lambda vs Fargate: Choosing AWS Compute

Choose between EC2, Lambda and Fargate using traffic shape, state and runtime limits, with worked cost break-evens instead of rules of thumb.

11 min read•Jul 2026

Explore More in AWS Messaging, Analytics, and Containers

All 6 Topics

Frequently Asked Questions

Is Running Kubernetes Workloads on Amazon EKS free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Running Kubernetes Workloads on Amazon EKS topic cover?

Run production Kubernetes on Amazon EKS: pick node types, understand the VPC CNI, add EBS and EFS storage, and give pods AWS access with IRSA.

Found a mistake, an outdated step or a broken link?