100% found this document useful (1 vote)
667 views5 pages

Ocp288 Question Answer

The document outlines a series of tasks for deploying applications on OpenShift, including creating projects, deploying applications from source code, and configuring image registries. It provides specific commands and requirements for each task, such as deploying a pastebin application, customizing templates, and implementing health checks. Additionally, it includes instructions for setting up environment variables and config maps for applications.

Uploaded by

mdnasir3801
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
667 views5 pages

Ocp288 Question Answer

The document outlines a series of tasks for deploying applications on OpenShift, including creating projects, deploying applications from source code, and configuring image registries. It provides specific commands and requirements for each task, such as deploying a pastebin application, customizing templates, and implementing health checks. Additionally, it includes instructions for setting up environment variables and config maps for applications.

Uploaded by

mdnasir3801
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

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

Open terminal, there will be no foundation machine on desktop.


#ssh [email protected] <<- password will be given in
instructions. Please remember users- root, ocdevop, regdevop all have same
password.
oc login -u ocpdev -p redhat https://api.example.com:6443

===================================================================================
====================================================
Q1.Deploy an Application
Using the source code from http://git.domin2.example.com/git/pastebin.git. Deploy
an application that meets the following requirements

● The application is part of a project numed: crdmson


● The application is named: pastebin
● Once deployed. the application is running and available at http://pastebin-
crdmson.apps.domain2.example.com
● You have used the application to create and save a pastebin entry containing
the text
“Per aspera ad astra”

Note that application dependencies are available from the registry located at
http://nexus-domain2.example.com:8081/nexus/content/groups/node.js/

ANS:
#oc new-project crdmson

# git clone http://git.domin2.example.com/git/pastebin.git


# cd pastebin
# ls
# python -m json.tool package.json <<- check for error, in line 6 (,) delimiter
will be missing
# vi package.json

key: "value"  3rd/4th line in the file. Add quotes.


:wq!
# git add .
# git commit –m “fsd”
# git push origin master
# oc new-app --name=pastebin http://git.domin2.example.com/git/pastebin.git --
build-env npm_config_registry=http://nexus-domain2.example.com:8081/nexus/content/
groups/node.js/
# oc expose servicepastebin --hostname=pastebin-crdmson.apps.domain2.example.com
===================================================================================
===================================================================================
============------------------------------------
Q2. Open the internal image registry
Use your Openshift user to meet the following requirements
● The internal OpenShift image registry should be accessible from outside the
cluster
● podman has been used to pull the image

chartre user
from the project
minzeoui
Note that your OpenShift user has been granted all the necessary roles to complete
these tasks
-----------------------------------------------------------------------------------
-----------------------------------------
ANS:

oc patch config.imageregistry cluster -n openshift-image-registry --type merge -p


'{"spec":{"defaultRoute":true}}'

# oc get route -n openshift-image-registry<- get route name


# podman login -u ocpdevop -p ocwhoami -t <registry_route_name>
# podman pull <registry_route_name>/<project_name>/<image_name> --tls-verify=false
===================================================================================
==============================================================================
Q3. There is an OpenShift template available for download to your workbench in
either JSON or YAML format
Choose one of the following as a starting point
● http://rhgla.domadn2.example.com/materials/php.app.json
● http://rhgla.domadn2.example.com/materials/php.app.yaml
Customize the template to meet the following requirements
The template exists is the tndy Project and as named ex288-php-mysql
All resources created from the template can the deleted by executing the command:
oc…..
The template uses available versions of php and mysql
The template uses the …..
The Template has a custom parameter ….
Engineers
● The following command fails:
oc new-App ax288-php-mysql
● The following command succeeds
oc new-app ex288-php-mysql -p APPLICATTION_DOMAIN=php-app-indy.apps.domain2.
example.com
and results in the application running at http://php-app-
indy.apps.domain2.exampie.com, displaying the greeting:

Bonjour Engineers:

● The following command succeeds:


oc new-app ex288-php-mysql -p APPLICATTION_DOMAIN-php-app-indy.apps.domain2.
Example.com - p HELLO_MESSAGE ……………..

… results in the application running


===================================================================================
==============================================================================

ANS: wget http://rhgla.domadn2.example.com/materials/php.app.yaml

name: ex288-php-mysql
namespace: tendy
image: php:latest <- make latest
image: mysql:latest <- make latest
Parameters:
- name: GIT_REPOSITORY
value: http://git.domain6.example.com/ex288 <- add this value
- name: HELLO_AUDIENCE <<- add this key value pair
value: Engineers
:wq!

# oc new-app --name=ex288-php-mysql -p APPLICATTION_DOMAIN-php-app-


