Initial commit

This commit is contained in:
2026-07-18 12:00:33 +05:30
commit caac8413e9
83 changed files with 10262 additions and 0 deletions

31
terraform/README.md Normal file
View File

@@ -0,0 +1,31 @@
# 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.

34
terraform/main.tf Normal file
View File

@@ -0,0 +1,34 @@
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0.0"
}
}
}
provider "kubernetes" {
# This tells Terraform how to connect to your k3s cluster.
# Usually it looks for the file in ~/.kube/config.
config_path = "~/.kube/config"
}
# Example: Manage a Kubernetes Namespace using Terraform
resource "kubernetes_namespace" "core" {
metadata {
name = "core"
labels = {
name = "core"
environment = "production"
}
}
}
# Practical: Point Terraform to your updated .yaml files
# Instead of you running 'kubectl apply', Terraform will do it.
resource "kubernetes_manifest" "worker_orders" {
manifest = yamldecode(file("${path.module}/../manifests/core/workers.yaml"))
}
# (Add more resources here for nearle, alaska, etc.)

20
terraform/namespaces.tf Normal file
View File

@@ -0,0 +1,20 @@
# Create namespaces using Terraform
# This makes sure the zones 'core', 'nearle', 'alaska' are always present and correctly labeled.
resource "kubernetes_namespace" "core" {
metadata {
name = "core"
}
}
resource "kubernetes_namespace" "nearle" {
metadata {
name = "nearle"
}
}
resource "kubernetes_namespace" "alaska" {
metadata {
name = "alaska"
}
}

14
terraform/providers.tf Normal file
View File

@@ -0,0 +1,14 @@
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.10.0"
}
}
}
provider "kubernetes" {
# This points to your k3s config file.
# When you get your new server, we will update this to point to the new IP.
config_path = "~/.kube/config"
}

45
terraform/workloads.tf Normal file
View File

@@ -0,0 +1,45 @@
# Manage the Nearle Stack (Jupiter, Atlantis, Fiesta)
# This is the "All-in-one" Terraform control for your major services
# 1. Jupiter Service
resource "kubernetes_manifest" "nearle_jupiter_sts" {
manifest = yamldecode(file("${path.module}/../manifests/nearle/jupiter-sts.yaml"))
}
resource "kubernetes_manifest" "nearle_jupiter_svc" {
manifest = yamldecode(file("${path.module}/../manifests/nearle/jupiter-svc.yaml"))
}
# 2. Atlantis Service
resource "kubernetes_manifest" "nearle_atlantis_sts" {
manifest = yamldecode(file("${path.module}/../manifests/nearle/atlantis-sts.yaml"))
}
resource "kubernetes_manifest" "nearle_atlantis_svc" {
manifest = yamldecode(file("${path.module}/../manifests/nearle/atlantis-svc.yaml"))
}
# 3. Fiesta Service
resource "kubernetes_manifest" "nearle_fiesta_sts" {
manifest = yamldecode(file("${path.module}/../manifests/nearle/fiesta-sts.yaml"))
}
resource "kubernetes_manifest" "nearle_fiesta_svc" {
manifest = yamldecode(file("${path.module}/../manifests/nearle/fiesta-svc.yaml"))
}
# 4. Workers (CPU-heavy isolated nodes)
resource "kubernetes_manifest" "core_workers" {
# This uses your existing workers.yaml file
# Note: Since this file has MANY documents, I recommend splitting it the same way as above.
manifest = yamldecode(file("${path.module}/../manifests/core/workers.yaml"))
}
# 5. Ingress (Unified routing that replaces Docker-side Nginx)
resource "kubernetes_manifest" "core_ingress" {
manifest = yamldecode(file("${path.module}/../manifests/core/ingress-unified.yaml"))
}
resource "kubernetes_manifest" "traefik_middlewares" {
manifest = yamldecode(file("${path.module}/../manifests/core/traefik-middlewares.yaml"))
}