diff --git a/examples/guides/cosmo-local/main.tf b/examples/guides/cosmo-local/main.tf index 4aff631..556acfb 100644 --- a/examples/guides/cosmo-local/main.tf +++ b/examples/guides/cosmo-local/main.tf @@ -24,16 +24,7 @@ module "cosmo_charts" { depends_on = [time_sleep.wait_for_minikube] } -// 4. Create a namespace for the cosmo deployment -resource "kubernetes_namespace" "cosmo_namespace" { - metadata { - name = var.cosmo.chart.namespace - } - - depends_on = [time_sleep.wait_for_minikube] -} - -// 5. Install the cosmo helm release +// 4. Install the cosmo helm release // see var.cosmo.release_name and var.cosmo.chart for more details module "cosmo_release" { source = "../../../modules/charts/release" @@ -44,26 +35,27 @@ module "cosmo_release" { depends_on = [time_sleep.wait_for_minikube] } -// 6. Install the cosmo router helm release +// 5. Install the cosmo router helm release // see local.cosmo_router.release_name and local.cosmo_router.chart for more details // this happens after graphs.tf was applied after the router token was created module "cosmo_router_release" { for_each = var.federated_graphs source = "../../../modules/charts/release" - # chart = local.cosmo_router.chart + chart = { - name = var.cosmo_router.chart.name - version = var.cosmo_router.chart.version - namespace = var.cosmo_router.chart.namespace - repository = var.cosmo_router.chart.repository - values = concat(var.cosmo_router.chart.values, []) - init_values = var.cosmo_router.chart.init_values + name = var.cosmo_router.chart.name + version = var.cosmo_router.chart.version + namespace = var.cosmo_router.chart.namespace + repository = var.cosmo_router.chart.repository + values = concat(var.cosmo_router.chart.values, []) + init_values = var.cosmo_router.chart.init_values + create_namespace = false set = merge({ "configuration.graphApiToken" = module.cosmo_federated_graph[each.key].router_token - "configuration.controlplaneUrl" = "http://cosmo-controlplane.${kubernetes_namespace.cosmo_namespace.metadata[0].name}.svc.cluster.local:3001" - "configuration.cdnUrl" = "http://cosmo-cdn.${kubernetes_namespace.cosmo_namespace.metadata[0].name}.svc.cluster.local:8787" - "configuration.otelCollectorUrl" = "http://cosmo-otelcollector.${kubernetes_namespace.cosmo_namespace.metadata[0].name}.svc.cluster.local:4318" - "configuration.graphqlMetricsCollectorUrl" = "http://cosmo-graphqlmetrics.${kubernetes_namespace.cosmo_namespace.metadata[0].name}.svc.cluster.local:4005" + "configuration.controlplaneUrl" = "http://cosmo-controlplane.${var.cosmo.chart.namespace}.svc.cluster.local:3001" + "configuration.cdnUrl" = "http://cosmo-cdn.${var.cosmo.chart.namespace}.svc.cluster.local:8787" + "configuration.otelCollectorUrl" = "http://cosmo-otelcollector.${var.cosmo.chart.namespace}.svc.cluster.local:4318" + "configuration.graphqlMetricsCollectorUrl" = "http://cosmo-graphqlmetrics.${var.cosmo.chart.namespace}.svc.cluster.local:4005" }, var.cosmo_router.chart.set) } diff --git a/examples/guides/cosmo-local/provider.tf b/examples/guides/cosmo-local/provider.tf index 23682d9..c24b029 100644 --- a/examples/guides/cosmo-local/provider.tf +++ b/examples/guides/cosmo-local/provider.tf @@ -4,10 +4,7 @@ terraform { source = "scott-the-programmer/minikube" version = "0.4.0" } - kubernetes = { - source = "hashicorp/kubernetes" - version = "2.32.0" - } + helm = { source = "hashicorp/helm" version = "2.15.0" @@ -23,13 +20,6 @@ terraform { } } -provider "kubernetes" { - host = module.minikube.host - client_certificate = module.minikube.client_certificate - client_key = module.minikube.client_key - cluster_ca_certificate = module.minikube.cluster_ca_certificate -} - provider "helm" { kubernetes { host = module.minikube.host diff --git a/examples/guides/cosmo-local/variables.tf b/examples/guides/cosmo-local/variables.tf index fbb41a7..6d30ec0 100644 --- a/examples/guides/cosmo-local/variables.tf +++ b/examples/guides/cosmo-local/variables.tf @@ -37,26 +37,28 @@ variable "cosmo" { type = object({ release_name = string chart = object({ - name = string - version = string - namespace = string - repository = string - values = list(string) - init_values = string - set = map(string) + name = string + version = string + namespace = string + repository = string + values = list(string) + init_values = string + set = map(string) + create_namespace = bool }) }) description = "The cosmo chart to deploy" default = { release_name = "cosmo" chart = { - name = "cosmo" - version = "0.11.2" - namespace = "cosmo" - repository = "oci://ghcr.io/wundergraph/cosmo/helm-charts" - values = [] - init_values = "./values/cosmo-values.yaml" - set = {} + name = "cosmo" + version = "0.12.2" + namespace = "cosmo" + repository = "oci://ghcr.io/wundergraph/cosmo/helm-charts" + values = [] + init_values = "./values/cosmo-values.yaml" + set = {} + create_namespace = true } } } @@ -119,4 +121,4 @@ variable "federated_graphs" { name = "spacex" } } -} \ No newline at end of file +} diff --git a/modules/charts/release/chart.tf b/modules/charts/release/chart.tf index b60bd97..82ac851 100644 --- a/modules/charts/release/chart.tf +++ b/modules/charts/release/chart.tf @@ -1,10 +1,11 @@ resource "helm_release" "this" { - name = var.release_name - namespace = var.chart.namespace - repository = var.chart.repository - version = var.chart.version - chart = var.chart.name - values = concat([file(var.chart.init_values)], var.chart.values) + name = var.release_name + namespace = var.chart.namespace + repository = var.chart.repository + version = var.chart.version + chart = var.chart.name + values = concat([file(var.chart.init_values)], var.chart.values) + create_namespace = var.chart.create_namespace wait = true wait_for_jobs = true @@ -20,4 +21,4 @@ resource "helm_release" "this" { value = set.value } } -} \ No newline at end of file +} diff --git a/modules/charts/release/variables.tf b/modules/charts/release/variables.tf index bba70c3..8b1ebb8 100644 --- a/modules/charts/release/variables.tf +++ b/modules/charts/release/variables.tf @@ -1,12 +1,13 @@ variable "chart" { type = object({ - name = string - version = string - namespace = string - repository = string - values = list(string) - init_values = string - set = map(string) + name = string + version = string + namespace = string + repository = string + values = list(string) + init_values = string + set = map(string) + create_namespace = optional(bool) }) default = { name = "cosmo"