RHCA之路—EX280(8)
1. 题目
On master.lab.example.com using the template file in http://materials.example.com/exam280/gogs as a basis,
install an application in the ditto project according to the following requirements:
All of the registry entries must point to your local registry at registry.lab.example.com
The version in the ImageStream line for the postgresql image must be changed from postgresql:9.5 to postgresql:9.2
For the Gogs pod, use the Docker image from http://materials.example.com/exam280/gogs.tar and make sure it is tagged as registry.lab.example.com/openshiftdemos/gogs:0.9.97 and pushed to your local registry
Mask the template gogs available across all projects and for all users
Deploy the appllication using the template, setting the parameter HOSTNAME to gogs.apps.lab.example.com
Create a user salvo with password redhat and email address salvo@master.lab.example.com on the application frontend
(use the Register link on the top right of the page at http://gogs.apps.lab.example.com) and, as this user, create a Git repository named ex280
If there isn’t one already, create a file named README.md in the repository ex280 and put the line faber est quisque fortunae suae in it and commit it.
The repository must be visible and accessible
2. 解题
2.1 切换项目
[root@master shrimp]# oc project ditto
Now using project "ditto" on server "https://master.lab.example.com".
[root@master shrimp]# mkdir ~/ditto
[root@master shrimp]# cd ~/ditto
[root@master ditto]# oc projects
You have access to the following projects and can switch between them with 'oc project <projectname>':default* dittofarmkube-publickube-service-catalogkube-systemloggingmanagement-infraopenshiftopenshift-ansible-service-brokeropenshift-infraopenshift-nodeopenshift-template-service-brokeropenshift-web-consoleromesamplesshrimpUsing project "ditto" on server "https://master.lab.example.com".
2.2 创建模板
2.2.1 下载模板
[root@master ditto]# wget http://materials.example.com/exam280/gogs/gogs-temp.yaml
--2023-09-04 16:33:37-- http://materials.example.com/exam280/gogs/gogs-temp.yaml
Resolving materials.example.com (materials.example.com)... 172.25.254.254
Connecting to materials.example.com (materials.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10037 (9.8K) [text/plain]
Saving to: ‘gogs-temp.yaml’100%[===========================================================================================================>] 10,037 --.-K/s in 0s2023-09-04 16:33:37 (285 MB/s) - ‘gogs-temp.yaml’ saved [10037/10037]
2.2.3 替换yaml
[root@master ditto]# sed -ir 's/postgresql:9.5/postgresql:9.2/g' gogs-temp.yaml
[root@master ditto]# grep gogs: gogs-temp.yamlname: services.lab.example.com/openshiftdemos/gogs:0.9.97
[root@master ditto]# sed -ir 's#services.lab.example.com/openshiftdemos/gogs:0.9.97#registry.lab.example.com/openshiftdemos/gogs:0.9.97#g' gogs-temp.yaml
2.2.4 创建template
[root@master ditto]# oc create -f gogs-temp.yaml -n openshift
template "gogs" created
2.3 创建镜像
[root@master ditto]# wget http://materials.example.com/exam280/gogs.tar
--2023-09-04 16:38:12-- http://materials.example.com/exam280/gogs.tar
Resolving materials.example.com (materials.example.com)... 172.25.254.254
Connecting to materials.example.com (materials.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 467157504 (446M) [application/x-tar]
Saving to: ‘gogs.tar’100%[===========================================================================================================>] 467,157,504 106MB/s in 4.7s2023-09-04 16:38:17 (95.1 MB/s) - ‘gogs.tar’ saved [467157504/467157504][root@master ditto]# docker load -i gogs.tar
34e7b85d83e4: Loading layer [==================================================>] 199.9 MB/199.9 MB
addf85492fbe: Loading layer [==================================================>] 6.144 kB/6.144 kB
126a150d0743: Loading layer [==================================================>] 189.6 MB/189.6 MB
b93687778caa: Loading layer [==================================================>] 77.66 MB/77.66 MB
Loaded image: openshiftdemos/gogs:latest
[root@master ditto]# docker tag openshiftdemos/gogs:latest registry.lab.example.com/openshiftdemos/gogs:0.9.97
[root@master ditto]# docker push registry.lab.example.com/openshiftdemos/gogs:0.9.97
The push refers to a repository [registry.lab.example.com/openshiftdemos/gogs]
b93687778caa: Pushed
126a150d0743: Pushed
addf85492fbe: Pushed
34e7b85d83e4: Pushed
0.9.97: digest: sha256:483a06aac04eb028ae1ddbd294954ba28d7c16b32fc5fca495f37d8e6c9295de size: 1160
2.4 根据template创建app
[root@master ditto]# oc new-app --template=gogs --param=HOSTNAME=gogs.apps.lab.example.com
--> Deploying template "openshift/gogs" to project dittogogs---------The Gogs git server (https://gogs.io/)* With parameters:* APPLICATION_NAME=gogs* HOSTNAME=gogs.apps.lab.example.com* GOGS_VOLUME_CAPACITY=1Gi* DB_VOLUME_CAPACITY=2Gi* Database Username=gogs* Database Password=gogs* Database Name=gogs* Database Admin Password=605BtU1L # generated* Maximum Database Connections=100* Shared Buffer Amount=12MB* Gogs Version=0.9.97* Installation lock=true* Skip TLS verification on webhooks=false--> Creating resources ...persistentvolume "gogs-postgres-data" createdpersistentvolume "gogs-data" createdserviceaccount "gogs" createdservice "gogs-postgresql" createddeploymentconfig "gogs-postgresql" createdservice "gogs" createdroute "gogs" createddeploymentconfig "gogs" createdimagestream "gogs" createdpersistentvolumeclaim "gogs-data" createdpersistentvolumeclaim "gogs-postgres-data" createdconfigmap "gogs-config" created
--> SuccessAccess your application via route 'gogs.apps.lab.example.com'Run 'oc status' to view your app.
2.5 创建git仓库
2.6 git clone
[root@master ditto]# git clone http://gogs.apps.lab.example.com/salvo/ex280.git
Cloning into 'ex280'...
warning: You appear to have cloned an empty repository.
[root@master ditto]# cd ex280/
[root@master ex280]# vim README.md
[root@master ex280]# cat README.md
faber est quisque fortunae suae
[root@master ex280]# git add .
[root@master ex280]# git commit -m 8
[master (root-commit) 5f37403] 81 file changed, 1 insertion(+)create mode 100644 README.md
[root@master ex280]# git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
Username for 'http://gogs.apps.lab.example.com': salvo
Password for 'http://salvo@gogs.apps.lab.example.com':redhat
To http://gogs.apps.lab.example.com/salvo/ex280.git* [new branch] master -> master
3. 确认
刷新git仓库,可以看到README.md已经被提交