This course is using an outdated version of the technology and is now considered to be Legacy content. It will be removed from our catalog on Jun 28, 2024. Please be sure to complete your course and finish any remaining labs before that date. We recommend moving to version 4.12, which is the latest version currently available.
Access a newly created managed cluster using initial cluster administrator credentials.
Perform a smoke test by deploying and accessing an application.
Outcomes
You should be able to:
Create a Red Hat OpenShift on AWS (ROSA) cluster administrator account.
Access the OpenShift web console.
Install the OpenShift command-line interface (CLI) on your workstation.
Deploy an application on OpenShift and expose it on the internet.
To perform this exercise, ensure that you have completed the section called “Guided Exercise: Create a ROSA Cluster ”.
Procedure 1.3. Instructions
Verify that your ROSA CLI configuration is correct and that the ROSA cluster is ready.
Open a command-line terminal on your system and then run the rosa whoami command to confirm that the AWS and Red Hat OpenShift Cluster Manager (OCM) configuration is correct.
Verify that the command lists your AWS account, the correct AWS region, and your Red Hat customer portal account.
$ rosa whoami
AWS ARN: arn:aws:iam::...:user/user1@example.com-fqppg-admin
AWS Account ID: 452954386616
AWS Default Region: us-east-1
OCM API: https://api.openshift.com
OCM Account Email: wlombardo@example.com
OCM Account ID: 1VhrXTjpDWnt4rfZvdgLj2fEcso
OCM Account Name: Wilhelm Lombardo
OCM Account Username: wlombardo
OCM Organization External ID: 15701801
OCM Organization ID: 1HMOv5QDUifj2g6Si1hyskyv2IP
OCM Organization Name: Wilhelm LombardoThe credentials in the preceding output are different on your system. Your own credentials should display.
Run the rosa describe cluster command to confirm that your ROSA cluster named do120-cluster is ready.
$rosa describe cluster -c do120-cluster...output omitted... State:ready...output omitted...
Create an administrator account so that you can access your cluster.
The following command creates the cluster-admin account.
$rosa create admin --cluster do120-clusterI: Admin account has been added to cluster 'do120-cluster'. I: Please securely store this generated password. If you lose this password you can delete and recreate the cluster admin user. I: To login, run the following command: oc login https://api.do120-cluster.jf96.p1.openshiftapps.com:6443 --usernamecluster-admin--password2XmXt-2Up7U-oqNTP-2Vw5yI: It may take several minutes for this access to become active.
In the preceding output, the URL and the password in the oc login command are different on your system.
Take a note of the password.
Log in to the OpenShift web console by using the cluster-admin username and the password that the preceding command has generated.
Run the rosa describe cluster command again to retrieve the URL of the OpenShift web console.
$rosa describe cluster -c do120-cluster...output omitted... Console URL:https://console-openshift-console.apps.do120-cluster.jf96.p1.openshiftapps.com...output omitted...
The URL in the preceding output is different on your system.
Open a web browser, navigate to the OpenShift web console URL, click , and then log in as the cluster-admin user with the password that the rosa create admin command returned.
If a message indicates that the connection is not private or that the certificate is not valid, or if the button does not display, then wait five minutes and refresh the page.
The page displays, which confirms that you are connected to the OpenShift web console. Do not log out from the console and do not close the web browser window. You use the console in a different step in this exercise.
Install the OpenShift CLI (oc) and the Kubernetes CLI (kubectl) so that you can log in and then manage your OpenShift cluster from the command line.
Use the rosa command to download the archive for your operating system.
$ rosa download oc
I: Verifying whether OpenShift command-line tool is available...
W: OpenShift command-line tool is not installed.
Run 'rosa download oc' to download the latest version, then add it to your PATH.
I: Downloading https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz
Downloading... 53 MB complete
I: Successfully downloaded openshift-client-linux.tar.gzDepending on your operating system, the archive name might be different.
Extract the archive and then move the executable files to a standard system directory so that you can run the commands.
For example, on Linux and macOS systems, you can move the oc and kubectl binary files into the /usr/local/bin/ directory:
$ sudo mv oc kubectl /usr/local/bin/Use the oc command to log in to your ROSA cluster.
To do so, you could copy and then paste the oc login command that the rosa create admin command returned in a preceding step.
That oc login command uses the --username and the --password options to specify the username and the password.
You can also use the oc login command with a token so that you do not have to expose your username.
In this exercise, you use the OpenShift web console to generate a token and then use it to log in from the command line.
Switch to the OpenShift web console in your web browser. Select → .

