From 281688b09b533c9e7a65ed8173dc595001e7e7c9 Mon Sep 17 00:00:00 2001 From: Filippo Date: Fri, 16 May 2025 15:35:08 +0200 Subject: [PATCH 1/2] feat: add gitlab_agent_enabled_deploy variable to control whether GitLab Agent components are deployed --- CHANGELOG.md | 7 +++++++ README.md | 3 ++- main.tf | 1 + variables.tf | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e047862..f07e8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.10.0] - 2025-05-16 + +[Compare with previous version](https://github.com/sparkfabrik/terraform-gitlab-kubernetes-gitlab-agent/compare/0.9.0...0.10.0) + +### Added + +- Add the `gitlab_agent_enabled_deploy` variable to control whether to deploy the GitLab Agent components. When set to false, the module only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself. - Upgrade terraform docs docker image using renovate. ## [0.9.0] - 2024-11-13 diff --git a/README.md b/README.md index 4e3a879..22b25ca 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ provider "gitlab" { | [gitlab\_agent\_commmit\_message](#input\_gitlab\_agent\_commmit\_message) | The commit message to use when committing the Gitlab Agent configuration file. You can use the placeholder `{{gitlab_agent_name}}` to reference the Gitlab Agent name. | `string` | `"[CI] Add agent config file for {{gitlab_agent_name}}"` | no | | [gitlab\_agent\_create\_variables\_in\_root\_namespace](#input\_gitlab\_agent\_create\_variables\_in\_root\_namespace) | Create two Gitlab CI/CD variables in the root namespace useful to configure the Kubernetes context and use the Gitlab Agent. These variables are created in the root namespace of the project defined in `gitlab_project_path_with_namespace`, which is the project that hosts the Gitlab Agent configuration. | `bool` | `true` | no | | [gitlab\_agent\_custom\_config\_file\_content](#input\_gitlab\_agent\_custom\_config\_file\_content) | The content of the Gitlab Agent configuration file. If not provided and `gitlab_agent_grant_access_to_entire_root_namespace` is true, the default configuration file will be used and the root namespace will be granted access to the Gitlab Agent. If you set this variable, it takes precedence over `gitlab_agent_grant_access_to_entire_root_namespace`. | `string` | `""` | no | +| [gitlab\_agent\_enabled\_deploy](#input\_gitlab\_agent\_enabled\_deploy) | Whether to deploy the GitLab Agent components. If false, only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself. | `bool` | `true` | no | | [gitlab\_agent\_grant\_access\_to\_entire\_root\_namespace](#input\_gitlab\_agent\_grant\_access\_to\_entire\_root\_namespace) | Grant access to the entire root namespace. If false, you can provide a custom configuration file content using the variable `gitlab_agent_custom_config_file_content`. Otherwise, you will have to manually manage the access to the Gitlab Agent committing the proper configuration to the Gitlab project. | `bool` | `true` | no | | [gitlab\_agent\_grant\_user\_access\_to\_root\_namespace](#input\_gitlab\_agent\_grant\_user\_access\_to\_root\_namespace) | Grant `user_access` to the root namespace. | `bool` | `false` | no | | [gitlab\_agent\_name](#input\_gitlab\_agent\_name) | The name of the Gitlab Agent. | `string` | n/a | yes | @@ -67,7 +68,7 @@ provider "gitlab" { | [gitlab\_project\_name](#input\_gitlab\_project\_name) | The name of the Gitlab project that hosts the Gitlab Agent configuration. If not provided, the module will use the project defined in `gitlab_project_path_with_namespace`. | `string` | `""` | no | | [gitlab\_project\_path\_with\_namespace](#input\_gitlab\_project\_path\_with\_namespace) | The path with namespace of the Gitlab project that hosts the Gitlab Agent configuration. The project must be created in Gitlab before running this module. The configured Gitlab provider must have write access to the project. | `string` | n/a | yes | | [helm\_additional\_values](#input\_helm\_additional\_values) | Additional values to be passed to the Helm chart. | `list(string)` | `[]` | no | -| [helm\_chart\_version](#input\_helm\_chart\_version) | The version of the gitlab-agent Helm chart. You can see the available versions at https://gitlab.com/gitlab-org/charts/gitlab-agent/-/tags, or using the command `helm search repo gitlab/gitlab-agent -l` after adding the Gitlab Helm repository. | `string` | `"2.11.0"` | no | +| [helm\_chart\_version](#input\_helm\_chart\_version) | The version of the gitlab-agent Helm chart. You can see the available versions at https://gitlab.com/gitlab-org/charts/gitlab-agent/-/tags, or using the command `helm search repo gitlab/gitlab-agent -l` after adding the Gitlab Helm repository. | `string` | `"2.13.0"` | no | | [helm\_release\_name](#input\_helm\_release\_name) | The name of the Helm release. | `string` | `"gitlab-agent"` | no | | [k8s\_additional\_labels](#input\_k8s\_additional\_labels) | Additional labels to apply to the kubernetes resources. | `map(string)` | `{}` | no | | [k8s\_default\_labels](#input\_k8s\_default\_labels) | Labels to apply to the kubernetes resources. These are opinionated labels, you can add more labels using the variable `additional_k8s_labels`. If you want to remove a label, you can override it with an empty map(string). | `map(string)` |
{
"managed-by": "terraform",
"scope": "gitlab-agent"
}
| no | diff --git a/main.tf b/main.tf index cc7987e..ba90037 100644 --- a/main.tf +++ b/main.tf @@ -129,6 +129,7 @@ resource "kubernetes_secret_v1" "gitlab_agent_token_secret" { # Helm release resource "helm_release" "this" { + count = var.gitlab_agent_enabled_deploy ? 1 : 0 name = var.helm_release_name repository = local.helm_chart_url chart = local.helm_chart_name diff --git a/variables.tf b/variables.tf index 2bae4e3..7fb30c2 100644 --- a/variables.tf +++ b/variables.tf @@ -3,6 +3,11 @@ variable "gitlab_project_name" { type = string default = "" } +variable "gitlab_agent_enabled_deploy" { + description = "Whether to deploy the GitLab Agent components. If false, only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself." + type = bool + default = true +} variable "gitlab_project_path_with_namespace" { description = "The path with namespace of the Gitlab project that hosts the Gitlab Agent configuration. The project must be created in Gitlab before running this module. The configured Gitlab provider must have write access to the project." From 1faabda8afaa094ea370121c3d49c4fe877e1fe3 Mon Sep 17 00:00:00 2001 From: Andrea Panisson Date: Fri, 16 May 2025 18:01:19 +0200 Subject: [PATCH 2/2] Rename variable --- CHANGELOG.md | 2 +- README.md | 2 +- main.tf | 2 +- variables.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f07e8f1..c14c0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added -- Add the `gitlab_agent_enabled_deploy` variable to control whether to deploy the GitLab Agent components. When set to false, the module only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself. +- Add the `gitlab_agent_deploy_enabled` variable to control whether to deploy the GitLab Agent components. When set to false, the module only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself. - Upgrade terraform docs docker image using renovate. ## [0.9.0] - 2024-11-13 diff --git a/README.md b/README.md index 22b25ca..f355923 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ provider "gitlab" { | [gitlab\_agent\_commmit\_message](#input\_gitlab\_agent\_commmit\_message) | The commit message to use when committing the Gitlab Agent configuration file. You can use the placeholder `{{gitlab_agent_name}}` to reference the Gitlab Agent name. | `string` | `"[CI] Add agent config file for {{gitlab_agent_name}}"` | no | | [gitlab\_agent\_create\_variables\_in\_root\_namespace](#input\_gitlab\_agent\_create\_variables\_in\_root\_namespace) | Create two Gitlab CI/CD variables in the root namespace useful to configure the Kubernetes context and use the Gitlab Agent. These variables are created in the root namespace of the project defined in `gitlab_project_path_with_namespace`, which is the project that hosts the Gitlab Agent configuration. | `bool` | `true` | no | | [gitlab\_agent\_custom\_config\_file\_content](#input\_gitlab\_agent\_custom\_config\_file\_content) | The content of the Gitlab Agent configuration file. If not provided and `gitlab_agent_grant_access_to_entire_root_namespace` is true, the default configuration file will be used and the root namespace will be granted access to the Gitlab Agent. If you set this variable, it takes precedence over `gitlab_agent_grant_access_to_entire_root_namespace`. | `string` | `""` | no | -| [gitlab\_agent\_enabled\_deploy](#input\_gitlab\_agent\_enabled\_deploy) | Whether to deploy the GitLab Agent components. If false, only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself. | `bool` | `true` | no | +| [gitlab\_agent\_enabled\_deploy](#input\_gitlab\_agent\_enabled\_deploy) | Whether to deploy the GitLab Agent components. If false, only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself. | `bool` | `true` | no | | [gitlab\_agent\_grant\_access\_to\_entire\_root\_namespace](#input\_gitlab\_agent\_grant\_access\_to\_entire\_root\_namespace) | Grant access to the entire root namespace. If false, you can provide a custom configuration file content using the variable `gitlab_agent_custom_config_file_content`. Otherwise, you will have to manually manage the access to the Gitlab Agent committing the proper configuration to the Gitlab project. | `bool` | `true` | no | | [gitlab\_agent\_grant\_user\_access\_to\_root\_namespace](#input\_gitlab\_agent\_grant\_user\_access\_to\_root\_namespace) | Grant `user_access` to the root namespace. | `bool` | `false` | no | | [gitlab\_agent\_name](#input\_gitlab\_agent\_name) | The name of the Gitlab Agent. | `string` | n/a | yes | diff --git a/main.tf b/main.tf index ba90037..b0566a2 100644 --- a/main.tf +++ b/main.tf @@ -129,7 +129,7 @@ resource "kubernetes_secret_v1" "gitlab_agent_token_secret" { # Helm release resource "helm_release" "this" { - count = var.gitlab_agent_enabled_deploy ? 1 : 0 + count = var.gitlab_agent_deploy_enabled ? 1 : 0 name = var.helm_release_name repository = local.helm_chart_url chart = local.helm_chart_name diff --git a/variables.tf b/variables.tf index 7fb30c2..3a2799b 100644 --- a/variables.tf +++ b/variables.tf @@ -3,7 +3,7 @@ variable "gitlab_project_name" { type = string default = "" } -variable "gitlab_agent_enabled_deploy" { +variable "gitlab_agent_deploy_enabled" { description = "Whether to deploy the GitLab Agent components. If false, only creates the GitLab Agent token, Kubernetes namespace and secret without deploying the agent itself." type = bool default = true