From 11708bfcc7cebc4985d81bcf76a77a8252b617b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mu=C3=B1oz?= Date: Thu, 7 Sep 2023 23:26:10 +0200 Subject: [PATCH 1/2] Fix issue terraform scripts not working on windows --- terraform/modules/helm/main.tf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/terraform/modules/helm/main.tf b/terraform/modules/helm/main.tf index 764c5fca..6165d0dd 100644 --- a/terraform/modules/helm/main.tf +++ b/terraform/modules/helm/main.tf @@ -156,6 +156,14 @@ resource "kubectl_manifest" "selfsigned_issuer" { yaml_body = file("${path.module}/clusterissuer-selfsigned.yaml") } +locals { + jsonpatch = jsonencode([{ + "op" = "add", + "path" = "/spec/template/spec/containers/0/args/-", + "value" = "--default-ssl-certificate=keycloak/${var.hostname}-tls" + }]) +} + resource "helm_release" "keycloak" { depends_on = [helm_release.theia-cloud-base, kubectl_manifest.selfsigned_issuer] # we need an existing issuer name = "keycloak" @@ -207,7 +215,7 @@ resource "helm_release" "keycloak" { # Below command connects to the cluster in the local environment and patches the ingress-controller accordingly. # Theia Cloud is then installed with path based hosts reusing the same certificate. provisioner "local-exec" { - command = "kubectl patch deploy ingress-nginx-controller --type='json' -n ingress-nginx -p '[{ \"op\": \"add\", \"path\": \"/spec/template/spec/containers/0/args/-\", \"value\": \"--default-ssl-certificate=keycloak/${var.hostname}-tls\" }]' && kubectl wait pods -n ingress-nginx -l app.kubernetes.io/component=controller --for condition=Ready --timeout=90s && kubectl wait certificate -n keycloak ${var.hostname}-tls --for condition=Ready --timeout=90s" + command = "kubectl patch deploy ingress-nginx-controller --type=json -n ingress-nginx -p ${local.jsonpatch} && kubectl wait pods -n ingress-nginx -l app.kubernetes.io/component=controller --for condition=Ready --timeout=90s && kubectl wait certificate -n keycloak ${var.hostname}-tls --for condition=Ready --timeout=90s" } } From 3f604ec295f3851f59f76aacf46ccad2b669e996 Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Tue, 12 Sep 2023 12:25:12 +0200 Subject: [PATCH 2/2] Fix issue terraform scripts not working on windows Co-authored-by: dmm9 --- terraform/modules/helm/main.tf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/terraform/modules/helm/main.tf b/terraform/modules/helm/main.tf index 6165d0dd..15bc8a51 100644 --- a/terraform/modules/helm/main.tf +++ b/terraform/modules/helm/main.tf @@ -157,6 +157,10 @@ resource "kubectl_manifest" "selfsigned_issuer" { } locals { + # local_exec_quotes is a helper function to deal with different handling of + # quotes between linux and windows. On linux, it will output "'". On windows, + # it will output "". + local_exec_quotes = startswith(abspath(path.module), "/") ? "'" : "" jsonpatch = jsonencode([{ "op" = "add", "path" = "/spec/template/spec/containers/0/args/-", @@ -215,7 +219,7 @@ resource "helm_release" "keycloak" { # Below command connects to the cluster in the local environment and patches the ingress-controller accordingly. # Theia Cloud is then installed with path based hosts reusing the same certificate. provisioner "local-exec" { - command = "kubectl patch deploy ingress-nginx-controller --type=json -n ingress-nginx -p ${local.jsonpatch} && kubectl wait pods -n ingress-nginx -l app.kubernetes.io/component=controller --for condition=Ready --timeout=90s && kubectl wait certificate -n keycloak ${var.hostname}-tls --for condition=Ready --timeout=90s" + command = "kubectl patch deploy ingress-nginx-controller --type=${local.local_exec_quotes}json${local.local_exec_quotes} -n ingress-nginx -p ${local.local_exec_quotes}${local.jsonpatch}${local.local_exec_quotes} && kubectl wait pods -n ingress-nginx -l app.kubernetes.io/component=controller --for condition=Ready --timeout=90s && kubectl wait certificate -n keycloak ${var.hostname}-tls --for condition=Ready --timeout=90s" } }