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 |
RememberIn 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.
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 MistakeUsing 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.
apiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: ebs-gp3provisioner: ebs.csi.aws.comparameters: type: gp3 encrypted: "true"volumeBindingMode: WaitForFirstConsumer# StorageClass using EFS (shared storage, many pods at once)apiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: efs-scprovisioner: efs.csi.aws.comparameters: provisioningMode: efs-ap fileSystemId: fs-0abc123456789def directoryPerClaim: "true"| Storage | Access mode | Works on Fargate |
|---|---|---|
| EBS | ReadWriteOnce | No |
| EFS | ReadWriteMany | Yes |
RememberIf 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.
The role's trust policy ties it to one service account through the sub condition:
{ "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:
apiVersion: v1kind: ServiceAccountmetadata: name: orders-service-account namespace: devops-namespace annotations: eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/devops-orders-pod-roleTipEKS 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.
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: devops-ingress namespace: devops-namespace annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ipspec: ingressClassName: alb rules: - host: api.devops-network.in http: paths: - path: /orders pathType: Prefix backend: service: name: orders-service port: number: 80Detailed 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.
- Create the cluster with a managed node group. The
--with-oidcflag creates the OIDC provider that IRSA needs, which eksctl does not do by default. It takes 15 to 20 minutes:
export AWS_REGION=ap-south-1export 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- Point kubectl at the cluster and confirm both nodes are
Ready:
aws eks update-kubeconfig --region $AWS_REGION --name $CLUSTERkubectl get nodes -o wide- Deploy nginx, then check that pod IPs come from your VPC range because of the VPC CNI:
kubectl create deployment devops-api --image=nginx --replicas=2kubectl expose deployment devops-api --port=80 --type=ClusterIPkubectl get pods -o wide- Scale the deployment and watch the new pods start:
kubectl scale deployment devops-api --replicas=4kubectl rollout status deployment devops-apikubectl logs -l app=devops-api --tail=5- Create a service account bound to an IAM role with read-only S3 access:
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 annotationkubectl describe serviceaccount s3-reader-sa- 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:
# Uses IRSA: the ARN shows an assumed-role created for s3-reader-sakubectl 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 rolekubectl run node-role-test --rm -i --restart=Never \ --image=amazon/aws-cli \ --command -- aws sts get-caller-identity- Clean up. Delete the Service first so any load balancer it created is removed before the VPC:
kubectl delete deployment devops-apikubectl delete svc devops-apieksctl delete cluster --name $CLUSTER --region $AWS_REGIONProduction Best Practices & Common Pitfalls
Common MistakeLetting 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.
TipUse eksctl for cluster creation and management. One command sets up the VPC, subnets, node group and IAM roles, where raw
aws ekscalls take many steps.
SecurityThe 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 |