If the log in page displays, then click and use the cluster-admin username with the password that the rosa create admin command returned in a preceding step.
Click and then copy the oc login --token=… command to the clipboard.
Paste the command into the command-line terminal and then run it.
$oc login --token=sha256~1NofZkVCi3qCBcBJGc6XiOJTK5SDXF2ZYwhAARx5yJg--server=https://api.do120-cluster.Logged into "https://api.do120-cluster.jf96.p1.openshiftapps.com:6443" as "cluster-admin" using the token provided. You have access to 99 projects, the list has been suppressed. You can list all projects with 'oc projects' Using project "default". Welcome! See 'oc help' to get started.jf96.p1.openshiftapps.com:6443
In the preceding command, the token and the URL are different on your system.
Create a new OpenShift project and then deploy a test application.
Create the hello-do120 project.
$ oc new-project hello-do120
Now using project "hello-do120" on server "https://api.do120-cluster.jf96.p1.openshiftapps.com:6443".
...output omitted...Use the quay.io/redhattraining/hello-world-nginx:v1.0 container image to deploy a NGINX web server with sample content.
Ignore the warning message.
$ oc new-app quay.io/redhattraining/hello-world-nginx:v1.0
...output omitted...
--> Creating resources ...
imagestream.image.openshift.io "hello-world-nginx" created
Warning: would violate PodSecurity "restricted:v1.24": allowPrivilegeEscalation != false (container "hello-world-nginx" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "hello-world-nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "hello-world-nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "hello-world-nginx" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
deployment.apps "hello-world-nginx" created
service "hello-world-nginx" created
--> Success
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose service/hello-world-nginx'
Run 'oc status' to view your app.Expose the application to the internet.
$ oc expose service/hello-world-nginx
route.route.openshift.io/hello-world-nginx exposedRetrieve the application URL.
To do so, you could use the oc get route command.
For demonstration purposes, use the kubectl command instead.
The Kubernetes CLI uses the same configuration as the OpenShift CLI.
The kubectl command uses the same credentials that you configured when you ran the oc login command.
$ kubectl get route/hello-world-nginx
NAME HOST/PORT ...
hello-world-nginx hello-world-nginx-hello-do120.apps.do120-cluster.jf96.p1.openshiftapps.com ...The hostname in the preceding output is different on your system.
Open a web browser and then access the URL from the preceding output in HTTP (without SSL): http://hello-world-nginx-hello-do120.apps.do120-cluster.jf96.p1.openshiftapps.com.
A Hello, world message displays.
This message confirms that you successfully deployed your application on OpenShift.
Clean up your work by deleting the hello-do120 project.
$ oc delete project hello-do120
project.project.openshift.io "hello-do120" deletedLog out from the OpenShift CLI and then remove the cluster-admin user.
In another exercise you create an identity provider and assign the cluster management role to a user.
Log out from the OpenShift CLI.
$ oc logout
Logged "cluster-admin" out on "https://api.do120-cluster.jf96.p1.openshiftapps.com:6443"Delete the cluster-admin user account.
$rosa delete admin --cluster do120-cluster? Are you sure you want to delete cluster-admin user on cluster do120-cluster?YesI: Admin user 'cluster-admin' has been deleted from cluster 'do120-cluster'
This concludes the section.