Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 1.93 KB

2.md

File metadata and controls

59 lines (47 loc) · 1.93 KB

Configure OpenShift client context for cluster admin access

You should have three OCP managed cluster and on OCP hub cluster

# Login into hub cluster 
oc login -u admin -p XXXX --insecure-skip-tls-verify https://api.YOURCLUSTER1.DOMAIN:6443
# Set the name of the context
oc config rename-context $(oc config current-context) hubcluster
# Login into 1st cluster (A environment)
oc login -u admin -p XXXX --insecure-skip-tls-verify https://api.YOURCLUSTER1.DOMAIN:6443
# Set the name of the context
oc config rename-context $(oc config current-context) cluster1
# Login into 2nd cluster (B environment)
oc login -u admin -p XXXX --insecure-skip-tls-verify https://api.YOURCLUSTER2.DOMAIN:6443
# Set the name of the context
oc config rename-context $(oc config current-context) cluster2
# Login into 3rd cluster (C environment)
oc login -u admin -p XXXX --insecure-skip-tls-verify https://api.YOURCLUSTER3.DOMAIN:6443
# Set the name of the context
oc config rename-context $(oc config current-context) cluster3

Confirm functionality of the new configured contexts. You will see that as you switch contexts and list nodes, that you are indeed switching to different clusters. Close out this validation by switching back to the cluster1 context.

# Switch to hub
oc config use-context hubcluster
# Switch to cluster1
oc config use-context cluster1
# List the nodes in cluster1
oc get nodes
# Switch to cluster2
oc config use-context cluster2
# List the nodes in cluster2
oc get nodes
# Switch to cluster3
oc config use-context cluster3
# List the nodes in cluster3
oc get nodes
# Switch back to cluster1
oc config use-context cluster1

After this our current client context is admin in cluster1.

# List the context currently being used and the user
oc config current-context && oc whoami

cluster1
admin