Skip to content

Deploy.latest.gitlab-ci.yml does not read KUBE_CONTEXT

Summary

If you see the following error in your deploy logs, when it attempts to create the namespace

...
+ kubectl create namespace 25562320-review-jsandlin-m-yiz45k
The connection to the server localhost:8080 was refused - did you specify the right host or port?
...

but you know you have the required vars setup

...
  KUBE_CONTEXT: "sandlin/gke-deploy-env:gitlab-agent"
  KUBE_INGRESS_BASE_DOMAIN: 'papanca.com'
  CI_KUBERNETES_ACTIVE: 'true'
  KUBE_NAMESPACE: "${CI_PROJECT_ID}-${CI_ENVIRONMENT_SLUG}"
...

then make certain you are using Deploy.gitlab-ci.yml and NOT Deploy.latest.gitlab-ci.yml

...
include:
  ...
  # BAD
  # - template: Jobs/Deploy.latest.gitlab-ci.yml  # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.latest.gitlab-ci.yml
  # GOOD
  - template: Jobs/Deploy.gitlab-ci.yml  # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
...

Steps to reproduce

  1. use new k8s agent
...
include:
  ...
  # BAD
  - template: Jobs/Deploy.latest.gitlab-ci.yml  # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.latest.gitlab-ci.yml
  # GOOD
  # - template: Jobs/Deploy.gitlab-ci.yml  # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
...

Example Project

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Possible fixes