IT 3300 : Virtualization

Infrastructure as Code

The pattern you've seen all semester

  • Proxmox cloud-init, Compose files, Kubernetes manifests, Helm values
  • Common thread: describe desired state in a file, apply it
  • Infrastructure as Code (IaC) applies that to the infrastructure itself

Why IaC

  • Reproducible — rebuild identical environments on demand
  • Versioned — infra changes reviewed in git, like code
  • Auditable — the file is the source of truth
  • Disposable — tear down and recreate without fear

Terraform / OpenTofu

  • Declarative, multi-cloud provisioning
  • OpenTofu is the open-source fork of Terraform (same language)
  • You declare resources; the tool creates/updates/deletes to match

A Terraform sketch

resource "google_container_cluster" "demo" {
  name               = "demo"
  location           = "us-central1"
  initial_node_count = 3
}

The workflow

    terraform init      # download providers
    terraform plan      # preview the changes
    terraform apply     # make it real
    terraform destroy   # tear it all down
  • plan before apply — see exactly what will change

State

  • Terraform tracks what it created in a state file
  • State maps your config to real-world resources
  • Store it remotely and lock it when working in a team

Declarative vs. imperative

  • Imperative — "run these steps" (a bash script)
  • Declarative — "here's the end state" (Terraform, k8s)
  • Declarative tools reconcile reality to your description — and can
    detect and fix drift

The whole course, one idea

Proxmox VMs  +  Docker images  +  k8s manifests  +  IaC
    = your entire stack, defined in files, in git, reproducible.

Lab goals

  • Use Terraform/OpenTofu to provision something small (a VM or a cluster)
  • Change the config and apply; observe the delta in plan
  • destroy it and confirm everything is gone