Adding a new Kubernetes deployment context

How to enable Kubernetes deployments to a new cluster and/or namespace in deployment-all


A new Kubernetes context needs to be enabled in deployment-all.


  1. Verify that the deployment-all checkout works correctly:

  2. Login to the cluster with admin rights, set the default namespace and show the context name (EXTERNAL_CONTEXT) via

    oc login https://K8S.API.URL:6443 --token=TOKEN
    oc config set-context --current --namespace=NAMESPACE
    oc config current-context  # Save as EXTERNAL_CONTEXT, used later

    For OpenShift, the token can be obtained after logging into the web interface by clicking on your name in the top-right corner and selecting Copy login command.

  3. Add the new context to the KUBERNETES_CREDENTIALS variable in secrets.yml.

      NEW_CONTEXT:  # name of new context
        server: https://K8S.API.URL:6443
        namespace: NAMESPACE
        token: OPENSHIFT_NEW_CONTEXT_KEY  # env var for new sa token
        pvcmode: ReadWriteOnce  # RWO for AWS/EBS, RWX if possible for EFS/NFS
        dns_record_type: cname  # 'cname' for AWS, 'a' everywhere else

    Deploy the setup project from openshift/setup via

  4. Edit secrets.yml and move the new token env variable (OPENSHIFT_NEW_CONTEXT_KEY) to the appropriate place.

  5. Edit .gitlab-ci.yml and add the new context to the deployment of the setup project.