Adding a new Kubernetes deployment context
How to enable Kubernetes deployments to a new cluster and/or namespace in deployment-all
This page has an internal companion page which might contain additional information.
Problem
A new Kubernetes context needs to be enabled in deployment-all.
Steps
-
Verify that the
deployment-all
checkout works correctly:./openshift_login.sh
-
Login to the cluster with admin rights, set the default namespace and show the context name (
EXTERNAL_CONTEXT
) viaoc 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
. -
Add the new context to the
KUBERNETES_CREDENTIALS
variable insecrets.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./openshift_setup_context.sh NEW_CONTEXT EXTERNAL_CONTEXT
-
Edit
secrets.yml
and move the new token env variable (OPENSHIFT_NEW_CONTEXT_KEY
) to the appropriate place. -
Edit
.gitlab-ci.yml
and add the new context to the deployment of thesetup
project.