commands Flashcards

1
Q

Login to Openshift cluster as admin user

A

oc login -u admin -p redhat https://api.ocp4.example.com:644

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Identify the URL for the web console

A

oc whoami –show-console

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create the comprehensive-review project

A

oc new-project comprehensive-review

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Source the classroom configuration file that is accessible at /usr/local/etc/ocp4.config, and log in as the kubeadmin user

A

$ source /usr/local/etc/ocp4.config
$ oc login -u kubeadmin -p ${RHT_OCP4_KUBEADM_PASSWD} \
> https://api.ocp4.example.com:6443

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Smoke test: Use the oc new-app command to create the hello-world-nginx deployment configuration. Make sure to use the –as-deployment-config option to create the application using a deployment configuration

A

$ oc new-app –name hello-world-nginx \
> –as-deployment-config \
> https://github.com/RedHatTraining/DO280-apps \
> –context-dir hello-world-nginx

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Smoke test: Create a route to the application by exposing the hello-world-nginx service

A

$ oc expose service hello-world-nginx \

> –hostname hello-world.apps.ocp4.example.com

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Smoke test: Verify access to the application

A

curl -s http://hello-world.apps.ocp4.example.com \

> | grep Hello

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Perform a smoke test of the cluster to verify basic cluster functionality. Use a deployment configuration to create an application named hello-world-nginx. The application source code is located in the hello-world-nginx subdirectory of the https://github.com/RedHatTraining/DO280-apps repository.

Create a route for the application using any available hostname in the apps.ocp4.example.com subdomain, and then verify that the application responds to external requests.

A
  1. Use the oc new-app command to create the hello-world-nginx deployment configuration. Make sure to use the –as-deployment-config option to create the application using a deployment configuration.
  2. Create a route to the application by exposing the hello-world-nginx service.
  3. Wait until the application pod is running.
  4. Verify access to the application.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

As the admin user, create three user groups: leaders, developers, and qa.

Assign the leader user to the leaders group, the developer user to the developers group, and the qa-engineer user to the qa group.

Assign roles to each group:

Assign the self-provisioner role to the leaders group, which allows members to create projects. For this role to be effective, you must also remove the ability of any authenticated user to create new projects.

Assign the edit role to the developers group for the comprehensive-review project only, which allows members to create and delete project resources.

Assign the view role to the qa group for the comprehensive-review project only, which provides members with read access to project resources.
A
  1. Log in as the admin user.
  2. Create the three user groups.
  3. Add each user to the appropriate group.
  4. Allow members of the leaders group to create new projects:
  5. Remove the self-provisioner cluster role from the system:authenticated:oauth group.
  6. Allow members of the developers group to create and delete resources in the comprehensive-review project:
  7. Allow members of the qa group to view project resources:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Log in as the admin user.

A

$ oc login -u admin -p review

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Create the three user groups

A

$ for group in leaders developers qa
> do
> oc adm groups new ${group}
> done

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Add each user to the appropriate group.

A

$ oc adm groups add-users leaders leader
$ oc adm groups add-users developers developer
$ oc adm groups add-users qa qa-engineer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Allow members of the leaders group to create new projects:

A

$ oc adm policy add-cluster-role-to-group \

> self-provisioner leaders

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Remove the self-provisioner cluster role from the system:authenticated:oauth group.

A

$ oc adm policy remove-cluster-role-from-group \

> self-provisioner system:authenticated:oauth

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Allow members of the developers group to create and delete resources in the comprehensive-review project:

A

$ oc policy add-role-to-group edit developers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Allow members of the qa group to view project resources:

A

$ oc policy add-role-to-group view qa

17
Q

As the developer user, use a deployment to create an application named mysql in the comprehensive-review project. Use the container image available at registry.access.redhat.com/rhscl/mysql-57-rhel7:5.7. This application provides a shared database service for other project applications.

Create a generic secret named mysql using password as the key and r3dh4t123 as the value.

Set the MYSQL_ROOT_PASSWORD environment variable to the value of the password key in the mysql secret.

A
  1. Log in to the cluster as the developer user.
  2. Create a new application to deploy a mysql database server. Use oc new-app to create a deployment.
  3. Create a generic secret for the MySQL database named mysql using a key of password and a value of r3dh4t123.
  4. Use the mysql secret to initialize environment variables for the mysql deployment.
18
Q

Log in to the cluster as the developer user.

A

$ oc login -u developer -p review

19
Q

Create a new application to deploy a mysql database server. Use oc new-app to create a deployment.

A

$ oc new-app –name mysql \

> –docker-image registry.access.redhat.com/rhscl/mysql-57-rhel7:5.7

20
Q

Create a generic secret for the MySQL database named mysql using a key of password and a value of r3dh4t123.

A

$ oc create secret generic mysql \

> –from-literal password=r3dh4t123

21
Q

Use the mysql secret to initialize environment variables for the mysql deployment.

A

$ oc set env deployment mysql \

> –prefix MYSQL_ROOT_ –from secret/mysql

22
Q

As the developer user, use a deployment to create an application named wordpress. Create the application in the comprehensive-review project. Use the image available at docker.io/library/wordpress:5.3.0.

Configure the WORDPRESS_DB_HOST environment variable to have a value of mysql. The application uses this variable to connect the mysql database service provided by the mysql application.

Configure the WORDPRESS_DB_NAME environment variable to have a value of wordpress. The application uses this variable to identify the name of the database. If the database does not exist on the database server, then the application attempts to create a new database with this name.

