32 lines
1.2 KiB
Markdown
32 lines
1.2 KiB
Markdown
# 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/kubernetes` provider.
|
|
- **Resources:** It manages your Namespaces, Workers, and Services.
|
|
|
|
## 2. How to run it:
|
|
1. **Install Terraform:** Download and install the Terraform CLI on your computer.
|
|
2. **Initialize the project:**
|
|
```bash
|
|
terraform init
|
|
```
|
|
3. **Check for changes:** (The "Safety Preview")
|
|
```bash
|
|
terraform plan
|
|
```
|
|
4. **Apply the changes:** (This actually updates the cluster)
|
|
```bash
|
|
terraform apply
|
|
```
|
|
|
|
## 3. Why this is good for your boss:
|
|
- **Reproducibility:** If you get a new server, run `terraform apply` and 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 `.tf` code 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.
|