RHCA之路—EX280(2)
1. 题目
Associate the share named /exports/registry to the built-in registry running within your OpenShift Enterprise instance so that it will be used for permanent storage
Use exam-registry-volume for the volume name and exam-registry-claim for the claim name
You can find sample YAML files on http://materials.example.com/exam280/storage/pv.yaml
(Note: This task needs to be solved before any applications are created)
2. 解题
2.1 获取pv模板文件
[root@master ~]# wget http://materials.example.com/exam280/storage/pv.yaml
--2023-09-04 14:53:08-- http://materials.example.com/exam280/storage/pv.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: 230
Saving to: ‘pv.yaml’
100%[===========================================================================================================>] 230 --.-K/s in 0s
2023-09-04 14:53:08 (47.0 MB/s) - ‘pv.yaml’ saved [230/230]
2.2 编辑pv模板文件
[root@master ~]# vim pv.yaml
按题意修改4,11行内容
apiVersion: v1
kind: PersistentVolume
metadata:
name: exam-registry-volume
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
nfs:
path: /exports/registry
server: services.lab.example.com
persistentVolumeReclaimPolicy: Recycle
2.3 生效pv
[root@master ~]# oc create -f pv.yaml
persistentvolume "exam-registry-volume" created
2.4 将pv挂载给dc/docker-registry
[root@master ~]# oc set volume dc/docker-registry --add --name=registry-storage -t pvc \
--claim-name=exam-registry-claim --claim-size=5G --overwrite
persistentvolumeclaims/exam-registry-claim
deploymentconfig "docker-registry" updated
3. 确认
3.1 确认pv被创建
[root@master ~]# oc get pv |grep exam-registry-volume
exam-registry-volume 5Gi RWO Recycle Bound default/exam-registry-claim 4m
3.2 确认pvc被创建
[root@master ~]# oc get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
exam-registry-claim Bound exam-registry-volume 5Gi RWO 2m
3.3 确认pvc被正常挂载
[root@master ~]# oc describe dc docker-registry |grep -A 2 registry-storage
/registry from registry-storage (rw)
Volumes:
registry-certificates:
--
registry-storage:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: exam-registry-claim
3.4 确认pod状态正常
[root@master ~]# oc get pod |grep docker-registry|grep -i running
docker-registry-2-4pcwl 1/1 Running 0 5m