diff --git a/README.md b/README.md index ce8e99ef8db03a24adde4571fba615063dc364b1..59b6dd53600df7759b757fcf81ab2a9638cd44a8 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ The Helm template uses some global configuration used throughout all jobs. | `HELM_ENV_VALUE_NAME` | The name of the Helm [value](https://helm.sh/docs/chart_best_practices/values/) containing the _environment type_ | `environmentType` | | `HELM_HOSTNAME_VALUE_NAME` | The name of the Helm [value](https://helm.sh/docs/chart_best_practices/values/) containing the _environment hostname_ (extracted from the environment URL) | `hostname` | | `KUBE_NAMESPACE` | The default Kubernetes namespace to use | _none_ but this variable is automatically set by [GitLab Kubernetes integration](https://docs.gitlab.com/ee/user/project/clusters/index.html) when enabled | -| :lock: `HELM_DEFAULT_KUBE_CONFIG` | The default kubeconfig content to use | `$KUBECONFIG` (thus supports the [GitLab Kubernetes integration](https://docs.gitlab.com/ee/user/project/clusters/index.html) when enabled) | +| :lock: `HELM_DEFAULT_KUBE_CONFIG` | The default kubeconfig to use (either content or file variable) | `$KUBECONFIG` (thus supports the [GitLab Kubernetes integration](https://docs.gitlab.com/ee/user/project/clusters/index.html) when enabled) | | `HELM_DEPLOY_ARGS` | The Helm [command with options](https://helm.sh/docs/helm/helm_upgrade/) to deploy the application (_without dynamic arguments such as release name and chart_) | `upgrade --install --atomic --timeout 120s` | | `HELM_DELETE_ARGS` | The Helm [command with options](https://helm.sh/docs/helm/helm_uninstall/) to cleanup the application (_without dynamic arguments such as release name_) | `uninstall` | | `HELM_DEPLOY_CHART` | The Helm [chart](https://helm.sh/docs/topics/charts/) to deploy. _Only required if you want to deploy an **external** chart._ | _none_ | @@ -235,7 +235,7 @@ Here are variables supported to configure review environments: | `HELM_REVIEW_APP_NAME` | Application name for `review` env | `"${HELM_BASE_APP_NAME}-${CI_ENVIRONMENT_SLUG}"` (ex: `myproject-review-fix-bug-12`) | |Â `HELM_REVIEW_ENVIRONMENT_URL`| The review environments url _(only define for static environment URLs declaration and if different from default)_ | `$HELM_ENVIRONMENT_URL` | | `HELM_REVIEW_NAMESPACE` | The Kubernetes namespace to use for `review` env _(only define to override default)_ | `$KUBE_NAMESPACE` | -| :lock: `HELM_REVIEW_KUBE_CONFIG` | kubeconfig content used for `review` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | +| :lock: `HELM_REVIEW_KUBE_CONFIG` | Specific kubeconfig for `review` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | | `HELM_REVIEW_VALUES` | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with `review` environments | _none_ | ### Integration environment configuration @@ -252,7 +252,7 @@ Here are variables supported to configure the integration environment: | `HELM_INTEG_APP_NAME` | Application name for `integration` env | `$HELM_BASE_APP_NAME-integration` | |Â `HELM_INTEG_ENVIRONMENT_URL`| The integration environment url _(only define for static environment URLs declaration and if different from default)_ | `$HELM_ENVIRONMENT_URL` | | `HELM_INTEG_NAMESPACE` | The Kubernetes namespace to use for `integration` env _(only define to override default)_ | `$KUBE_NAMESPACE` | -| :lock: `HELM_INTEG_KUBE_CONFIG` | kubeconfig content used for `integration` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | +| :lock: `HELM_INTEG_KUBE_CONFIG` | Specific kubeconfig for `integration` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | | `HELM_INTEG_VALUES` | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the `integration` environment | _none_ | ### Staging environment configuration @@ -269,7 +269,7 @@ Here are variables supported to configure the staging environment: | `HELM_STAGING_APP_NAME` | Application name for `staging` env | `$HELM_BASE_APP_NAME-staging` | |Â `HELM_STAGING_ENVIRONMENT_URL`| The staging environment url _(only define for static environment URLs declaration and if different from default)_ | `$HELM_ENVIRONMENT_URL` | | `HELM_STAGING_NAMESPACE` | The Kubernetes namespace to use for `staging` env _(only define to override default)_ | `$KUBE_NAMESPACE` | -| :lock: `HELM_STAGING_KUBE_CONFIG` | kubeconfig content used for `staging` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | +| :lock: `HELM_STAGING_KUBE_CONFIG` | Specific kubeconfig for `staging` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | | `HELM_STAGING_VALUES` | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the staging environment | _none_ | ### Production environment configuration @@ -286,7 +286,7 @@ Here are variables supported to configure the production environment: | `HELM_PROD_APP_NAME` | Application name for `production` env | `$HELM_BASE_APP_NAME` | |Â `HELM_PROD_ENVIRONMENT_URL`| The production environment url _(only define for static environment URLs declaration and if different from default)_ | `$HELM_ENVIRONMENT_URL` | | `HELM_PROD_NAMESPACE` | The Kubernetes namespace to use for `production` env _(only define to override default)_ | `$KUBE_NAMESPACE` | -| :lock: `HELM_PROD_KUBE_CONFIG` | kubeconfig content used for `production` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | +| :lock: `HELM_PROD_KUBE_CONFIG` | Specific kubeconfig for `production` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | | `AUTODEPLOY_TO_PROD` | Set this variable to auto-deploy to production. If not set deployment to production will be `manual` (default behaviour). | _none_ (disabled) | | `HELM_PROD_VALUES` | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the production environment | _none_ | diff --git a/kicker.json b/kicker.json index 5cf9b9b842e94828445a02d51a4d88d6e0aedd17..d9cd4ea73feb53d4ca191c95d6144fb664fb29a2 100644 --- a/kicker.json +++ b/kicker.json @@ -255,7 +255,7 @@ }, { "name": "HELM_REVIEW_KUBE_CONFIG", - "description": "kubeconfig content used for review env (only define to override default)", + "description": "Specific kubeconfig for review env (only define to override default)", "default": "$HELM_DEFAULT_KUBE_CONFIG", "advanced": true, "secret": true @@ -292,7 +292,7 @@ }, { "name": "HELM_INTEG_KUBE_CONFIG", - "description": "kubeconfig content used for integration env (only define to override default)", + "description": "Specific kubeconfig for integration env (only define to override default)", "default": "$HELM_DEFAULT_KUBE_CONFIG", "advanced": true, "secret": true @@ -329,7 +329,7 @@ }, { "name": "HELM_STAGING_KUBE_CONFIG", - "description": "kubeconfig content used for staging env (only define to override default)", + "description": "Specific kubeconfig for staging env (only define to override default)", "default": "$HELM_DEFAULT_KUBE_CONFIG", "advanced": true, "secret": true @@ -371,7 +371,7 @@ }, { "name": "HELM_PROD_KUBE_CONFIG", - "description": "kubeconfig content used for production env (only define to override default)", + "description": "Specific kubeconfig for production env (only define to override default)", "default": "$HELM_DEFAULT_KUBE_CONFIG", "advanced": true, "secret": true diff --git a/templates/gitlab-ci-helm.yml b/templates/gitlab-ci-helm.yml index 6b6a143c6516568c156ae6d28e3fc5921f6f5222..b80798b13d4ba6736c7b3836f051e58de2b7c92c 100644 --- a/templates/gitlab-ci-helm.yml +++ b/templates/gitlab-ci-helm.yml @@ -324,11 +324,20 @@ stages: } function setup_kubeconfig() { - if [ -n "$1" ]; then + if [[ -f "$1" ]] + then + # arg1 is a path to a Kuberconfig file + export KUBECONFIG="$CI_PROJECT_DIR/.kubeconfig" + cp -f "$1" "$KUBECONFIG" + log_info "--- using \\e[32mKUBECONFIG\\e[0m provided by env variables" + elif [[ -n "$1" ]] + then + # arg1 is a Kuberconfig file content export KUBECONFIG="$CI_PROJECT_DIR/.kubeconfig" echo "$1" > "$KUBECONFIG" log_info "--- using \\e[32mKUBECONFIG\\e[0m provided by env variables" - elif [ -n "$KUBECONFIG" ]; then + elif [[ -n "$KUBECONFIG" ]] + then log_info "--- using \\e[32mKUBECONFIG\\e[0m provided by GitLab" else log_warn "No \\e[32mKUBECONFIG\\e[0m configuration found!"