By the end you'll know
- What EKS runs for you, and what you still run: the control plane, nodes, add-ons and your apps
- Why every Kubernetes version on EKS has an end date, and how to avoid paying five times as much after it
- How kubectl signs in to EKS, and how EKS decides who may use it
- Why a small node can only hold a handful of pods, and what the scheduler says when it's full
- Why some AWS resources are made by Kubernetes, not Terraform, and how that changes the order you tear down
Before you start
- You need: the
juniper-ryeprofile, signed in, Lesson 20's virtual environment, Docker running, Terraform 1.11 or newer, kubectl, and the AWS CLI. On a Mac:brew install kubectl awscli. - This lesson builds on three others. Lesson 28 covers the state bucket and the plan-then-apply habit used here. Lesson 27 ran the same menu on ECS, and compares ECS, EKS and your own machine. The Kubernetes track covers Deployments, Services and requests and limits; this lesson is about running them on AWS.
- The lab:
lesson-29in the practice folder:lab.pyand aterraformfolder. Everything is namedjr-lesson29-*and taggedlesson=29. - kubectl uses a kubeconfig of the lab's own,
./kubeconfigin the lesson folder, throughpython lab.py k. Your own~/.kube/config, and any other clusters in it, are never touched. - Where you run things: your own machine, labeled (Your machine).
- Every output below is from a real run on November 15, 2026, with Terraform 1.11.3 and the AWS provider 6.73.0. Long outputs are trimmed to the part that matters; each block is a continuous piece of the real output.
An EKS cluster bills by the hour, even when it's idle
The cluster itself is $0.10 an hour before a single node runs, about $73 a month, and on extended support it's $0.50 an hour. With the nodes and the load balancer, this lab is about 18 cents an hour. Build, explore and destroy in one sitting, and run check at the end. The Terraform here locks the cluster to standard support so it can never drift into the expensive kind.
The short version
- EKS runs Kubernetes' control plane for you; you choose and pay for the nodes, and you deploy the apps.
- Each Kubernetes version gets about 14 months of standard support, then costs five times as much. Upgrade, or let EKS upgrade for you.
- kubectl signs in with your AWS identity, and EKS access entries decide what that identity may do.
- Every pod gets a real address in your VPC, so a node holds only as many pods as it has addresses: 11 on a
t4g.small. - Kubernetes makes some AWS resources itself, like load balancers. Delete them through Kubernetes before Terraform destroys the network.
What this lesson costs
| Part | Cost, in us-east-2 |
|---|---|
| The EKS cluster, standard support | $0.10 an hour |
Two t4g.small nodes, Arm | $0.0168 an hour each |
| Their 20 GB disks | $0.08 per GB a month: about half a cent an hour together |
| The Classic Load Balancer Kubernetes makes | $0.025 an hour |
| Four public IPv4 addresses | $0.005 an hour each |
| This lesson, about 90 minutes | About 27 cents, from credits |
What EKS runs, and what you run
A Kubernetes cluster has two halves. The control plane is the brain: the API server kubectl talks to, the database that remembers everything, and the scheduler that decides where pods go. The nodes are the computers that run your pods. On your laptop with kind, both halves are containers on one machine. On EKS, AWS runs the control plane across several zones, patches it and keeps it available; you choose the nodes and everything that runs on them.
| Part | Is | Who runs it | In the lab |
|---|---|---|---|
| Control plane | The API server, its database and the scheduler | AWS, outside your VPC | Kubernetes 1.37, $0.10 an hour |
| Nodes | EC2 instances that run pods | You choose; a managed node group launches and replaces them | Two t4g.small, Arm |
| Add-ons | The cluster's own pods: networking, DNS, traffic rules | AWS publishes them; you choose versions | vpc-cni, kube-proxy, coredns |
| Your apps | Deployments, Services and the rest | You, with kubectl or a pipeline | The menu, 2 copies |
Versions, and what they cost
Kubernetes releases a new minor version about three times a year, and EKS supports each one for a fixed time. When standard support ends, a cluster still on that version moves to extended support, at a higher price, unless you've said otherwise.
(Your machine)
cd ~/Apps/aws-practice/lesson-29
source ../lesson-20/.venv/bin/activate
python lab.py fence
== Tools on your machine
terraform 1.11.3
kubectl v1.33.3
aws CLI aws-cli/2.39.7
docker linux/arm64 29.9.2
== Kubernetes versions EKS offers today
1.37 standard support standard support ends 2027-11-30 <- the default for new clusters
1.36 standard support standard support ends 2027-08-01
1.35 standard support standard support ends 2027-03-26
1.34 standard support standard support ends 2026-12-01
1.33 extended support standard support ends 2026-07-28
== What it costs in us-east-2 (from the Price List API)
EKS cluster, standard support, an hour $0.1
EKS cluster, extended support, an hour $0.5
t4g.small node (2 vCPU, 2 GiB, Arm), an hour $0.0168
gp3 disk, per GB a month $0.08
Classic Load Balancer, an hour $0.025
Public IPv4 address in use, an hour $0.005
== While it runs: about $0.183 an hour
the cluster $0.10; 2 nodes $0.0336; their disks $0.0044; the load balancer $0.0250; 4 public IPs $0.020
building takes about 15 minutes and destroying about 10: a 90-minute sitting is about $0.27
on extended support the cluster alone would be $0.50 an hour: 5 times as much
A cluster made on 1.34 that day had two weeks of standard support left. After December 1, 2026, it would have cost $0.50 an hour instead of $0.10: about $365 a month instead of $73, for the same cluster doing the same work. That's the most common surprise on an EKS bill.
The Terraform blocks it with one setting:
# STANDARD: when this version's standard support ends, EKS upgrades the cluster
# instead of moving it to extended support, which costs five times as much an hour.
upgrade_policy {
support_type = "STANDARD"
}
With STANDARD, a cluster that reaches the end of standard support is upgraded by EKS to the next version rather than billed for extended support. That's the right default for anything you can upgrade without warning. For production, the better habit is upgrading yourself, a version at a time, a few times a year, before EKS has to.
The kubectl here was 1.33, and the cluster 1.37. kubectl is supported only one minor version either side of the cluster; this run worked, but a newer kubectl avoids odd errors: brew upgrade kubectl.
Build it
The state bucket, the image and the plan-then-apply habit are Lesson 28's, unchanged:
python lab.py state
python lab.py image
python lab.py tf init -backend-config=backend.hcl
python lab.py tf validate
python lab.py tf plan -out=tfplan
== A bucket for Terraform's state: jr-lesson29-state-f2829cd3
== jr-lesson29-state-f2829cd3: versioned, encrypted, private; backend.hcl written
== my-ip.auto.tfvars: allowed_cidr = "your IP/32": the only address that can reach the cluster's API
== version.auto.tfvars: kubernetes_version = "1.37", EKS's default today; standard support to 2027-11-30
== The image repository, made outside Terraform
pushed jr-lesson29-menu:v1, built for Arm like the nodes
The state step asked EKS for today's default version and wrote it into a variables file, so the version is chosen once, on purpose, and recorded, not left to whatever EKS picks. The plan, for the cluster itself:
# aws_eks_cluster.this will be created
+ resource "aws_eks_cluster" "this" {
+ arn = (known after apply)
+ bootstrap_self_managed_addons = false
+ certificate_authority = (known after apply)
+ cluster_id = (known after apply)
+ created_at = (known after apply)
+ deletion_protection = (known after apply)
+ endpoint = (known after apply)
+ id = (known after apply)
+ identity = (known after apply)
+ name = "jr-lesson29"
+ platform_version = (known after apply)
+ region = "us-east-2"
+ role_arn = (known after apply)
+ status = (known after apply)
+ tags_all = {
+ "lesson" = "29"
+ "managed_by" = "terraform"
+ "owner" = "juniper-rye"
}
+ version = "1.37"
+ access_config {
+ authentication_mode = "API"
+ bootstrap_cluster_creator_admin_permissions = true
}
+ compute_config (known after apply)
+ control_plane_scaling_config (known after apply)
+ kube_api_server_config (known after apply)
+ kube_controller_manager_config (known after apply)
+ kube_scheduler_config (known after apply)
+ kubernetes_network_config (known after apply)
+ storage_config (known after apply)
+ upgrade_policy {
+ support_type = "STANDARD"
}
+ vpc_config {
+ cluster_security_group_id = (known after apply)
+ control_plane_egress_mode = (known after apply)
+ endpoint_private_access = true
+ endpoint_public_access = true
+ public_access_cidrs = [
+ "your IP/32",
]
+ subnet_ids = (known after apply)
+ vpc_id = (known after apply)
}
}
Plan: 18 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ cluster_name = "jr-lesson29"
+ kubernetes_version = "1.37"
+ node_count = 2
+ support_type = "STANDARD"
| Setting | Why |
|---|---|
public_access_cidrs: your IP/32 | The Kubernetes API answers only your address. Without it, anyone on the internet can reach the login page of your cluster. |
endpoint_private_access | Nodes reach the API from inside the VPC, so locking the public side to your IP doesn't lock them out |
authentication_mode = "API" | Who may use kubectl is managed with EKS access entries, through AWS, instead of a file inside the cluster |
bootstrap_self_managed_addons = false | The cluster's own pods come from managed add-ons Terraform lists, with versions EKS keeps track of |
upgrade_policy: STANDARD | Never billed for extended support |
python lab.py tf apply tfplan
aws_eks_cluster.this: Creation complete after 8m3s [id=jr-lesson29]
aws_eks_addon.kube_proxy: Creating...
aws_eks_addon.vpc_cni: Creating...
aws_eks_addon.vpc_cni: Creation complete after 7s [id=jr-lesson29:vpc-cni]
aws_eks_addon.kube_proxy: Creation complete after 7s [id=jr-lesson29:kube-proxy]
aws_eks_node_group.default: Creating...
aws_eks_node_group.default: Still creating... [10s elapsed]
aws_eks_node_group.default: Still creating... [20s elapsed]
aws_eks_node_group.default: Still creating... [30s elapsed]
aws_eks_node_group.default: Still creating... [40s elapsed]
aws_eks_node_group.default: Still creating... [50s elapsed]
aws_eks_node_group.default: Still creating... [1m0s elapsed]
aws_eks_node_group.default: Still creating... [1m10s elapsed]
aws_eks_node_group.default: Still creating... [1m21s elapsed]
aws_eks_node_group.default: Still creating... [1m31s elapsed]
aws_eks_node_group.default: Still creating... [1m41s elapsed]
aws_eks_node_group.default: Still creating... [1m51s elapsed]
aws_eks_node_group.default: Creation complete after 1m58s [id=jr-lesson29:jr-lesson29-nodes]
aws_eks_addon.coredns: Creating...
aws_eks_addon.coredns: Still creating... [10s elapsed]
aws_eks_addon.coredns: Creation complete after 14s [id=jr-lesson29:coredns]
Apply complete! Resources: 18 added, 0 changed, 0 destroyed.
Outputs:
cluster_name = "jr-lesson29"
kubernetes_version = "1.37"
node_count = 2
support_type = "STANDARD"
The control plane took 8 minutes; everything else, about 2. The order is the interesting part, and it comes from depends_on in the code. A node isn't Ready until it has pod networking, so the vpc-cni and kube-proxy add-ons go first, then the nodes. CoreDNS runs as ordinary pods, so it can only start once there are nodes for it to run on, and goes last. Get that order wrong and the apply sits waiting on a node that never becomes Ready.
Connect with kubectl
python lab.py kubeconfig
python lab.py k get nodes -o wide
python lab.py k -n kube-system get pods
Added new context jr-lesson29 to ./kubeconfig
== kubectl in this lab uses ./kubeconfig only; your ~/.kube/config is untouched
== How kubectl signs in: it runs aws eks get-token with the juniper-rye profile for each call
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
ip-10-29-0-18.us-east-2.compute.internal Ready <none> 67s v1.37.1-eks-9adbfea 10.29.0.18 3.138.178.186 Amazon Linux 2023.12.20261112 6.18.62-127.179.amzn2023.aarch64 (arm64) containerd://2.3.7+unknown
ip-10-29-1-223.us-east-2.compute.internal Ready <none> 67s v1.37.1-eks-9adbfea 10.29.1.223 3.135.231.78 Amazon Linux 2023.12.20261112 6.18.62-127.179.amzn2023.aarch64 (arm64) containerd://2.3.7+unknown
NAME READY STATUS RESTARTS AGE
aws-node-bc5v9 2/2 Running 0 68s
aws-node-zd5sl 2/2 Running 0 68s
coredns-598bf5b859-bftfx 1/1 Running 0 13s
coredns-598bf5b859-pnlrf 1/1 Running 0 13s
kube-proxy-cn2cl 1/1 Running 0 68s
kube-proxy-ctqkv 1/1 Running 0 68s
kubectl has no password for EKS. aws eks update-kubeconfig wrote a kubeconfig that tells kubectl to run aws eks get-token before each call: the AWS CLI signs a short-lived token with your juniper-rye sign-in, and EKS checks it. When your AWS sign-in expires, so does kubectl's.
Two nodes, one per zone, each named after its private address in the VPC. In kube-system, the add-ons: aws-node is the VPC CNI, one per node, which gives pods their network addresses; kube-proxy, one per node, routes Service traffic; CoreDNS, two copies, answers DNS for the cluster.
Who may use kubectl
python lab.py access
== Who may use kubectl on jr-lesson29 (EKS access entries)
role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS
type STANDARD; Kubernetes groups eks:managed; policies AmazonEKSClusterInsightsPolicy, AmazonEKSEventPolicy, AmazonEKSPodIdentityPolicy
role/jr-lesson29-node-role
type EC2_LINUX; Kubernetes groups system:nodes; policies none
role/managed/AccountFullAccessRole
type STANDARD; Kubernetes groups none; policies AmazonEKSClusterAdminPolicy
An access entry ties an AWS identity to what it may do inside Kubernetes. Three are here: EKS's own service role, so AWS can manage the cluster; the node role, so nodes can join as system:nodes; and the role you signed in with, made cluster admin because you created the cluster, and its access_config says to make the creator an admin.
| Entry | Is | May do |
|---|---|---|
AWSServiceRoleForAmazonEKS | EKS itself | Read events and insights, and run Pod Identity |
jr-lesson29-node-role | Every node | Join the cluster and run its pods |
| Your sign-in role | Whoever ran apply | Everything: AmazonEKSClusterAdminPolicy |
Older clusters kept this in a ConfigMap called aws-auth, inside the cluster; one bad edit there could lock everyone out. Access entries live in AWS, are managed with the AWS API or Terraform, and can't be broken from inside Kubernetes. For a teammate, you'd add an access entry for their role, with a narrower policy such as AmazonEKSViewPolicy.
Deploy the menu
The cluster is the platform; what runs on it is deployed with kubectl, the way a pipeline would. The deploy step writes menu.yaml, a Deployment of 2 copies spread across zones and a Service of type LoadBalancer open to your IP only, and applies it:
python lab.py deploy
python lab.py call
== menu.yaml: a Deployment of 2, spread across zones, and a Service of type LoadBalancer for your IP/32
deployment.apps/menu created
service/menu created
Waiting for deployment "menu" rollout to finish: 0 of 2 updated replicas are available...
Waiting for deployment "menu" rollout to finish: 1 of 2 updated replicas are available...
deployment "menu" successfully rolled out
rolled out in 4 seconds
== Waiting for AWS to make the load balancer Kubernetes asked for
a118788d9d3204d479e757f9f9a6be7a-2135254127.us-east-2.elb.amazonaws.com after 1 seconds
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
menu-785cf46557-qbvcg 1/1 Running 0 5s 10.29.1.111 ip-10-29-1-223.us-east-2.compute.internal <none> <none>
menu-785cf46557-r6n9m 1/1 Running 0 5s 10.29.0.19 ip-10-29-0-18.us-east-2.compute.internal <none> <none>
== GET http://a118788d9d3204d479e757f9f9a6be7a-2135254127.us-east-2.elb.amazonaws.com/ ten times
not answering yet (URLError); a new load balancer's address can take a few minutes
not answering yet (URLError); a new load balancer's address can take a few minutes
not answering yet (URLError); a new load balancer's address can take a few minutes
not answering yet (URLError); a new load balancer's address can take a few minutes
not answering yet (URLError); a new load balancer's address can take a few minutes
v1 menu-785cf46557-qbvcg on ip-10-29-1-223.us-east-2.compute.internal answered 6
v1 menu-785cf46557-r6n9m on ip-10-29-0-18.us-east-2.compute.internal answered 4
Look at the pods' addresses: 10.29.1.111 and 10.29.0.19, from the VPC's own subnets. On EKS, the VPC CNI gives every pod a real VPC address, the same kind a server gets. Anything in the VPC can reach a pod directly, and security groups and flow logs see pod traffic as it is. It also has a limit, which the next section runs into.
Nobody wrote a load balancer into the Terraform, yet one exists. A Service of type LoadBalancer asks the cluster for one, and EKS's built-in controller made a Classic Load Balancer in the tagged public subnets, with its security group limited by loadBalancerSourceRanges to your IP. Its address was known in a second; it answered about 75 seconds later, once its DNS name and health checks caught up. Terraform has no record of it at all, which matters at the end.
How many pods fit?
python lab.py squeeze
== Asking for 30 copies of the menu
deployment.apps/menu scaled
== The menu's pods: 14 pending, 16 running
== Pods per node, out of what each node allows
ip-10-29-0-18.us-east-2.compute.internal us-east-2a 11 of 11 pods
ip-10-29-1-223.us-east-2.compute.internal us-east-2b 11 of 11 pods
== Why the rest are Pending (the scheduler's message)
0/2 nodes are available: 2 Too many pods. preemption: 0/2 nodes are available: 2 No preemption victims found for incoming pod.
Each node was full at 11 pods, though each was nowhere near out of CPU or memory. 30 copies asked for 750m of CPU in all, less than half of one node's. The limit was addresses. Because every pod gets a VPC address, a node can only run as many pods as it has addresses to give out, and a t4g.small has 3 network cards with 4 addresses each, one of which each card keeps for itself:
| Step | Count |
|---|---|
Network cards on a t4g.small | 3 |
| Addresses per card, less the card's own | 4 - 1 = 3 |
| Addresses for pods | 3 × 3 = 9 |
Plus 2 pods that use the node's own address (aws-node, kube-proxy) | 11 pods per node |
Less the add-ons on each node: aws-node, kube-proxy, one CoreDNS | 8 left for the menu, 16 on two nodes |
The scheduler's message says it plainly: 2 Too many pods, not too little CPU or memory. Bigger instance types have more network cards and more addresses each, so the limit grows with size. The VPC CNI can also give each card whole blocks of addresses, called prefix delegation, which raises a small node's limit to 110; real clusters often turn it on.
Add a node with Terraform
python lab.py tf plan -var node_count=3 -out=tfplan
python lab.py tf apply tfplan
python lab.py pods
# aws_eks_node_group.default will be updated in-place
~ resource "aws_eks_node_group" "default" {
id = "jr-lesson29:jr-lesson29-nodes"
tags = {}
# (17 unchanged attributes hidden)
~ scaling_config {
~ desired_size = 2 -> 3
# (2 unchanged attributes hidden)
}
# (1 unchanged block hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
aws_eks_node_group.default: Modifying... [id=jr-lesson29:jr-lesson29-nodes]
aws_eks_node_group.default: Modifications complete after 4s [id=jr-lesson29:jr-lesson29-nodes]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Outputs:
cluster_name = "jr-lesson29"
kubernetes_version = "1.37"
node_count = 3
support_type = "STANDARD"
== The menu's pods: 14 pending, 16 running
== Pods per node, out of what each node allows
ip-10-29-0-18.us-east-2.compute.internal us-east-2a 11 of 11 pods
ip-10-29-1-223.us-east-2.compute.internal us-east-2b 11 of 11 pods
Terraform finished in 4 seconds, and nothing had changed yet. The apply changed the node group's desired size, which is all Terraform does here. The node group then launched an instance, which had to boot, join the cluster and start its own aws-node and kube-proxy before the scheduler could put anything on it: a minute or two. pods ran straight after the apply, so it still saw two nodes and 14 pods waiting.
That's worth remembering beyond this lab: Terraform reporting done means AWS accepted the change, not that the capacity is ready. For the ECS service in Lesson 28, wait_for_steady_state made Terraform wait for healthy copies; a node group has no such wait. Run python lab.py pods again a minute or two later and you'll see a third node with 11 more places, 9 of them for the menu.
In real clusters, nobody runs Terraform to add a node when pods are Pending. Karpenter or the Cluster Autoscaler watches for exactly the message above and adds nodes on its own, then removes them when they're empty; Terraform sets the limits.
Take it down
python lab.py undeploy
python lab.py tf plan -destroy -var node_count=3 -out=tfplan
python lab.py tf apply tfplan
python lab.py delete
== Deleting the menu; Kubernetes deletes the load balancer it made
deployment.apps "menu" deleted
service "menu" deleted
the load balancer is gone after 0 seconds
undeploy has to come first. The load balancer Kubernetes made sits in the VPC, with its own network cards and security group, and Terraform knows nothing about it. Destroy the network first and the VPC can't be deleted while the load balancer is in it: the destroy fails, or hangs, and the load balancer keeps billing with nothing managing it. The lab's tf step refuses a destroy while the Service exists, for exactly this reason.
The load balancer was already gone when kubectl delete returned because a Service of type LoadBalancer carries a finalizer: Kubernetes won't finish deleting the Service until its controller has deleted the load balancer. Deleting through Kubernetes is what makes that cleanup happen.
The destroy's last minutes:
module.network.aws_internet_gateway.this: Destruction complete after 1m40s
aws_eks_node_group.default: Still destroying... [id=jr-lesson29:jr-lesson29-nodes, 1m40s elapsed]
aws_eks_node_group.default: Still destroying... [id=jr-lesson29:jr-lesson29-nodes, 1m50s elapsed]
aws_eks_node_group.default: Still destroying... [id=jr-lesson29:jr-lesson29-nodes, 2m0s elapsed]
aws_eks_node_group.default: Destruction complete after 2m6s
aws_iam_role_policy_attachment.node["arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"]: Destroying... [id=jr-lesson29-node-role/arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy]
aws_iam_role_policy_attachment.node["arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"]: Destroying... [id=jr-lesson29-node-role/arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy]
aws_iam_role_policy_attachment.node["arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"]: Destroying... [id=jr-lesson29-node-role/arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly]
aws_eks_addon.vpc_cni: Destroying... [id=jr-lesson29:vpc-cni]
aws_eks_addon.kube_proxy: Destroying... [id=jr-lesson29:kube-proxy]
aws_iam_role_policy_attachment.node["arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"]: Destruction complete after 0s
aws_iam_role_policy_attachment.node["arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"]: Destruction complete after 0s
aws_iam_role_policy_attachment.node["arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"]: Destruction complete after 0s
aws_iam_role.node: Destroying... [id=jr-lesson29-node-role]
aws_iam_role.node: Destruction complete after 0s
aws_eks_addon.kube_proxy: Destruction complete after 1s
aws_eks_addon.vpc_cni: Destruction complete after 1s
aws_eks_cluster.this: Destroying... [id=jr-lesson29]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 10s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 20s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 30s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 40s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 50s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 1m0s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 1m10s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 1m20s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 1m30s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 1m40s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 1m50s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 2m0s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 2m10s elapsed]
aws_eks_cluster.this: Still destroying... [id=jr-lesson29, 2m20s elapsed]
aws_eks_cluster.this: Destruction complete after 2m28s
aws_iam_role_policy_attachment.cluster: Destroying... [id=jr-lesson29-cluster-role/arn:aws:iam::aws:policy/AmazonEKSClusterPolicy]
module.network.aws_subnet.public[0]: Destroying... [id=subnet-0dddaaadbe1b1baf3]
module.network.aws_subnet.public[1]: Destroying... [id=subnet-0e79722e7e2feb94e]
aws_iam_role_policy_attachment.cluster: Destruction complete after 0s
aws_iam_role.cluster: Destroying... [id=jr-lesson29-cluster-role]
aws_iam_role.cluster: Destruction complete after 0s
module.network.aws_subnet.public[1]: Destruction complete after 0s
module.network.aws_subnet.public[0]: Destruction complete after 1s
module.network.aws_vpc.this: Destroying... [id=vpc-0b2a43667057702f9]
module.network.aws_vpc.this: Destruction complete after 0s
Apply complete! Resources: 0 added, 0 changed, 18 destroyed.
== Deleting the repository and its images
== Deleting the state bucket jr-lesson29-state-f2829cd3, every version of every file in it
== Removed backend.hcl, the .auto.tfvars files, kubeconfig, menu.yaml, the saved plan and .terraform
== Removing 1 image tags from your machine, and the registry login
== Anything left from Lesson 29
nothing: all clear
The building order in reverse: CoreDNS, then the nodes, then the networking add-ons, then the cluster, then the network. The internet gateway waited 1m40s while the nodes, and their public addresses, went away.
By hand: kubectl and the AWS CLI, without the helper
(Your machine) Write a kubeconfig for this cluster only, and use it:
cd ~/Apps/aws-practice/lesson-29
aws eks update-kubeconfig --name jr-lesson29 --region us-east-2 --profile juniper-rye \
--kubeconfig ./kubeconfig --alias jr-lesson29
export KUBECONFIG=./kubeconfig AWS_PROFILE=juniper-rye
kubectl get nodes -o wide
kubectl get nodes -o custom-columns=NAME:.metadata.name,ZONE:.metadata.labels.topology\\.kubernetes\\.io/zone,PODS:.status.allocatable.pods
kubectl get events --field-selector reason=FailedScheduling
Versions, and who may use the cluster:
aws eks describe-cluster-versions --region us-east-2 \
--query "clusterVersions[].[clusterVersion,versionStatus,endOfStandardSupportDate]" --output table
aws eks list-access-entries --cluster-name jr-lesson29 --region us-east-2
Clean up in the right order: Kubernetes' resources first, then Terraform's:
kubectl delete -f menu.yaml --wait=true
cd terraform
terraform plan -destroy -out=tfplan
terraform apply tfplan
In real systems
- Nodes live in private subnets, reaching the internet through NAT, with only load balancers public. The API endpoint is often private-only, reached over a VPN.
- Traffic comes in through the AWS Load Balancer Controller, which makes Application or Network Load Balancers from Ingress or Gateway API objects; the Classic Load Balancer made here is the old built-in way. The Kubernetes track's Gateway API lesson covers the Kubernetes side.
- Karpenter or the Cluster Autoscaler adds and removes nodes as pods need them.
- Apps get AWS permissions with EKS Pod Identity, a role per service account, never the node's role.
- Versions are upgraded on a schedule, a few times a year: control plane, then add-ons, then nodes, tested in a lower environment first.
- Apps are deployed by GitOps, with a tool like Argo CD watching a Git repository, not kubectl from a laptop.
- EKS Auto Mode is an option that also manages nodes, add-ons and load balancers, for an extra fee per node; it trades control for less to run.
Spot the problem
Work out what's wrong before you read the explanation.
"Our test cluster's bill went up five times overnight." A team's test cluster cost about $73 a month for its control plane. One month it's $365, with nothing changed: same nodes, same apps, nobody touched it. What's wrong? The cluster's Kubernetes version reached the end of standard support, and the cluster moved to extended support, at $0.50 an hour instead of $0.10. Nothing changed is the problem: nobody upgraded it. The fix: set the upgrade policy's support type to STANDARD, so EKS upgrades the cluster instead of moving it to extended support, and put upgrades on the calendar before each end date. Then check: run aws eks describe-cluster-versions; how many months of standard support does the cluster's version have left, and is the cluster's support type STANDARD?
Keep this
| Remember | Why |
|---|---|
| The control plane bills by the hour | $0.10 an hour with nothing running |
| Every version has an end date | Extended support was 5 times the price |
upgrade_policy: STANDARD | Never billed for extended support |
| API open to your IP only | Nodes use the private endpoint |
| Access entries decide who uses kubectl | In AWS, not a ConfigMap in the cluster |
| Networking add-ons before nodes, DNS after | Nodes need networking to be Ready; DNS needs nodes |
| Pods get VPC addresses | A t4g.small held 11 pods, then "Too many pods" |
| Terraform done isn't capacity ready | The node group changed in 4 seconds; the node took minutes |
| Delete Kubernetes' resources first | Its load balancer would block destroying the VPC |
Where you are now
Juniper & Rye's menu has run on Kubernetes in AWS: an EKS cluster on 1.37, locked to standard support, with an API only you could reach and two small Arm nodes, all from Terraform, and the menu deployed with kubectl behind a load balancer Kubernetes made itself. You saw why a small node fills up at 11 pods, added a node with one changed value, and tore it down in the order that leaves nothing behind. Next, Lesson 30 compares Terraform with AWS's own tools for the same job: CloudFormation and the CDK.
Check yourself
What does the $0.10 an hour EKS fee pay for?
What does upgrade_policy with support_type STANDARD do when a version's standard support ends?
Why was the coredns add-on created last?
How does kubectl sign in to the EKS cluster?
With 30 copies asked for, why were 14 Pending?
Terraform changed node_count to 3 in 4 seconds. Why did pods still show 2 nodes?
Why must the menu be undeployed before Terraform destroys everything?
Key terms
- EKS (Elastic Kubernetes Service): Kubernetes with the control plane run by AWS.
- Control plane: the API server, cluster database and scheduler; on EKS, run by AWS.
- Node: a computer that runs pods; here, an EC2 instance.
- Managed node group: a group of nodes EKS launches, updates and replaces for you.
- Add-on: a piece of the cluster's own software EKS publishes, like the VPC CNI or CoreDNS.
- VPC CNI: the add-on that gives each pod an address in your VPC.
- Standard support: about 14 months during which a Kubernetes version costs the normal hourly fee.
- Extended support: a further year on an old version, at five times the price here.
- Access entry: an EKS record tying an AWS identity to what it may do in the cluster.
- kubeconfig: the file that tells kubectl which cluster to use and how to sign in.
- Finalizer: a marker that stops Kubernetes deleting an object until some cleanup has finished.
- Prefix delegation: giving each network card blocks of addresses, so a node can hold more pods.
Go deeper
- Kubernetes track: Deployments, Services, Requests, limits and choosing nodes, and When it won't run for Pending pods.
- AWS: EKS Kubernetes versions and support (opens in a new tab), and access entries (opens in a new tab).
- AWS: the EKS Best Practices Guide (opens in a new tab), including the networking chapter on pod addresses and prefix delegation.
- Try: after the first apply, run
python lab.py squeeze, applynode_count=3, then runpython lab.py podsevery 30 seconds and watch the third node join and the Pending count fall. Then runpython lab.py k describe nodeon the new node and find itsAllocatablepods. Undeploy, destroy and rundeletewhen you're done.