Creating and Sample OCP APP Flashcards

1
Q

In this lab scenario, you have been approached by a client who would like you to test the basic functionality of their new development Red Hat OpenShift Container Platform. The client would like you to complete the following tasks:

Create a project with the name test-db. The display name should be The first test project.
Create a new MySQL application in the project with a name of guru-mysql and label all created resources with guru-test. The MySQL database should be set up with the following configuration:
The DB name should be testdb.
The MySQL root password set to rootpass.
The MySQL user set to guru.
The MySQL user password set to badpass.
Create a route by exposing the new service.
Lastly, you will need to test that the new MySQL application is available and the DB can be accessed.
Upon completion of the lab, you can clean up the resources by running the following command: oc delete deployment.apps/guru-mysql service/guru-mysql route.route.openshift.io/guru-mysql
Good luck, and have fun, Gurus!

A

This assumes that you are logged in the OC envir
onment.

1 . Create a new project

oc new-project test-db –display-name=”The first test project””

2 Create a new application

oc new-app mysql -e MYSQL_DATABASE=testdb -e MYSQL_ROOT_PASSWORD=rootpass -e MYSQL_USER=guru -e MYSQL_PASSWORD=badpass
– name guru-mysql -l app=guru-test

3 Check status

oc status

  1. Get info on Resources

oc get all

oc get pods

  1. Expose App Service

oc expose svc/guru-mysql or oc expose service guru-mysql

  1. Get the Route

oc get route

  1. Check that you can access the database

oc get pods

oc rsh <pod-name></pod-name>

  1. Once inside the container - login to Database

guru-sql-container > mysql -uguru -pbadpass

mysql> show databases;

exit
exit

gets you back to the host

  1. Delete all resources or project

oc delete deployment.apps/guru-mysql service/guru-mysql route.route.openshift.io/guru-mysql

or

oc delete project test-db

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

In this scenario, you have been tasked with making sure that a simple Apache web page can be built from a Git repository using a new OpenShift cluster. The client would like you to complete the following tasks

Create a project with the name llama-cart-test. The display name should be Llama Cart Racing test.
Create a new http application in the project with the following configuration:
1. Uses the image stream httpd to build the application.
2. Uses the client-provided Git repository with the context directory llama-cart.

  1. The application name should be llama-cart-racing.
    Label app resources with racing-test.
  2. Create a route by exposing the new service.
  3. Test that the new Apache application is available and the web page can be accessed.
A
    • Create a new application named llama-cart-racing using the httpd image stream and the Git repository for the llama-cart-test project project:

oc new-app –name=llama-cart-racing httpd~https://github.com/linuxacademy/Red-Hat-Certified-Specialist-in-Containers-and-Kubernetes –context-dir=llama_cart -l app=”racing-test”

2.- Check the app status:

oc status

3.- Create a New Route
Create a new route to the application by exposing the new service:

oc expose service llama-cart-racing

Look up the new route:

oc get routes

    • Test the Web Page
      To view the web page, use a curl command and paste in the previously copied host name:

curl -s <ROUTE_HOST_NAME>
You should now see the HTML of the Llama Cart Racing Club web page.</ROUTE_HOST_NAME>

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

Setup Multicontainer Application

In this lab scenario, you have been approached by a client who would like you to test a new multi-container application template using their new development Red Hat OpenShift Container Platform. The client would like you to complete the following tasks:

Create a new project.
Download the template file from this Git repo and publish it to your new project.

Process the template with custom parameters and use this to create the application.

Enter a test value into the web application to verify it is working properly.

A
    • Download the OpenShift Template and Publish It
      Note: If you are using the Red Hat OpenShift sandbox, log in and ensure you start a shell by clicking on the >_ icon in the top-right corner.

curl https://raw.githubusercontent.com/linuxacademy/Red-Hat-Certified-Specialist-in-Containers-and-Kubernetes/main/multi-container/multi_test.yaml -o multi_test.yaml

List your file.
Note: If you are using OpenShift sandbox, exclude multi-test.yaml from the following command:

ls multi-test.yaml

clear your screen.
clear

    • Publish the template to your local project:

oc create -f multi_test.yaml

3.- Verify the template is published:

oc get templates

clear your screen.
clear

    • Process the Template and Create the Application
      Process the template with the following custom parameters and create the application using the processed template (this will take a few minutes to build):

oc process -f multi_test.yaml -o yaml -p NAME=fruit-stand -p DATABASE_NAME=fruit_stand -p DATABASE_USER=guru -p DATABASE_PASSWORD=badpass -p DATABASE_ADMIN_PASSWORD=badidea | oc create -f -

    • Verify the Application Is Working
      View the resources:
      oc get all | less

Scroll down towards the bottom and copy the HOST/PORT route (SERVICES would be fruit-stand) and paste it into a web browser.

curl fruit-stand-multi-test.apps.na410.prod.nextcle.com

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