Access the OpenShift Console and CLI

Login to the OpenShift Web Console

  1. Set your account to the proper subscription.

    az account set --subscription {azure_subscription}
  2. Make sure your cluster is ready by using the aro show extension to the az command. Use this command to check on the state of your ARO clusters.

    az aro show \
      --resource-group openenv-${GUID} \
      --name aro-cluster-${GUID} \
      --query "provisioningState" -o tsv
    Sample Output
    Succeeded
  3. First, let’s configure your workshop environment with some helper variables to store key values of our cluster to make accessing it easier. To do so, let’s run the following command:

    cat << EOF >> ~/.workshoprc
    export OCP_PASS=$(az aro list-credentials --name \
      aro-cluster-${GUID} --resource-group openenv-${GUID} \
      --query="kubeadminPassword" -o tsv)
    
    export OCP_USER="kubeadmin"
    
    export OCP_CONSOLE="$(az aro show --name aro-cluster-${GUID} \
      --resource-group openenv-${GUID} \
      -o tsv --query consoleProfile)"
    
    export OCP_API="$(az aro show --name aro-cluster-${GUID} \
      --resource-group openenv-${GUID} \
      --query apiserverProfile.url -o tsv)"
    EOF
    
    source ~/.workshoprc
    
    echo "source ~/.workshoprc" >>~/.bashrc
    
    env | grep -E 'AZ_|OCP'
    Sample Output
    OCP_USER=kubeadmin
    OCP_API={aro_public_api_url}
    OCP_PASS={aro_kube_password}
    OCP_CONSOLE={aro_console}
  4. To access the OpenShift CLI tools (oc) and web console you will need to retrieve your cluster credentials. The helper variables from above will make this simple!

    To retrieve the credentials, run the following command:

    az aro list-credentials --name aro-cluster-${GUID} --resource-group openenv-${GUID}
    Sample Output
    {
      "kubeadminPassword": "{aro_kube_password}",
      "kubeadminUsername": "kubeadmin"
    }
  5. Next retrieve the console URL by running the following command:

    az aro show --name aro-cluster-${GUID} --resource-group \
      openenv-${GUID} -o tsv --query consoleProfile
    Sample Output
    {aro_console}
  6. Finally, open the link to the console provided in a separate tab, and login with the provided credentials.

Login to the OpenShift CLI

Now that you’re logged into the cluster’s console, return to the lab command line console.

  1. To login to the cluster using the OpenShift CLI tools (oc), first we need to retrieve the API server endpoint. To do so, run the following command:

    az aro show -g openenv-${GUID} -n aro-cluster-${GUID} --query apiserverProfile.url -o tsv
    Sample Output
    {aro_public_api_url}
  2. Now that we’ve captured the API server endpoint, we can login to the cluster by running the following command:

    oc login "${OCP_API}" -u "${OCP_USER}" -p "${OCP_PASS}"
    Sample Output
    Login successful.
    
    You have access to 72 projects, the list has been suppressed. You can list all projects with
    'oc projects'
    
    Using project "default".

Congratulations, you’re now logged into the cluster and ready to move on to the workshop content.