OpenShift GitLab Runner CI Failure to Set KUBECONFIG

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When using the OpenShift GitLab CI Template, the pipeline fails to set the KUBECONFIG after performing an oc login

Steps to reproduce

  1. Install GitLab Runner Operator in OpenShift
  2. Create Token Secret
  3. Create Runner CRD (with pointer to token secret from 2.)
  4. Generate GitLab CI Pipeline with the aforementioned OpenShift template
  5. Run the pipeline
  6. oc login works as expected, printing the standard "now accessing the default project"
  7. oc fails to set KUBECONFIG and throws an error, causing the pipeline to exit with a failure code

Example Project

A private projected hosted by @salvarz1121

What is the current bug behavior?

the OpenShift GitLab Runner seems to lack permission to write the KUBECONFIG file

$ oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" --insecure-skip-tls-verify
Logged into "https://c100-e.us-east.containers.cloud.ibm.com:30852" as "IAM#salvador.alvarez@ibm.com" using the token provided.
You have access to 79 projects, the list has been suppressed. You can list all projects with 'oc projects'
Using project "default".
error: KUBECONFIG is set to a file that cannot be created or modified: /.kube/config; caused by: mkdir /.kube: permission denied

What is the expected correct behavior?

The CI template should then try to access the appropriate project as the next line in the CI yaml.

Output of checks

This bug happens on GitLab.com

Edited by 🤖 GitLab Bot 🤖