HomeRoadmapsTerraform Day 9
Kubernetes & GitOps Track Β· Day 9 Β· 20 min

Kubernetes Cluster Provisioning
DevOps IaC Part 2 β€” Day 9

Declaratively provision local multi-node Kind clusters (and AWS EKS alternative) using Terraform HCL

πŸ› οΈ Tooling: Terraform 1.5+, Kind CLI & Docker Engine🎭 Role: Kubernetes & Cloud Infrastructure Quality Architect
KubernetesKindCluster ProvisioningMulti-NodeEKS ArchitectureIaC
About Today's 20-Minute Lab

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.

🎬
Day 9 Video Walkthrough: Declarative Multi-Node Kubernetes Provisioning with TerraformComing Soon

An interactive 20 min video walkthrough for Day 9 is currently in production. Follow the step-by-step interactive playbook below!

πŸ“¦Sample Codebase & Working Solution (Day 9)Available Now
View on GitHub

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 β€” Working Solution
git clone https://github.com/777abhi/devops-terraform-roadmap.git
cd devops-terraform-roadmap/day-9-kind-cluster
1

Architecture: Kind Docker-in-Docker vs Cloud EKS

Understand how Kind creates real containerized Kubernetes nodes and when to use it in testing pipelines.

Cluster Topology: 1 Control Plane + 2 Workers

Examine the cluster architecture where each Kubernetes node runs as an isolated Docker container with containerd inside.

cluster-topology-architecture.txt
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.
2

HCL Manifest Authoring: Kind Provider

Define provider requirements, cluster parameters, and multi-node topology in main.tf.

Declare tehcyx/kind Provider in versions.tf

Instruct Terraform to download the community Kind provider from HashiCorp Registry.

HCL β€” versions.tf
# versions.tf
terraform {
  required_version = ">= 1.5.0"
  required_providers {
    kind = {
      source  = "tehcyx/kind"
      version = "~> 0.5.0"
    }
  }
}
Define Multi-Node Cluster in main.tf

Provision a cluster named 'devops-lab-cluster' with 1 control plane node and 2 worker nodes.

HCL β€” main.tf
# 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
}
3

Cluster Execution & Node Readiness Verification

Execute terraform apply, verify kubeconfig creation, and query node status.

Provision the Cluster

Initialize the Kind provider and apply the HCL cluster definition.

Terminal β€” Provision Kind Cluster
cd /Users/abhinavsharma/Downloads/devops-terraform-roadmap/day-9-kind-cluster
terraform init
terraform apply -auto-approve
Audit Cluster Nodes with kubectl

Verify that all 3 nodes transition to the 'Ready' state.

Terminal β€” Inspect K8s Nodes
kubectl cluster-info --context kind-devops-lab-cluster
kubectl get nodes -L tier -o wide
4

Production EKS Blueprint & Quality Gates

Examine production AWS EKS HCL architecture and resource cleanups.

🏭AWS EKS Production Blueprint Alternative

In production cloud environments, replace kind_cluster with HashiCorp's official aws_eks_cluster and managed node groups:

HCL β€” AWS EKS Module Production Blueprint
# 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
    }
  }
}
Day 9 Quality Gate & Outcomes Checklist
  • 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.