RHCA之路—EX280(4)
1. 题目
Use the S2I functionality of your OpenShift instance to build an application in the rome project
Use the Git repository at http://services.lab.example.com/php-helloworld for the application source
Use the Docker image labeled registry.lab.example.com/rhscl/php-70-rhel7
Once deployed, the application must be reachable(and browseable)at the following address: http://hellophp.apps.lab.example.com
Update the original repository so that the index.php file contains the text from http://materials.example.com/exam280/mordor.txt instead of the word PHP
Trigger a rebuild so that when browsing http://hellophp.apps.lab.example.com it will display the new text文章来源:https://www.toymoban.com/news/detail-703489.html
2. 解题
2.1 切换项目
一定要确认切换到了题目对应的项目,否则这题没分.文章来源地址https://www.toymoban.com/news/detail-703489.html
[root@master ~]# oc project rome
Now using project "rome" on server "https://master.lab.example.com".
[root@master ~]# mkdir ~/rome
[root@master ~]# cd ~/rome
[root@master rome]# oc projects
You have access to the following projects and can switch between them with 'oc project <projectname>':
default
ditto
farm
kube-public
kube-service-catalog
kube-system
logging
management-infra
openshift
openshift-ansible-service-broker
openshift-infra
openshift-node
openshift-template-service-broker
openshift-web-console
* rome
samples
shrimp
2.2 创建app
[root@master rome]# oc new-app registry.lab.example.com/rhscl/php-70-rhel7~http://services.lab.example.com/php-helloworld
--> Found Docker image c101534 (6 years old) from registry.lab.example.com for "registry.lab.example.com/rhscl/php-70-rhel7"
Apache 2.4 with PHP 7.0
-----------------------
PHP 7.0 available as docker container is a base platform for building and running various PHP 7.0 applications and frameworks. PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers to write dynamically generated web pages. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding is probably as a replacement for CGI scripts.
Tags: builder, php, php70, rh-php70
* An image stream will be created as "php-70-rhel7:latest" that will track the source image
* A source build using source code from http://services.lab.example.com/php-helloworld will be created
* The resulting image will be pushed to image stream "php-helloworld:latest"
* Every time "php-70-rhel7:latest" changes a new build will be triggered
* This image will be deployed in deployment config "php-helloworld"
* Port 8080/tcp will be load balanced by service "php-helloworld"
* Other containers can access this service through the hostname "php-helloworld"
--> Creating resources ...
imagestream "php-70-rhel7" created
imagestream "php-helloworld" created
buildconfig "php-helloworld" created
deploymentconfig "php-helloworld" created
service "php-helloworld" created
--> Success
Build scheduled, use 'oc logs -f bc/php-helloworld' to track its progress.
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose svc/php-helloworld'
Run 'oc status' to view your app.
2.3 创建app路由
[root@master rome]# oc expose svc/php-helloworld --hostname=hellophp.apps.lab.example.com
route "php-helloworld" exposed
2.4 克隆项目
[root@master rome]# git clone registry.lab.example.com/rhscl/php-70-rhel7
fatal: repository 'registry.lab.example.com/rhscl/php-70-rhel7' does not exist
[root@master rome]# git clone http://services.lab.example.com/php-helloworld
Cloning into 'php-helloworld'...
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
[root@master rome]# cd php-helloworld/
[root@master php-helloworld]# curl http://materials.example.com/exam280/mordor.txt
exam280
2.5 修改index.html并长传
[root@master php-helloworld]# cat index.php
<?php
print "exam280\n";
?>
[root@master php-helloworld]# git config --global user.name "qiuqin"
[root@master php-helloworld]# git config --global user.email 199@199.com
[root@master php-helloworld]# git config --global push.default simple
[root@master php-helloworld]# git add .
[root@master php-helloworld]# git commit -m 4
[master d0d382a] 4
1 file changed, 1 insertion(+), 1 deletion(-)
[root@master php-helloworld]# git push
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (3/3), 264 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://services.lab.example.com/php-helloworld
6d61e75..d0d382a master -> master
2.6 重构应用
[root@master php-helloworld]# oc start-build php-helloworld
build "php-helloworld-2" started
3. 确认
[root@master php-helloworld]# curl http://hellophp.apps.lab.example.com
exam280
[root@master php-helloworld]# oc get pods
NAME READY STATUS RESTARTS AGE
php-helloworld-1-build 0/1 Completed 0 9m
php-helloworld-2-build 0/1 Completed 0 1m
php-helloworld-2-dmncr 1/1 Running 0 1m
[root@master php-helloworld]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
php-helloworld ClusterIP 172.30.55.47 <none> 8080/TCP 9m
[root@master php-helloworld]# oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
php-helloworld hellophp.apps.lab.example.com php-helloworld 8080-tcp None
到了这里,关于RHCA之路---EX280(4)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!