Adding a new Kubernetes deployment context
How to enable Kubernetes deployments to a new cluster and/or namespace in deployment-all
Problem
A new Kubernetes context needs to be enabled in deployment-all.
Steps
-
Verify that the
deployment-allcheckout 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 laterFor 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_CREDENTIALSvariable 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 elseDeploy the setup project from
openshift/setupvia./openshift_setup_context.sh NEW_CONTEXT EXTERNAL_CONTEXT -
Edit
secrets.ymland move the new token env variable (OPENSHIFT_NEW_CONTEXT_KEY) to the appropriate place. -
Edit
.gitlab-ci.ymland add the new context to the deployment of thesetupproject.