A CORPOLEARN SPECIALIST SCHOOL

Compiling a clear engineering solution

1 min read

Kubernetes & Terraform: Infrastructure as Code & Container Orchestration Guide

Published:
article_source.md — DEV ACADEMY IDE
✓ VERIFIED SPEC

Declarative Infrastructure as Code (IaC) ensures repeatable deployments and seamless cloud environment promotion across staging and production.

Terraform Kubernetes Deployment Module

resource "kubernetes_deployment" "api_gateway" {
  metadata {
    name = "api-gateway-deployment"
    labels = {
      app = "api-gateway"
    }
  }

  spec {
    replicas = 3

    selector {
      match_labels = {
        app = "api-gateway"
      }
    }

    template {
      metadata {
        labels = {
          app = "api-gateway"
        }
      }

      spec {
        container {
          image = "myregistry.io/api-gateway:v1.2.0"
          name  = "gateway"

          resources {
            limits = {
              cpu    = "500m"
              memory = "512Mi"
            }
            requests = {
              cpu    = "250m"
              memory = "256Mi"
            }
          }
        }
      }
    }
  }
}