Terraform Infrastructure as Code (IaC)
This directory contains the "Recipe Book" for your k3s environment.
1. What's here?
Instead of manually running kubectl apply, you use Terraform to manage your entire cluster.
- Provider: It uses the standard
hashicorp/kubernetesprovider. - Resources: It manages your Namespaces, Workers, and Services.
2. How to run it:
- Install Terraform: Download and install the Terraform CLI on your computer.
- Initialize the project:
terraform init - Check for changes: (The "Safety Preview")
terraform plan - Apply the changes: (This actually updates the cluster)
terraform apply
3. Why this is good for your boss:
- Reproducibility: If you get a new server, run
terraform applyand the whole setup is recreated in seconds. - Versioning: You can see every change ever made to your cluster.
- No drifting: Terraform ensures that what's in your
.tfcode is EXACTLY what's running in your cluster.
4. Next Step:
We can add a BigRock Provider (if available) or a generic SSH/Shell provider to even automate the creation of the VPS itself.