From b069f42c4062e6a4af2ae3d91f226f01630dc9f6 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Sat, 11 Sep 2021 21:27:02 +0000 Subject: [PATCH 1/9] update main.tf, replace remote_chart with enabled, remove helm_remote_deployment --- main.tf | 66 +++++++++++++++++++-------------------------------------- 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/main.tf b/main.tf index 9bce723..1043f5a 100644 --- a/main.tf +++ b/main.tf @@ -1,50 +1,44 @@ locals { required_values = { - ## Deployment endpoint for ingress + # Deployment endpoint for ingress deployment_endpoint = "${lower(var.deployment_endpoint)}" - - ## for backend.tf and also release name - deployment_name = "${lower(var.deployment_name)}" - - ## for global environment variables takes map() - env_vars = "${trimspace(join("\n", data.template_file.env_vars.*.rendered))}" + # for backend.tf and also release name + deployment_name = "${lower(var.deployment_name)}" + # for global environment variables takes map() + env_vars = "${trimspace(join("\n", data.template_file.env_vars.*.rendered))}" } - - ## When all requred values all deffined then also will incloude users values + # When all requred values all deffined then also will incloude users values template_all_values = "${merge(local.required_values, var.template_custom_vars)}" - - timeout = "${var.timeout}" - recreate_pods = "${var.recreate_pods}" + timeout = "${var.timeout}" + recreate_pods = "${var.recreate_pods}" } -## template_file.env_vars just converting to right values +# template_file.env_vars just converting to right values data "template_file" "env_vars" { count = "${length(keys(var.env_vars))}" template = " $${key}: \"$${value}\"" - vars { key = "${element(keys(var.env_vars), count.index)}" value = "${element(values(var.env_vars), count.index)}" } } -## template_file.chart_values_template actual values.yaml file from charts +# template_file.chart_values_template actual values.yaml file from charts data "template_file" "chart_values_template" { - count = "${var.remote_chart == "true" ? 0 : 1 }" - template = "${file("charts/${var.deployment_path}/values.yaml")}" - - vars = "${local.template_all_values}" + count = "${var.enabled == "true" ? 1 : 0 }" + template = "${file("${var.deployment_path}/values.yaml")}" + vars = "${local.template_all_values}" } -## This resource was disabled and moved to output please see the ticket -## https://github.com/fuchicorp/terraform-helm-chart/issues/21 +# This resource was disabled and moved to output please see the ticket +# https://github.com/fuchicorp/terraform-helm-chart/issues/21 # resource "local_file" "deployment_values" { -# content = "${trimspace(data.template_file.chart_values_template.rendered)}" +# content = "${trimspace(data.template_file.chart_values_template.0.rendered)}" # filename = "${path.module}/${var.deployment_name}-values.yaml" # } output "deployment_values" { - value = "${data.template_file.chart_values_template.0.rendered}" + value = "${data.template_file.chart_values_template.*.rendered}" description = "This output is for storing values.yaml" } @@ -52,32 +46,16 @@ locals { trigger = "${var.trigger == "UUID" ? uuid() : var.trigger}" } -## helm_release.helm_deployment is actual helm deployment +# helm_release.helm_deployment is actual helm deployment resource "helm_release" "helm_deployment" { - count = "${var.remote_chart == "true" ? 0 : 1 }" - name = "${var.deployment_name}-${var.deployment_environment}" - namespace = "${var.deployment_environment}" - chart = "./charts/${var.deployment_path}" - timeout = "${local.timeout}" - recreate_pods = "${local.recreate_pods}" - version = "${var.release_version}" - - values = [ - "${trimspace(data.template_file.chart_values_template.rendered)}", - ] -} - -## helm_release.helm_deployment is actual helm deployment -resource "helm_release" "helm_remote_deployment" { - count = "${var.remote_chart == "true" ? 1 : 0 }" + count = "${var.enabled == "true" ? 1 : 0}" name = "${var.deployment_name}-${var.deployment_environment}" namespace = "${var.deployment_environment}" chart = "${var.deployment_path}" timeout = "${local.timeout}" recreate_pods = "${local.recreate_pods}" version = "${var.release_version}" - values = [ - "${file("${var.values}")}" + values = [ + "${trimspace(data.template_file.chart_values_template.rendered)}", ] - -} +} \ No newline at end of file From ab6841ff13a0cc0bd132a9b0e4b1c943d5cdb4f4 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Sat, 11 Sep 2021 21:28:08 +0000 Subject: [PATCH 2/9] update variables.tf, replace variable remote_chart to enabled --- variables.tf | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/variables.tf b/variables.tf index b9215c7..3804404 100644 --- a/variables.tf +++ b/variables.tf @@ -1,19 +1,19 @@ -## The name of the deployment +# The name of the deployment variable "deployment_name" { description = "The name of the deployment" } -## The name of the environment +# The name of the environment variable "deployment_environment" { description = "The name of the environment" } -## Chart location or chart name +# Chart location or chart name variable "deployment_path" { description = "Chart location or chart name " } -## Endpoint for the application +# Endpoint for the application variable "deployment_endpoint" { description = "Endpoint for the application" } @@ -39,18 +39,16 @@ variable "timeout" { variable "recreate_pods" { default = false } - variable "release_version" { - description = "(Required) Specify the exact chart version to install" - default = " 0.1.0" - - } +variable "release_version" { + default = " 0.1.0" + description = "(Required) Specify the exact chart version to install" +} + +variable "enabled" { + default = "false" +} - variable "remote_chart" { - default = "false" - } - variable "values" { - default = "values.yaml" - } - \ No newline at end of file + default = "values.yaml" +} \ No newline at end of file From 2f78b0ba802e8d72aaf4339d22fae47720a0f573 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Sat, 11 Sep 2021 21:29:00 +0000 Subject: [PATCH 3/9] update README.md, replace remote_chart to enabled, update description --- README.md | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 5ab996b..808946b 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ This terraform module will help you deploy the helm charts on local. - [Custom Values](#custom-variable-deployment) - - ## Requirements Terraform >= 0.11.7 @@ -68,21 +66,18 @@ output "success" { ``` -follow the file path - +follow the file path: ```yaml ./module.tf ./output.tf ./charts/ - /example ## Your chart location - /Chart.yaml - /charts - /templates - /values.yaml + /example ## Your chart location + /Chart.yaml + /charts + /templates + /values.yaml ``` - - ## Variables For more info, please see the [variables file](variables.tf). @@ -94,7 +89,7 @@ For more info, please see the [variables file](variables.tf). | `deployment_endpoint` | Ingress endpoint `example.fuchicorp.com` | `(Required)` | `domain/string` | | `deployment_path` | path for helm chart on local | `(Required)` | `string` | | `release_version` | Specify the exact chart version to install. | `(Required)` | `string` | -| `remote_chart` | Specify if you want to deploy the remote chart to `"True"` default value is `"False"`| `(Optional)` | `bool` | +| `enabled` | Specify if you want to deploy the enabled to `"true"` default value is `"false"`| `(Optional)` | `bool` | | `values` | Name of the values.yaml file | `(Optional)` | `string` | | `template_custom_vars` | Template custom veriables you can modify variables by parsting the `template_custom_vars` | `(Optional)` | `map` | | `env_vars` | Environment veriable for the containers takes map | `(Optional)` | `map` | @@ -108,15 +103,14 @@ For more info, please see the [variables file](variables.tf). ``` module "helm_deploy" { # source = "git::https://github.com/fuchicorp/helm-deploy.git" - source = "fuchicorp/chart/helm" + source = "fuchicorp/chart/helm" deployment_name = "artemis-deployment" deployment_environment = "dev" deployment_endpoint = "artemis.fuchicorp.com" deployment_path = "artemis" release_version = "0.0.4" - - - template_custom_vars = { + enabled = "true" + template_custom_vars = { deployment_image = "nginx" } } @@ -161,13 +155,13 @@ Please follow the steps to configure `module.tf` and `output.tf` ``` module "helm_remote_deployment" { source = "fuchicorp/chart/helm" - deployment_name = "example-deployment" ## The name of the deployment - deployment_environment = "dev" ## Name of the namespace - deployment_endpoint = "example.fuchicorp.com" ## Ingress endpoint - deployment_path = "stable/jenkins" ## Path for helm chart - release_version = "0.0.4" ## Chart version - remote_chart = "true" - values = "values.yaml" ## your values.yaml file + deployment_name = "example-deployment" # The name of the deployment + deployment_environment = "dev" # Name of the namespace + deployment_endpoint = "example.fuchicorp.com" # Ingress endpoint + deployment_path = "stable/jenkins" # Path for helm chart + release_version = "0.0.4" # Chart version + enabled = "true" # Deploy resource + values = "values.yaml" # your values.yaml file } ``` Next create an simple output file named `output.tf` and copy and paste the following: From cc384ce751628a22affdf51beffb29b04c56e779 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Mon, 13 Sep 2021 23:46:12 +0000 Subject: [PATCH 4/9] set enabled default to true --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 3804404..b0fecf8 100644 --- a/variables.tf +++ b/variables.tf @@ -46,7 +46,7 @@ variable "release_version" { } variable "enabled" { - default = "false" + default = "true" } variable "values" { From 7310bf3e1cc14ab74d91bcfd9a6d0e0e19489a55 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Mon, 13 Sep 2021 23:47:00 +0000 Subject: [PATCH 5/9] update README.md, set enabled to true and false in documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 808946b..d2678d2 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ For more info, please see the [variables file](variables.tf). | `deployment_endpoint` | Ingress endpoint `example.fuchicorp.com` | `(Required)` | `domain/string` | | `deployment_path` | path for helm chart on local | `(Required)` | `string` | | `release_version` | Specify the exact chart version to install. | `(Required)` | `string` | -| `enabled` | Specify if you want to deploy the enabled to `"true"` default value is `"false"`| `(Optional)` | `bool` | +| `enabled` | Specify if you want to deploy the enabled to `"true"` or `"false"` default value is `"true"`| `(Optional)` | `bool` | | `values` | Name of the values.yaml file | `(Optional)` | `string` | | `template_custom_vars` | Template custom veriables you can modify variables by parsting the `template_custom_vars` | `(Optional)` | `map` | | `env_vars` | Environment veriable for the containers takes map | `(Optional)` | `map` | From bcf3d32f3302f4bc69ba0c71cfc6a873eddc9c1e Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Tue, 14 Sep 2021 01:26:06 +0000 Subject: [PATCH 6/9] update wording --- variables.tf | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/variables.tf b/variables.tf index b0fecf8..d9d053f 100644 --- a/variables.tf +++ b/variables.tf @@ -19,36 +19,37 @@ variable "deployment_endpoint" { } variable "template_custom_vars" { - type = "map" - default = {} + type = "map" + default = {} } variable "env_vars" { - type = "map" - default = {} + type = "map" + default = {} } variable "trigger" { - default = "UUID" + default = "UUID" } variable "timeout" { - default = "400" + default = "400" } variable "recreate_pods" { - default = false + default = false } variable "release_version" { - default = " 0.1.0" description = "(Required) Specify the exact chart version to install" + default = " 0.1.0" + } variable "enabled" { - default = "true" + default = "true" } variable "values" { - default = "values.yaml" -} \ No newline at end of file + default = "values.yaml" +} \ No newline at end of file From ccdead24f0e733111983f6aaed6d58fee456aa8b Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Tue, 14 Sep 2021 01:32:21 +0000 Subject: [PATCH 7/9] remove whitespaces --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d2678d2..91d51fe 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ module "helm_deploy" { deployment_endpoint = "example.fuchicorp.com" deployment_path = "example" release_version = "0.0.4" - } EOF ``` @@ -169,7 +168,6 @@ Next create an simple output file named `output.tf` and copy and paste the follo output "success" { value = "${module.helm_remote_deployment.success_output}" } - ``` Developed by FuchiCorp DevOps team, Enjoy using it. From 27705bcbc8ad54bae49455a892636a63640def10 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Wed, 15 Sep 2021 23:59:38 +0000 Subject: [PATCH 8/9] update readme.md --- README.md | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 91d51fe..9029273 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ module "helm_deploy" { deployment_name = "example-deployment" deployment_environment = "dev" deployment_endpoint = "example.fuchicorp.com" - deployment_path = "example" + deployment_path = "./charts/example" + enabled = "true" release_version = "0.0.4" } EOF @@ -106,7 +107,7 @@ module "helm_deploy" { deployment_name = "artemis-deployment" deployment_environment = "dev" deployment_endpoint = "artemis.fuchicorp.com" - deployment_path = "artemis" + deployment_path = "./charts/artemis" release_version = "0.0.4" enabled = "true" template_custom_vars = { @@ -151,23 +152,5 @@ Please follow the steps to configure `module.tf` and `output.tf` ./values.yaml ``` `module.tf` file should look like this -``` -module "helm_remote_deployment" { - source = "fuchicorp/chart/helm" - deployment_name = "example-deployment" # The name of the deployment - deployment_environment = "dev" # Name of the namespace - deployment_endpoint = "example.fuchicorp.com" # Ingress endpoint - deployment_path = "stable/jenkins" # Path for helm chart - release_version = "0.0.4" # Chart version - enabled = "true" # Deploy resource - values = "values.yaml" # your values.yaml file -} -``` -Next create an simple output file named `output.tf` and copy and paste the following: -``` -output "success" { - value = "${module.helm_remote_deployment.success_output}" -} -``` Developed by FuchiCorp DevOps team, Enjoy using it. From 76dd4199e0c1bbe94d3f8f10d4bf59e7ca7d45f6 Mon Sep 17 00:00:00 2001 From: Mike <15527358+devdot4@users.noreply.github.com> Date: Thu, 16 Sep 2021 00:02:46 +0000 Subject: [PATCH 9/9] remove remote chart --- README.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/README.md b/README.md index 9029273..41910b8 100644 --- a/README.md +++ b/README.md @@ -136,21 +136,4 @@ Output file will be: You can see the `repository` replaced to the right value -## If you would like to deploy remote chart - -REMOTE CHARTS are available on versions `"0.0.4"` and up. - -In order to deploy remote charts, you should have your own `values.yaml` file, - -`module.tf` and `output.tf` in the same folder. - -Please follow the steps to configure `module.tf` and `output.tf` - -```yaml -./module.tf -./output.tf -./values.yaml -``` -`module.tf` file should look like this - Developed by FuchiCorp DevOps team, Enjoy using it.