Skip to content
Snippets Groups Projects
Commit e9003369 authored by Pierre SMEYERS's avatar Pierre SMEYERS
Browse files

Merge branch '2-fix-set-env' into 'master'

fix: add an option to avoid var conflict name

Closes #2

See merge request to-be-continuous/helm!3
parents bb60beac b6e98a70
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,9 @@ The Helm template uses some global configuration used throughout all jobs.
| --------------------- | -------------------------------------- | ----------------- |
| `HELM_CLI_IMAGE` | The Docker image used to run Helm | `alpine/helm:latest` - **it is highly recommended to set the CLI version compatible with your Kubernetes server** |
| `HELM_CHART_DIR` | The folder in which is stored the Helm chart | `.` |
| `HELM_ENV_VALUE_NAME` | The environment type variable set to helm | `env` |
| `HELM_HOSTNAME_VALUE_NAME` | The hostname variable set to helm | `hostname` |
### Secrets management
......@@ -194,8 +197,8 @@ In order to be able to implement some **genericity** in your scripts and templat
1. you should use generic [values](https://helm.sh/docs/chart_best_practices/values/) dynamically set and passed by the template:
* `env`: the environment type (`review`, `integration`, `staging` or `production`)
* `hostname`: the environment hostname, extracted from `${CI_ENVIRONMENT_URL}` (got from [`environment:url`](https://docs.gitlab.com/ee/ci/yaml/#environmenturl) - see `OS_REVIEW_ENVIRONMENT_SCHEME`, `OS_REVIEW_ENVIRONMENT_DOMAIN`, `OS_STAGING_ENVIRONMENT_URL` and `OS_PROD_ENVIRONMENT_URL`)
* `$HELM_ENV_VALUE_NAME` (set by default to `env`): the environment type (`review`, `integration`, `staging` or `production`)
* `$HELM_HOSTNAME_VALUE_NAME` (set by default to `hostname`): the environment hostname, extracted from `${CI_ENVIRONMENT_URL}` (got from [`environment:url`](https://docs.gitlab.com/ee/ci/yaml/#environmenturl) - see `OS_REVIEW_ENVIRONMENT_SCHEME`, `OS_REVIEW_ENVIRONMENT_DOMAIN`, `OS_STAGING_ENVIRONMENT_URL` and `OS_PROD_ENVIRONMENT_URL`)
2. you should use available environment variables:
......
......@@ -56,6 +56,18 @@
"description": "The Helm [command with options](https://helm.sh/docs/helm/helm_dependency_update/) to update on-disk the chart dependencies (_without dynamic arguments such as the chart path_)",
"default": "dependency update",
"advanced": true
},
{
"name": "HELM_ENV_VALUE_NAME",
"description": "The environment type variable set to helm",
"default": "env",
"advanced": true
},
{
"name": "HELM_HOSTNAME_VALUE_NAME",
"description": "The hostname variable set to helm",
"default": "hostname",
"advanced": true
}
],
"features": [
......
......@@ -33,6 +33,9 @@ variables:
HELM_REPOS: "stable@https://charts.helm.sh/stable bitnami@https://charts.bitnami.com/bitnami"
HELM_ENV_VALUE_NAME: env
HELM_HOSTNAME_VALUE_NAME: hostname
# Will work with gitlab Kubernetes integration (per env variables)
# KUBE_NAMESPACE: "default"
# KUBECONFIG: ""
......@@ -373,8 +376,9 @@ stages:
fi
log_info "--- using \\e[32mpackage\\e[0m: \\e[33;1m${package}\\e[0m"
# shellcheck disable=SC2086
helm ${TRACE+--debug} $helm_opts $helm_namespace_opt $helm_values_opt --set "env=$env,hostname=$hostname" $HELM_DEPLOY_ARGS $appname $package
helm ${TRACE+--debug} $helm_opts $helm_namespace_opt $helm_values_opt --set "${HELM_ENV_VALUE_NAME}=$env,${HELM_HOSTNAME_VALUE_NAME}=$hostname" $HELM_DEPLOY_ARGS $appname $package
# finally persist environment url
echo "$CI_ENVIRONMENT_URL" > environment_url.txt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment