|
| 1 | +# dev environment — local kind cluster + agentrax stack |
| 2 | +# This is the primary target for local development, integration testing, and CI. |
| 3 | +# State is stored in a local backend file (terraform.tfstate) — not shared. |
| 4 | + |
| 5 | +terraform { |
| 6 | + required_version = ">= 1.6" |
| 7 | + |
| 8 | + # Local backend — intentional for dev. Do not check in terraform.tfstate. |
| 9 | + backend "local" {} |
| 10 | + |
| 11 | + required_providers { |
| 12 | + kind = { |
| 13 | + source = "tehcyx/kind" |
| 14 | + version = "~> 0.6" |
| 15 | + } |
| 16 | + helm = { |
| 17 | + source = "hashicorp/helm" |
| 18 | + version = "~> 2.14" |
| 19 | + } |
| 20 | + kubernetes = { |
| 21 | + source = "hashicorp/kubernetes" |
| 22 | + version = "~> 2.31" |
| 23 | + } |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +# --------------------------------------------------------------------------- |
| 28 | +# Step 1: Provision the kind cluster |
| 29 | +# --------------------------------------------------------------------------- |
| 30 | +module "kind_cluster" { |
| 31 | + source = "../../modules/kind_cluster" |
| 32 | + cluster_name = var.cluster_name |
| 33 | +} |
| 34 | + |
| 35 | +# --------------------------------------------------------------------------- |
| 36 | +# Step 2: Configure the Helm and Kubernetes providers to target the new cluster. |
| 37 | +# Both providers read credentials from the kind_cluster module outputs so no |
| 38 | +# local kubeconfig file needs to exist before `terraform apply`. |
| 39 | +# --------------------------------------------------------------------------- |
| 40 | +provider "helm" { |
| 41 | + kubernetes { |
| 42 | + host = module.kind_cluster.endpoint |
| 43 | + client_certificate = module.kind_cluster.client_certificate |
| 44 | + client_key = module.kind_cluster.client_key |
| 45 | + cluster_ca_certificate = module.kind_cluster.cluster_ca_certificate |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +provider "kubernetes" { |
| 50 | + host = module.kind_cluster.endpoint |
| 51 | + client_certificate = module.kind_cluster.client_certificate |
| 52 | + client_key = module.kind_cluster.client_key |
| 53 | + cluster_ca_certificate = module.kind_cluster.cluster_ca_certificate |
| 54 | +} |
| 55 | + |
| 56 | +# --------------------------------------------------------------------------- |
| 57 | +# Step 3: Install cert-manager → kube-prometheus-stack → agentrax |
| 58 | +# --------------------------------------------------------------------------- |
| 59 | +module "agentrax_stack" { |
| 60 | + source = "../../modules/agentrax_stack" |
| 61 | + |
| 62 | + cert_manager_version = var.cert_manager_version |
| 63 | + prometheus_stack_version = var.prometheus_stack_version |
| 64 | + agentrax_chart_path = var.agentrax_chart_path |
| 65 | + agentrax_leader_elect = var.agentrax_leader_elect |
| 66 | + agentrax_extra_values = var.agentrax_extra_values |
| 67 | + |
| 68 | + # The stack module requires the cluster to exist first. |
| 69 | + # Provider-level dependency is enforced via the shared kubeconfig above. |
| 70 | +} |
0 commit comments