Learning objectives
- Separate system, fault-tolerant application, and stateful capacity.
- Use labels to attract intended pods and taints to repel unintended pods.
- Read scaling, AMI, update, repair, and replacement behavior from a plan.
Four groups across three private-subnet AZs
This is the production intent, not an AWS guarantee of one node per AZ. Capacity, Kubernetes topology spread, and disruption policy complete the design.
Placement matrix
| Group | Capacity | Labels and taints | Why |
|---|---|---|---|
| system | On-Demand | workload=systemdedicated=system:NO_SCHEDULE | Envoy, Argo CD, and platform agents need stable EC2 features. |
| application_on_demand | On-Demand | workload=applicationlifecycle=on-demand | Baseline capacity for fault-intolerant services. |
| application_spot | Spot, three instance types | lifecycle=spot:NO_SCHEDULE | Interruptible workers opt in with a toleration. |
| Cassandra | On-Demand | workload=cassandradedicated=cassandra:NO_SCHEDULE | StatefulSets and EBS-backed data avoid Spot interruption. |
Lab: compare learning and production
# Provider-mocked tests create no AWS resources.
terraform -chdir=learn-terraform/capstone/infra/modules/eks test
tofu -chdir=learn-terraform/capstone/infra/modules/eks test
# Inspect both profiles before any plan.
terraform fmt -check learn-terraform/capstone/infra/environments/learning/eks.tfvars
terraform fmt -check learn-terraform/capstone/infra/environments/production/eks.tfvars
tofu fmt -check learn-terraform/capstone/infra/environments/learning/eks.tfvars
tofu fmt -check learn-terraform/capstone/infra/environments/production/eks.tfvarsLearning keeps paid capacity small and Cassandra at zero desired nodes. Production makes a three-node floor visible for every group; applying it is outside this chapter.
Read update behavior
version = var.kubernetes_versionmakes every managed group follow the reviewed control-plane minor version instead of relying on the provider default.ami_type = AL2023_x86_64_STANDARDmakes the OS family reviewable and enables drift detection for that choice.release_version = nulllets EKS choose the latest compatible AMI only when the group is created. Terraform does not discover later recommended AMI releases while that input stays null. Set a reviewed release_version value in the selected tfvars, inspect the in-place node-group update, and roll it out during a maintenance window.- Capacity type, subnet set, node role, and launch choices can replace a node group. Treat replacement as a migration.
max_unavailable = 1bounds a rolling update, but PodDisruptionBudgets still decide whether eviction succeeds.node_repair_config.enabled = truelets EKS replace unhealthy nodes; it does not repair application data.- Spot uses multiple instance types to widen capacity pools. Design for interruption rather than assuming replacement arrives first.
- Terraform owns desired size in this phase. Chapter 16 will define autoscaler ownership without permanent plan drift.
Failure drill
Verify the contract
terraform -chdir=learn-terraform/capstone/infra/modules/eks test -filter=tests/eks.tftest.hcl
tofu -chdir=learn-terraform/capstone/infra/modules/eks test -filter=tests/eks.tftest.hclThe assertions require four groups, private subnets, On-Demand system and Cassandra capacity, separate Spot application capacity, stable labels and taints, node repair, and bounded updates.
Cleanup
No resources were created. Remove only temporary plans and copied working directories. After a future apply, drain workloads and remove dependent GitOps state before deleting a node group.
Quick check
Does a label stop other pods from using the node?
No. A label attracts selected pods; a taint repels pods that lack a matching toleration.
Does three desired nodes guarantee one per AZ?
No. The group spans three subnets, but placement can be uneven. Topology spread and workload replicas complete availability.
Recap and next
Managed groups turn resilience and cost choices into reviewable HCL: stable system capacity, two application lifecycles, and isolated Cassandra capacity.
Next: add Fargate for a narrow class of stateless worker pods while keeping system and stateful workloads on EC2.