$KUBECONFIG contains file content, not path to file in GitLab CI variables section

According to https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/user/project/clusters/index.md#L267, $KUBECONFIG is a path to a file containing a suitable kubeconfig for use in a deployment to an environment in a GitLab CI pipeline. In the code https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/clusters/kubernetes_namespace.rb#L48 and observing actual behaviour (13.5.5), $KUBECONFIG actually points to the contents of a kubeconfig file. When running a GitLab CI pipeline, if I reference $KUBECONFIG in variables: it is file content (e.g. KUBE_CONFIG_PATH: $KUBECONFIG for Terraform). But when in the script section $KUBECONFIG is a path.

Conventionally $KUBECONFIG should be a path to a file, not file contents. See https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable:

The KUBECONFIG environment variable is a list of paths to configuration files. The list is colon-delimited for Linux and Mac, and semicolon-delimited for Windows. If you have a KUBECONFIG environment variable, familiarize yourself with the configuration files in the list.

See #295627 (comment 473289663) for a repro.

Edited Dec 24, 2020 by Joel Low
Assignee Loading
Time tracking Loading