OpenShift - Display API Server URL using the oc config view command

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

After you have successfully logged into OpenShift, your /home/your_username/.kube/config file will be created. The oc config view command can be used to parse your /home/your_username/.kube/config file and display the contents of the file, which should return something like this.

~]$ oc config view
apiVersion: v1
clusters:
- cluster:
    server: https://api.openshift.example.com:6443
contexts:
- context:
    cluster: api-openshift-example-com:6443
    namespace: default
    user: john.doe/api-openshift-example-com:6443
  name: default/api-openshift-example-com:6443/john.doe
current-context: default/api-openshift-example-com:6443/john.doe
kind: Config
preferences: {}
users:
- name: john.doe
  user:
    token: sha256~83miYt8vIEHeP6CDaTKRy2SUruoo-TuVxdYToGQQOqo

 

The --output jsonpath option can be used to return the output as JSON and to then return the value of a specific JSON key.

~]$ oc config view --output jsonpath='{.clusters[*].cluster.server}'
https://api.openshift.example.com:6443

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter e52c1 in the box below so that we can be sure you are a human.