Bootstrap FreeKB - OpenShift - Display api URL using the oc get apiserver command
OpenShift - Display api URL using the oc get apiserver command

Updated:   |  OpenShift articles

The oc get apiserver command can be used to list the API Servers. In this example, there is one API Server named "cluster".

~]$ oc get apiserver
NAME      AGE
cluster   333d

 

The oc describe apiserver cluster command can be used to display details of the API Server. Notice in this example that near the bottom of the output the URL for the API Server is api.openshift.example.com which means that https://api.openshfit.example.com:<port> would be used to submit an HTTPS request to the API Server.

~]$ oc describe apiserver cluster
Name:         cluster
Namespace:    
Labels:       <none>
Annotations:  oauth-apiserver.openshift.io/secure-token-storage: true
              release.openshift.io/create-only: true
API Version:  config.openshift.io/v1
Kind:         APIServer
Metadata:
  Creation Timestamp:  2021-07-16T17:10:18Z
  Generation:          3
  Managed Fields:
    API Version:  config.openshift.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:oauth-apiserver.openshift.io/secure-token-storage:
          f:release.openshift.io/create-only:
      f:spec:
        .:
        f:audit:
          .:
          f:profile:
    Manager:      cluster-version-operator
    Operation:    Update
    Time:         2021-07-16T17:10:18Z
    API Version:  config.openshift.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        f:servingCerts:
          .:
          f:namedCertificates:
    Manager:         kubectl-patch
    Operation:       Update
    Time:            2021-09-15T17:51:41Z
  Resource Version:  66484952
  Self Link:         /apis/config.openshift.io/v1/apiservers/cluster
  UID:               f079c10c-6551-4b38-913e-23eec0d1ff24
Spec:
  Audit:
    Profile:  Default
  Serving Certs:
    Named Certificates:
      Names:
        api.openshift.example.com
      Serving Certificate:
        Name:  api-cert-2022
Events:        <none>

 

The --output jsonpath option can be used to return the output as JSON and to then return only the API Server URL.

~]$ oc get apiserver cluster --output jsonpath={.spec.servingCerts.namedCertificates[*].names[*]}
api.openshift.example.com

 

 




Did you find this article helpful?

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



Comments


Add a Comment


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