indy.apps.domain2.example.com
-----------------------------------------------------------------------------------
-------------------------------------------------------------------------------
===================================================================================
===============================================================================
Q4. In concert with the source code from http://git.domin2.example.com/git/exy.git.
Customize the behavior of the existing rhscl/httpd-24-rhel7 builder image scripts
to deploy an application that meets the following requirements.

● The applicalson is part of a project named: toain


● The application is named: oxy
● During the build of the image, as part of the assemble script :
/tmp/src/*.html ./ files are copied into.
● Once deployed. the application is running and available at http://oxy-
tocin.apps.domin2.example.com. displaying the following text:

Amor vinoit omnia


● Browsing to http://http://oxy-tocin.apps.domin2.example.com/info.html.html
displays an information page with the date
when the application was build (YYY-mm-dd format) as well as the text
===================================================================================
===================================================================================
==========================
ANS:
# oc new-project totain
#podman login -u regdevop -p starkmen17 registry7.domain.example.com (Testing)
# oc create secret docker-registry regsec --docker-
server=registry7.domain.example.com --docker-username=regdevop --docker-
password=starkmen17 <<- must create secret coz image stream looks for
secret within the project to pull the image. ( create secret for image registry)
# oc secrets link default regsec --for pull ( link to default service account)
# oc import-image httpd --from=private.eaxmple.com/rhscl/httpd:latest --
confirm--reference-policy='local'
# git clone http://git.domin2.example.com/git/oxy.git
# cd oxy
# ls
Index.html
# ls –a
# vi .s2i/bin/assemble
####### CHANGES ADDED HERE#####
cp -Rf /tmp/src/*.html ./

DATE=`date "+%F"`
echo "$DATE Hello world" >> ./info.html
################################
# git add .
# git commit –m “fdfd”
# git push origin master
# oc new-app --name=oxy
httpd:latest~https://git.domin2.example.com/git/oxy.git<<- ~ indicated builder
image.
# oc expose svc oxy
# curlhttp://url <<- verify the response
# curlhttp://url.info.html<<- verify the response
-----------------------------------------------------------------------------------
----------------------------------------------
===================================================================================
===========================================================================
Q5. A Python 3 application named blog has been deployed for you in a project named
octane
The application includes a script named: mailer-py
Customize the application such that the following statements are true.
● The application is running and available at http://blog-octane-apps-
domin2example.com
● After a build finishes, the above-mentioned script is automatically executed
● The most recent build of the application succeeded and triggered the script
to run
● Future rebuilds of the application will trigger the script to run
● The original Git repository used to create the application has not ....

To verify your work. you can use the…


===================================================================================
==============================================================================
ANS:
# Oc project octane
# oc get pod
# oc rsh-f blog-1-754rw<- pod name
# which python3 <<- check python path
# oc get bc. <- get the bc name
Mailer.py
# oc set build-hook bc/blog
--post-commit \
--command -- /opt/bin/python3 mailer.py” <- use python path here
# oc start-build blog
# oc expose svc blog <<- must expose service
# mail -u copenhak <- verify mail

-----------------------------------------------------------------------------------
--------------------------------------------------------------------------------
===================================================================================
===================================================
Q6. An application named blog has been deployed for you in a project named octane
The application is backed by a single running container Implement a liveness probe
for this container that meets the following requirement
● The probe monitors liveness by performing a TCP socket check on port: 8080
● The probe has an initial delay of 10 seconds and a timeout of 30 seconds
● Your changes can survive a rebuild
===================================================================================
===================================================
# oc project blog
# oc get dc
#oc set probe dc/blog --liveness --open-tcp=8080 --initial-delay-seconds=30 --
timeout-seconds=10
# oc logs -f dc/blog
-----------------------------------------------------------------------------------
-------------------------------------------------
===================================================================================
================================================================================
Q7. Using the openshift/hello-openshift image. deploy an application that meets the
following requirements.

● The application is part ot a project named: acid


● The application is named: phosphorie
● The application looks for a key named:
RESPONSE
● ...in a configuration map named:
● sodicon
● Once deployed, the application is running and available at http://phosphorie-
acid.apps.domin2.example.com. displaying the following
initial text:
● Soda pop won't stop can't....
● Re-deploying the application after ....

===================================================================================
===================================================================================
==
# oc new-project acid
# oc new-app --name=phosphorie --as-deployment-config --docker-
image=private.example.com/openshift/hello-openshift --insecure-registry=false<<-
use –as-deployment-config else dc won’t be seen and set env command will fail
below.
# oc create configmap sodicon --from-literal RESPONSE=”Soda pop won't stop can't”

oc set env dc/phosphori --from=configmap/sodicon

oc expose svc phosphorie --hostname=phosphorie-acid.apps.domin2.example.com


-----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
===================================================================================
===================================================================================
=

You might also like