Skip to content

Commit

Permalink
chore: remove unneeded extra provider
Browse files Browse the repository at this point in the history
the kubernetes provider might fail on building the rest client for k8s
under various circumstances e.g. hashicorp/terraform-provider-kubernetes#1391
  • Loading branch information
AndreasZeissner committed Oct 14, 2024
1 parent 09b0c23 commit 26fc81b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 62 deletions.
36 changes: 14 additions & 22 deletions examples/guides/cosmo-local/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}

Expand Down
12 changes: 1 addition & 11 deletions examples/guides/cosmo-local/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
32 changes: 17 additions & 15 deletions examples/guides/cosmo-local/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -119,4 +121,4 @@ variable "federated_graphs" {
name = "spacex"
}
}
}
}
15 changes: 8 additions & 7 deletions modules/charts/release/chart.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,4 +21,4 @@ resource "helm_release" "this" {
value = set.value
}
}
}
}
15 changes: 8 additions & 7 deletions modules/charts/release/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 26fc81b

Please sign in to comment.