Commit 029fb9cb authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: add $k8s_namespace ctx variables

parent eb6aafe4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ that you might use in your hook scripts, deployment manifests and other deployme
* `${environment_name}`: a generated application name to use for the current deployment environment (ex: `myproject-review-fix-bug-12` or `myproject-staging`) - _details below_
* `${environment_name_ssc}`: the above application name in [SCREAMING_SNAKE_CASE](https://en.wikipedia.org/wiki/Snake_case) format
    (ex: `MYPROJECT_REVIEW_FIX_BUG_12` or `MYPROJECT_STAGING`)
* `${k8s_namespace}`: the Kubernetes namespace currently used for deployment/cleanup

#### Generated environment name

@@ -242,6 +243,7 @@ by using available environment variables:
    * `${environment_name}`: the application name to use for the current environment (ex: `myproject-review-fix-bug-12` or `myproject-staging`)
    * `${environment_name_ssc}`: the application name in [SCREAMING_SNAKE_CASE](https://en.wikipedia.org/wiki/Snake_case) format
       (ex: `MYPROJECT_REVIEW_FIX_BUG_12` or `MYPROJECT_STAGING`)
    * `${k8s_namespace}`: the Kubernetes namespace currently used for deployment/cleanup
    * `${hostname}`: the environment hostname, extracted from the current environment url (after late variable expansion - see below)
2. any [GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)
3. any [custom variable](https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project)
+4 −1
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ stages:
  }

  function k8s_login() {
    k8s_namespace=${ENV_SPACE:-$K8S_SPACE}
    export k8s_namespace=${ENV_SPACE:-$K8S_SPACE}
    k8s_config=${ENV_KUBE_CONFIG:-${K8S_DEFAULT_KUBE_CONFIG}}

    if [[ -f "$k8s_config" ]]
@@ -358,6 +358,9 @@ stages:

    kubectl config set-context --current --namespace="$k8s_namespace"

    log_info "--- \\e[32mlogin\\e[0m"
    log_info "--- \$k8s_namespace: \\e[33;1m${k8s_namespace}\\e[0m"

    # finally test connection and dump versions
    kubectl ${TRACE+-v=5} version
  }