I’m trying to re-export KUBECONFIG
as KUBE_CONFIG_PATH
. My issue is that adding
variables:
KUBE_CONFIG_PATH: $KUBECONFIG
to my .gitlab-ci.yml
results in KUBE_CONFIG_PATH
being set to the contents of the kube config file instead of the path. I’ve double-checked, and KUBECONFIG
is the path to the kube config file, not the contents.
What I expected to happen is that KUBE_CONFIG_PATH
would be set to the path of the kube config file.
If I create a variable in the GUI I can set it’s type to “file” to save the value to a file and set the variable to the file’s path (GitLab CI/CD variables | GitLab). This seems like what KUBECONFIG
is doing behind the scenes. It doesn’t seem like this is possible when defining a variable in .gitlab-ci.yml
however.
For context I am using Gitlab.com, I have integrated a k8s cluster with my project, and I’m running Terraform as a deploy job.
A dummy .gitlab-ci.yml
script that replicates my issue is:
stages:
- test
test:
stage: test
image: alpine:3.7
environment:
name: staging
variables:
KUBE_CONFIG_PATH: $KUBECONFIG
script:
- echo $KUBECONFIG
- echo $KUBE_CONFIG_PATH
This script shows that KUBECONFIG
is the file path and KUBE_CONFIG_PATH
is the file contents.