Kubernetes Cluster Provisioning
DevOps IaC Part 2 β Day 9
Declaratively provision local multi-node Kind clusters (and AWS EKS alternative) using Terraform HCL
On Day 9, you will progress from single containers to enterprise container orchestration. Rather than paying for an AWS EKS or GCP GKE control plane, today you will declaratively provision a multi-node Kubernetes cluster directly inside Docker using Kind (Kubernetes in Docker) managed entirely via Terraform HCL. You will configure node roles (control-plane and multiple worker nodes), export cluster credentials, and audit node readiness using kubectl.
An interactive 20 min video walkthrough for Day 9 is currently in production. Follow the step-by-step interactive playbook below!
The official reference codebase for Day 9 is hosted in the repository. Clone the repository and navigate to day-9-kind-cluster to run the working solution.
git clone https://github.com/777abhi/devops-terraform-roadmap.git
cd devops-terraform-roadmap/day-9-kind-clusterArchitecture: Kind Docker-in-Docker vs Cloud EKS
Understand how Kind creates real containerized Kubernetes nodes and when to use it in testing pipelines.
Examine the cluster architecture where each Kubernetes node runs as an isolated Docker container with containerd inside.
Local Kind Multi-Node Architecture: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Host Machine (macOS / Linux / Windows WSL2) β β ββ Docker Daemon β β ββ [Container 1] kind-control-plane (API, etcd, sched)β β ββ [Container 2] kind-worker-1 (kubelet, containerd) β β ββ [Container 3] kind-worker-2 (kubelet, containerd) β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β’ 100% Zero Cost: Boots in ~45 seconds, zero cloud billing. β’ True Kubernetes API: 100% compliant with standard kubectl & Helm.
HCL Manifest Authoring: Kind Provider
Define provider requirements, cluster parameters, and multi-node topology in main.tf.
Instruct Terraform to download the community Kind provider from HashiCorp Registry.
# versions.tf
terraform {
required_version = ">= 1.5.0"
required_providers {
kind = {
source = "tehcyx/kind"
version = "~> 0.5.0"
}
}
}Provision a cluster named 'devops-lab-cluster' with 1 control plane node and 2 worker nodes.
# main.tf
provider "kind" {}
resource "kind_cluster" "devops_cluster" {
name = "devops-lab-cluster"
wait_for_ready = true
kind_config {
kind = "Cluster"
api_version = "kind.x-k8s.io/v1alpha4"
node {
role = "control-plane"
extra_port_mappings {
container_port = 80
host_port = 8080
listen_address = "127.0.0.1"
}
}
node {
role = "worker"
labels = {
tier = "frontend"
}
}
node {
role = "worker"
labels = {
tier = "backend"
}
}
}
}
output "cluster_name" {
value = kind_cluster.devops_cluster.name
description = "The provisioned Kind cluster identifier"
}
output "client_certificate" {
value = kind_cluster.devops_cluster.client_certificate
sensitive = true
}Cluster Execution & Node Readiness Verification
Execute terraform apply, verify kubeconfig creation, and query node status.
Initialize the Kind provider and apply the HCL cluster definition.
cd /Users/abhinavsharma/Downloads/devops-terraform-roadmap/day-9-kind-cluster
terraform init
terraform apply -auto-approveVerify that all 3 nodes transition to the 'Ready' state.
kubectl cluster-info --context kind-devops-lab-cluster
kubectl get nodes -L tier -o wideProduction EKS Blueprint & Quality Gates
Examine production AWS EKS HCL architecture and resource cleanups.
In production cloud environments, replace kind_cluster with HashiCorp's official aws_eks_cluster and managed node groups:
# Production AWS EKS Snippet
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
cluster_name = "prod-enterprise-cluster"
cluster_version = "1.30"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
eks_managed_node_groups = {
primary = {
instance_types = ["t3.medium"]
min_size = 2
max_size = 5
desired_size = 2
}
}
}- Understood Docker-in-Docker Kubernetes topology vs managed cloud control planes.
- Configured the tehcyx/kind provider and declared a 3-node cluster in HCL.
- Defined worker node labels (tier=frontend, tier=backend) for pod scheduling.
- Applied the configuration and validated node readiness via kubectl get nodes.
- Analyzed production AWS EKS Terraform module patterns for real-world transitions.