Set the WORDPRESS_DB_USER environment variable to have a value of root. Set the WORDPRESS_DB_PASSWORD environment variable to the value of the password key in the mysql secret. The value of the WORDPRESS_DB_PASSWORD environment variable must be the same as the mysql root user password.

The wordpress application also requires the anyuid security context constraint. Create a service account named wordpress-sa, and then assign the anyuid security context constraint to it. Configure the wordpress deployment to use the wordpress-sa service account.

Create a route for the application using any available hostname in the apps.ocp4.example.com subdomain. If you correctly deploy the application, then an installation wizard displays when you access the application from a browser.

A
  1. Deploy a wordpress application as a deployment.
  2. Add the WORDPRESS_DB_PASSWORD environment variable to the wordpress deployment. Use the value of the password key in the mysql secret as the value for the variable.
  3. Create the wordpress-sa service account.
  4. Log in to the cluster as the admin user and grant anyuid privileges to the wordpress-sa service account.
  5. Switch back to the developer user to perform the remaining steps. Log in to the cluster as the developer user.
  6. Configure the wordpress deployment to use the wordpress-sa service account.
  7. Create a route for the wordpress application.
  8. Use a web browser to verify access to the URL http://wordpress.apps.ocp4.example.com. When you correctly deploy the application, a setup wizard displays in the browser.
23
Q

Deploy a wordpress application as a deployment.

A

$ oc new-app –name wordpress \
> –docker-image docker.io/library/wordpress:5.3.0 \
> -e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_USER=root \
> -e WORDPRESS_DB_NAME=wordpress

24
Q

Add the WORDPRESS_DB_PASSWORD environment variable to the wordpress deployment. Use the value of the password key in the mysql secret as the value for the variable.

A

$ oc set env deployment/wordpress \

> –prefix WORDPRESS_DB_ –from secret/mysql

25
Q

Create the wordpress-sa service account.

A

$ oc create serviceaccount wordpress-sa

26
Q

Log in to the cluster as the admin user and grant anyuid privileges to the wordpress-sa service account.

A

$ oc login -u admin -p review

$ oc adm policy add-scc-to-user anyuid -z wordpress-sa

27
Q

Switch back to the developer user to perform the remaining steps. Log in to the cluster as the developer user.

A

$ oc set serviceaccount deployment/wordpress \

> wordpress-sa

28
Q

Configure the wordpress deployment to use the wordpress-sa service account.

A

$ oc set serviceaccount deployment/wordpress \

> wordpress-sa

29
Q

Create a route for the wordpress application.

A

$ oc expose service wordpress \

> –hostname wordpress.apps.ocp4.example.com

30
Q

As the developer user, deploy the famous-quotes application in the comprehensive-review project using the ~/DO280/labs/comprehensive-review/deploy_famous-quotes.sh script. This script creates the defaultdb database and the resources defined in the ~/DO280/labs/comprehensive-review/famous-quotes.yaml file.

The application pods do not initially deploy after you execute the script. The famous-quotes deployment configuration specifies a node selector, and there are no cluster nodes with a matching node label.

Remove the node selector from the deployment configuration, which enables OpenShift to schedule application pods on any available node.

Create a route for the famous-quotes application using any available hostname in the apps.ocp4.example.com subdomain, and then verify that the application responds to external requests.

A
  1. Run the ~/DO280/labs/comprehensive-review/deploy_famous-quotes.sh script.
  2. Verify that the famous-quotes application pod is not scheduled for deployment.
  3. See if any project events provide information about the problem.
  4. Save the famous-quotes deployment configuration resource to a file.
  5. Use an editor to remove the node selector from the /tmp/famous-dc.yaml file. Search for the nodeSelector line in the file. Delete the following two lines from the /tmp/famous-dc.yaml file.
  6. Replace the famous-quotes deployment configuration with the modified file.
  7. Wait a few moments and then run the oc get pods command to ensure that the famous-quotes application is now running.
  8. Create a route for the famous-quotes application.
  9. Verify that the famous-quotes application responds to requests sent to the http://quotes.apps.ocp4.example.com URL.
31
Q

Run the ~/DO280/labs/comprehensive-review/deploy_famous-quotes.sh script.

A

$ ~/DO280/labs/comprehensive-review/deploy_famous-quotes.sh

32
Q

Verify that the famous-quotes application pod is not scheduled for deployment.

A

$ oc get pods

33
Q

See if any project events provide information about the problem.

A

$ oc get events –sort-by=’{.lastTimestamp}’

34
Q

Save the famous-quotes deployment configuration resource to a file.

A

$ oc get dc/famous-quotes -o yaml > /tmp/famous-dc.yaml

35
Q

Use an editor to remove the node selector from the /tmp/famous-dc.yaml file. Search for the nodeSelector line in the file. Delete the following two lines from the /tmp/famous-dc.yaml file.

A

nodeSelector:

env: quotes

36
Q

Replace the famous-quotes deployment configuration with the modified file.

A

$ oc replace -f /tmp/famous-dc.yaml

37
Q

Wait a few moments and then run the oc get pods command to ensure that the famous-quotes application is now running.

A

$ oc get pods -l app=famous-quotes

38
Q

Create a route for the famous-quotes application.

A

$ oc expose service famous-quotes \

> –hostname quotes.apps.ocp4.example.com

39
Q

Verify that the famous-quotes application responds to requests sent to the http://quotes.apps.ocp4.example.com URL.

A

$ curl -s http://quotes.apps.ocp4.example.com \

> | grep Quote