From b61a905de6355ebad6767fcda47f23c3b7fe7776 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:02:44 +0200 Subject: [PATCH 01/15] Use autocluster only when there's a license --- ...rties.tmpl => axonserver.properties.tftpl} | 6 ++-- configmap.tf | 32 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) rename conf/{axonserver.properties.tmpl => axonserver.properties.tftpl} (85%) diff --git a/conf/axonserver.properties.tmpl b/conf/axonserver.properties.tftpl similarity index 85% rename from conf/axonserver.properties.tmpl rename to conf/axonserver.properties.tftpl index df5c72c..8221ac7 100644 --- a/conf/axonserver.properties.tmpl +++ b/conf/axonserver.properties.tftpl @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -#axoniq.axonserver.autocluster.first=${first_name}.${namespace}.svc.cluster.local -#axoniq.axonserver.autocluster.contexts=_admin,default +%{ if var.console_authentication = "" } +axoniq.axonserver.autocluster.first=${first_name}.${namespace}.svc.cluster.local +axoniq.axonserver.autocluster.contexts=_admin,default +%{ endif } axoniq.axonserver.enterprise.licenseDirectory=./license diff --git a/configmap.tf b/configmap.tf index a0d38a8..f1f6d06 100755 --- a/configmap.tf +++ b/configmap.tf @@ -1,14 +1,14 @@ -data "template_file" "axonserver_properties" { - template = file("${path.module}/conf/axonserver.properties.tmpl") - - vars = { - first_name = "${var.cluster_name}-1" - public_domain = var.public_domain - namespace = kubernetes_namespace.as_demo.id - internal_token = random_uuid.internal_token.result - devmode_enabled = var.devmode_enabled - } -} +#data "template_file" "axonserver_properties" { +# template = file("${path.module}/conf/axonserver.properties.tmpl") +# +# vars = { +# first_name = "${var.cluster_name}-1" +# public_domain = var.public_domain +# namespace = kubernetes_namespace.as_demo.id +# internal_token = random_uuid.internal_token.result +# devmode_enabled = var.devmode_enabled +# } +#} resource "kubernetes_config_map" "axonserver_properties" { metadata { @@ -17,6 +17,14 @@ resource "kubernetes_config_map" "axonserver_properties" { } data = { - "axonserver.properties" = data.template_file.axonserver_properties.rendered + "axonserver.properties" = templatefile( + "${path.module}/conf/axonserver.properties.tftpl", + { + first_name = "${var.cluster_name}-1", + public_domain = var.public_domain, + namespace = kubernetes_namespace.as_demo.id, + internal_token = random_uuid.internal_token.result, + devmode_enabled = var.devmode_enabled + }) } } From 677ced631fec878ff350dd8d2d647bcca16a66ea Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:05:52 +0200 Subject: [PATCH 02/15] Fixed a typo --- conf/axonserver.properties.tftpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/axonserver.properties.tftpl b/conf/axonserver.properties.tftpl index 8221ac7..1ff3c28 100644 --- a/conf/axonserver.properties.tftpl +++ b/conf/axonserver.properties.tftpl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -%{ if var.console_authentication = "" } +%{ if var.console_authentication == "" } axoniq.axonserver.autocluster.first=${first_name}.${namespace}.svc.cluster.local axoniq.axonserver.autocluster.contexts=_admin,default %{ endif } From d8153a6f36fb8e039bfa54f6c2e3e1847b4e2a08 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:14:11 +0200 Subject: [PATCH 03/15] Using a different approach --- conf/axonserver.properties.tftpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/axonserver.properties.tftpl b/conf/axonserver.properties.tftpl index 1ff3c28..262afbc 100644 --- a/conf/axonserver.properties.tftpl +++ b/conf/axonserver.properties.tftpl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -%{ if var.console_authentication == "" } +%{ if length(var.console_authentication) == 0 } axoniq.axonserver.autocluster.first=${first_name}.${namespace}.svc.cluster.local axoniq.axonserver.autocluster.contexts=_admin,default %{ endif } From 67a0b246d95a8094cc645b608d825a6265705299 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:19:05 +0200 Subject: [PATCH 04/15] Fixing the variables to render --- configmap.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configmap.tf b/configmap.tf index f1f6d06..c1c74b3 100755 --- a/configmap.tf +++ b/configmap.tf @@ -20,11 +20,11 @@ resource "kubernetes_config_map" "axonserver_properties" { "axonserver.properties" = templatefile( "${path.module}/conf/axonserver.properties.tftpl", { - first_name = "${var.cluster_name}-1", - public_domain = var.public_domain, - namespace = kubernetes_namespace.as_demo.id, - internal_token = random_uuid.internal_token.result, - devmode_enabled = var.devmode_enabled + "first_name" = "${var.cluster_name}-1", + "public_domain" = var.public_domain, + "namespace" = kubernetes_namespace.as_demo.id, + "internal_token" = random_uuid.internal_token.result, + "devmode_enabled" = var.devmode_enabled }) } } From e79346b0c556aec4a4a732adee9ee635159a1ca3 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:31:26 +0200 Subject: [PATCH 05/15] Using a different approach --- configmap.tf | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/configmap.tf b/configmap.tf index c1c74b3..190b395 100755 --- a/configmap.tf +++ b/configmap.tf @@ -10,6 +10,16 @@ # } #} +locals { + properties = templatefile("${path.module}/conf/axonserver.properties.tftpl", { + first_name = "${var.cluster_name}-1" + public_domain = var.public_domain + namespace = kubernetes_namespace.as_demo.id + internal_token = random_uuid.internal_token.result + devmode_enabled = var.devmode_enabled + }) +} + resource "kubernetes_config_map" "axonserver_properties" { metadata { name = "axonserver.properties" @@ -17,14 +27,6 @@ resource "kubernetes_config_map" "axonserver_properties" { } data = { - "axonserver.properties" = templatefile( - "${path.module}/conf/axonserver.properties.tftpl", - { - "first_name" = "${var.cluster_name}-1", - "public_domain" = var.public_domain, - "namespace" = kubernetes_namespace.as_demo.id, - "internal_token" = random_uuid.internal_token.result, - "devmode_enabled" = var.devmode_enabled - }) + "axonserver.properties" = local.properties } } From 1285364889106406cc30c896fe12a74fb5bd50f1 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:39:27 +0200 Subject: [PATCH 06/15] Fixing the variables to render --- configmap.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configmap.tf b/configmap.tf index 190b395..fed8ee1 100755 --- a/configmap.tf +++ b/configmap.tf @@ -27,6 +27,6 @@ resource "kubernetes_config_map" "axonserver_properties" { } data = { - "axonserver.properties" = local.properties + "axonserver.properties" = "${file(local.properties)}" } } From f20e85a7c6de5581c469f8ba703379f610403599 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:45:34 +0200 Subject: [PATCH 07/15] Fixing the variables to render --- configmap.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configmap.tf b/configmap.tf index fed8ee1..7188939 100755 --- a/configmap.tf +++ b/configmap.tf @@ -12,11 +12,11 @@ locals { properties = templatefile("${path.module}/conf/axonserver.properties.tftpl", { - first_name = "${var.cluster_name}-1" - public_domain = var.public_domain + first_name = "$${var.cluster_name}-1" + public_domain = "$${var.public_domain}" namespace = kubernetes_namespace.as_demo.id internal_token = random_uuid.internal_token.result - devmode_enabled = var.devmode_enabled + devmode_enabled = "$${var.devmode_enabled}" }) } From 1e5b6d86e541790c64c404b32e01eb634439303c Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:46:26 +0200 Subject: [PATCH 08/15] Fixing the variables to render --- configmap.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configmap.tf b/configmap.tf index 7188939..66429ac 100755 --- a/configmap.tf +++ b/configmap.tf @@ -14,8 +14,8 @@ locals { properties = templatefile("${path.module}/conf/axonserver.properties.tftpl", { first_name = "$${var.cluster_name}-1" public_domain = "$${var.public_domain}" - namespace = kubernetes_namespace.as_demo.id - internal_token = random_uuid.internal_token.result + namespace = "${kubernetes_namespace.as_demo.id}" + internal_token = "${random_uuid.internal_token.result}" devmode_enabled = "$${var.devmode_enabled}" }) } From 45f6b8314c5136e6e4f62f132ada6c7531d6cc86 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:46:55 +0200 Subject: [PATCH 09/15] Fixing the variables to render --- configmap.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configmap.tf b/configmap.tf index 66429ac..7b26822 100755 --- a/configmap.tf +++ b/configmap.tf @@ -12,11 +12,11 @@ locals { properties = templatefile("${path.module}/conf/axonserver.properties.tftpl", { - first_name = "$${var.cluster_name}-1" - public_domain = "$${var.public_domain}" + first_name = "${var.cluster_name}-1" + public_domain = "${var.public_domain}" namespace = "${kubernetes_namespace.as_demo.id}" internal_token = "${random_uuid.internal_token.result}" - devmode_enabled = "$${var.devmode_enabled}" + devmode_enabled = "${var.devmode_enabled}" }) } From 0e5e432d47dd1a640c9110900948ad5bad8620a1 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:51:23 +0200 Subject: [PATCH 10/15] Using a different approach --- configmap.tf | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/configmap.tf b/configmap.tf index 7b26822..17da7c0 100755 --- a/configmap.tf +++ b/configmap.tf @@ -11,13 +11,11 @@ #} locals { - properties = templatefile("${path.module}/conf/axonserver.properties.tftpl", { - first_name = "${var.cluster_name}-1" - public_domain = "${var.public_domain}" - namespace = "${kubernetes_namespace.as_demo.id}" - internal_token = "${random_uuid.internal_token.result}" - devmode_enabled = "${var.devmode_enabled}" - }) + first_name = "${var.cluster_name}-1" + public_domain = var.public_domain + namespace = kubernetes_namespace.as_demo.id + internal_token = random_uuid.internal_token.result + devmode_enabled = var.devmode_enabled } resource "kubernetes_config_map" "axonserver_properties" { @@ -27,6 +25,12 @@ resource "kubernetes_config_map" "axonserver_properties" { } data = { - "axonserver.properties" = "${file(local.properties)}" + "axonserver.properties" = templatefile("${path.module}/conf/axonserver.properties.tftpl", { + first_name = local.first_name, + public_domain = local.public_domain, + namespace = local.namespace, + internal_token = local.internal_token, + devmode_enabled = local.devmode_enabled + }) } } From 76ad64b7fa2cef7fee393c6a3ad328b6e6e11642 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:56:45 +0200 Subject: [PATCH 11/15] Move the templatefile migration to another issue --- configmap.tf | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/configmap.tf b/configmap.tf index 17da7c0..a0d38a8 100755 --- a/configmap.tf +++ b/configmap.tf @@ -1,21 +1,13 @@ -#data "template_file" "axonserver_properties" { -# template = file("${path.module}/conf/axonserver.properties.tmpl") -# -# vars = { -# first_name = "${var.cluster_name}-1" -# public_domain = var.public_domain -# namespace = kubernetes_namespace.as_demo.id -# internal_token = random_uuid.internal_token.result -# devmode_enabled = var.devmode_enabled -# } -#} +data "template_file" "axonserver_properties" { + template = file("${path.module}/conf/axonserver.properties.tmpl") -locals { - first_name = "${var.cluster_name}-1" - public_domain = var.public_domain - namespace = kubernetes_namespace.as_demo.id - internal_token = random_uuid.internal_token.result - devmode_enabled = var.devmode_enabled + vars = { + first_name = "${var.cluster_name}-1" + public_domain = var.public_domain + namespace = kubernetes_namespace.as_demo.id + internal_token = random_uuid.internal_token.result + devmode_enabled = var.devmode_enabled + } } resource "kubernetes_config_map" "axonserver_properties" { @@ -25,12 +17,6 @@ resource "kubernetes_config_map" "axonserver_properties" { } data = { - "axonserver.properties" = templatefile("${path.module}/conf/axonserver.properties.tftpl", { - first_name = local.first_name, - public_domain = local.public_domain, - namespace = local.namespace, - internal_token = local.internal_token, - devmode_enabled = local.devmode_enabled - }) + "axonserver.properties" = data.template_file.axonserver_properties.rendered } } From 3eca438d44ceb696c0cf01bc789f48c3604147f4 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 16:58:03 +0200 Subject: [PATCH 12/15] Template file name changed as described by TF docs --- configmap.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configmap.tf b/configmap.tf index a0d38a8..09da824 100755 --- a/configmap.tf +++ b/configmap.tf @@ -1,5 +1,5 @@ data "template_file" "axonserver_properties" { - template = file("${path.module}/conf/axonserver.properties.tmpl") + template = file("${path.module}/conf/axonserver.properties.tftpl") vars = { first_name = "${var.cluster_name}-1" From 7f7ef9001a572a39f97b90cd491ec730c8211b62 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Fri, 19 Jul 2024 17:00:48 +0200 Subject: [PATCH 13/15] Fixed the variable name for console auth --- conf/axonserver.properties.tftpl | 2 +- configmap.tf | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conf/axonserver.properties.tftpl b/conf/axonserver.properties.tftpl index 262afbc..9d88a2e 100644 --- a/conf/axonserver.properties.tftpl +++ b/conf/axonserver.properties.tftpl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -%{ if length(var.console_authentication) == 0 } +%{ if ${console_authentication} == "" } axoniq.axonserver.autocluster.first=${first_name}.${namespace}.svc.cluster.local axoniq.axonserver.autocluster.contexts=_admin,default %{ endif } diff --git a/configmap.tf b/configmap.tf index 09da824..caa6222 100755 --- a/configmap.tf +++ b/configmap.tf @@ -2,11 +2,12 @@ data "template_file" "axonserver_properties" { template = file("${path.module}/conf/axonserver.properties.tftpl") vars = { - first_name = "${var.cluster_name}-1" - public_domain = var.public_domain - namespace = kubernetes_namespace.as_demo.id - internal_token = random_uuid.internal_token.result - devmode_enabled = var.devmode_enabled + first_name = "${var.cluster_name}-1" + public_domain = var.public_domain + namespace = kubernetes_namespace.as_demo.id + internal_token = random_uuid.internal_token.result + devmode_enabled = var.devmode_enabled + console_authentication = var.console_authentication } } From 86b54032920cc6371bc373d86b0b19cf025330bb Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Mon, 12 Aug 2024 18:04:47 +0200 Subject: [PATCH 14/15] Added an if for the license --- conf/axonserver.properties.tftpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/axonserver.properties.tftpl b/conf/axonserver.properties.tftpl index 9d88a2e..f656771 100644 --- a/conf/axonserver.properties.tftpl +++ b/conf/axonserver.properties.tftpl @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -%{ if ${console_authentication} == "" } +%{ if console_authentication == "" } axoniq.axonserver.autocluster.first=${first_name}.${namespace}.svc.cluster.local axoniq.axonserver.autocluster.contexts=_admin,default -%{ endif } axoniq.axonserver.enterprise.licenseDirectory=./license +%{ endif } axoniq.axonserver.domain=${public_domain} axoniq.axonserver.internal-domain=${namespace}.svc.cluster.local From fe24afe4fa6a0b55d03623670d39b7e8c7d68781 Mon Sep 17 00:00:00 2001 From: Francesco Latini Date: Wed, 28 Aug 2024 14:56:34 +0200 Subject: [PATCH 15/15] Using TF module v1.11 on the example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2a7217..e4e986b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ```terraform module "as_demo" { - source = "git@github.com:AxonIQ/terraform-axonserver-k8s.git?ref=v1.10" + source = "git@github.com:AxonIQ/terraform-axonserver-k8s.git?ref=v1.11" axonserver_release = "2024.1.1" java_version = "17"