Logging in to your cluster from the command-line interface

After you install the CLIs, you can log in to your cluster from the command-line interface to view information about the cluster and manage your resources.

About this task

The instructions in the following procedure document how to log in from the Red Hat® OpenShift® CLI (oc).
  • If you are using a Kubernetes environment, log in by using the relevant command for your environment.
  • In all other commands within the documentation, substitute oc with kubectl where appropriate.

Procedure

To log in to your cluster, complete the following steps:

  1. From a command window, run the oc login command and provide the OpenShift Container Platform server URL (and optionally a token).

    Examples:

    oc login https://Mycluster_hostName:8443

    oc login --token=AbcdE1fgHijKLM2moP3q4rs5TU6vw7xYz --server=https://Mycluster_hostName:6443

  2. Indicate whether to use insecure connections, and then specify a user name and password if required.
    Logging in to the cluster from the CLI
  3. If you intend to run commands against resources in a specific namespace (or project), which is not currently the default, switch to that namespace:
    oc project namespaceName