Difficulty: beginner
Estimated Time: 5-10 minutes

When working with an OpenShift cluster you can use either the web console, the command line oc tool, or the REST API. Whichever method you use to access the OpenShift cluster you need to prove you have the right to use the cluster by first authenticating using a user account registered with the cluster.

In this course you will learn about how to access and login to an OpenShift cluster using the web console and command line. You will also learn how you can add collaborators on your projects so others can view or work on your applications.

In this course you learnt about how to log into an OpenShift cluster, as well as how you can add other users as collaborators to you project.

You can find a summary of the key commands covered below, along with some related commands. To see more information on each oc command, run it with the --help option.

oc login: Log in to your OpenShift cluster and save the session token for subsequent use. You will be prompted for the user name and password or directed to a web console page where you can obtain a token you must then use to use to login from the command line. The web page will require you to first login in to the web console if you are not already logged in.

oc login <server>: Log in to a specific OpenShift cluster. You will need to specify the name of the server as argument the first time you are using it, or if switching back to it after having used a different cluster.

oc login --username <user>: Log in to your OpenShift cluster as a specific user.

oc login --username <username> --password <password>: Log in to your OpenShift cluster as a specific user and supply the password on the command line. Note that this is not recommended for real systems as your password may be logged or retained in command history.

oc login --token <token>: Log in to your server using a token for an existing session.

oc logout: Log out of the active session by clearing the session token.

oc whoami: Show the name of the user for the current login session.

oc whoami --token: Show the token for the current login session.

oc whoami --show-server: Show which OpenShift cluster you are logged into.

oc whoami --show-context: Shows the context for the current session. This will include details about the project, server and name of user, in that order.

oc config get-clusters: Show a list of all OpenShift clusters ever logged in to.

oc config get-contexts: Show a list of contexts for all sessions ever created. For each context listed, this will include details about the project, server and name of user, in that order.

oc adm policy add-role-to-user edit <username> -n <project>: Add another user to a project so that they can work within the project, including creating new deployments or deleting applications.

oc adm policy add-role-to-user view <username> -n <project>: Add another user to a project but such that they can only view what is in the project.

oc adm policy add-role-to-user admin <username> -n <project>: Add another user to a project such that they are effectively a joint owner of the project and have administration rights over it, including the ability to delete the project.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Logging in to an OpenShift Cluster

Step 1 of 4

Topic 1 - Logging in Via the Web Console

The easiest way to access and interact with OpenShift is through the web console. The URL for the web console will be dictated by what was specified as the public URL for the OpenShift cluster when it was set up. Once the web console is accessed, how you then login will depend on the configured identity provider.

For this course the public URL for the web console is:

https://[[HOST_SUBDOMAIN]]-8443-[[KATACODA_HOST]].environments.katacoda.com

To view the web console at the same time as these instructions, you can also select the Dashboard tab to the right of the tab for the embedded Terminal.

In the case of the OpenShift cluster managing user authentication, the web console login page will prompt you for your Username and Password.

Web Console Login

In the case of an external authentication service being used as the identity provider, it will be necessary to login first to the external service. As an example, if you were accessing OpenShift Online you would see:

External Login

For the OpenShift cluster used in this course, as the OpenShift cluster is managing user authentication, you will be presented with a login page that prompts you for your user account credentials. You can login using the credentials:

  • Username: developer
  • Password: developer

As this is the first time you have logged in as this user in this OpenShift cluster, you will be presented with a "Welcome to OpenShift" message and the option of creating a new project.

Web Console Welcome

Create a new project by selecting New Project. Call the project myproject.

Create New Project

When a new project is created you will be shown a catalog of application types you can deploy. To skip creating any application at this point and get to main page with the list of all projects you have, you can select on the name of the OpenShift product found at the top left of the page.

Shortcut to Projects

Click on the logo now to return to the main page.

This is useful if you ever got lost in the web console and want to get back to the top most level.

List of Projects