0.lab deploy-registry setup进行初始环境检查和配置。showmount -e查看挂载目录的情况。
[student@workstation ~]$ lab deploy-registry setup
Setting up master for lab exercise work:
· Check that master host is reachable......................... SUCCESS
· Check that OpenShift master service is running.............. SUCCESS
· Check that node1 is reachable............................... SUCCESS
· Check that node2 is reachable............................... SUCCESS
· Check that OpenShift node service is running on node1....... SUCCESS
· Check that OpenShift node service is running on node2....... SUCCESS
Downloading files for Guided Exercise: Creating a Persistent Registry
· Downloading starter project................................. SUCCESS
· Downloading solution project................................ SUCCESS
Download successful.
[root@master ~]# showmount -e
Export list for master.lab.example.com:
/exports/logging-es-ops *
/exports/logging-es *
/exports/metrics *
/exports/registry *
1.oc login -u admin -p redhat https://master.lab.example.com:8443使用管理员账号登陆。 oc project查看目前使用的项目名称。oc project default指定使用哪个项目。
[student@workstation ~]$ oc login -u admin -p redhat https://master.lab.example.com:8443
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y
Login successful.
You have access to the following projects and can switch between them with 'oc project <projectname>':
* default
kube-system
logging
management-infra
openshift
openshift-infra
Using project "default".
Welcome! See 'oc help' to get started.
[student@workstation ~]$ oc project
Using project "default" on server "https://master.lab.example.com:8443".
[student@workstation ~]$ oc project default
Already on project "default" on server "https://master.lab.example.com:8443".
2.cat DO280/labs/deploy-registry/registry-volume.yml查看PersistentVolume资源文件,nfs:指明挂载的server:和path:,storage: 15Gi指明资源的大小,accessModes:指明访问模式,claimRef:指明使用的namespace: 和name:。oc apply -f DO280/labs/deploy-registry/registry-volume.yml声明资源。oc get pv获取PersistentVolume资源信息。oc describe pv registry-volume获取PersistentVolume资源详细信息。
[student@workstation ~]$ cat DO280/labs/deploy-registry/registry-volume.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: registry-volume
spec:
capacity:
storage: 15Gi
accessModes:
- ReadWriteOnce
nfs:
path: /exports/registry
server: master.lab.example.com
persistentVolumeReclaimPolicy: Recycle
claimRef:
name: registry-pvclaim
namespace: default
[student@workstation ~]$ oc apply -f DO280/labs/deploy-registry/registry-volume.yml
persistentvolume "registry-volume" created
[student@workstation ~]$ oc get pv
NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM REASON AGE
registry-volume 15Gi RWO Recycle Available default/registry-pvclaim 24s
[student@workstation ~]$ oc describe pv registry-volume
Name: registry-volume
Labels: <none>
StorageClass:
Status: Bound
Claim: default/registry-pvclaim
Reclaim Policy: Recycle
Access Modes: RWO
Capacity: 15Gi
Message:
Source:
Type: NFS (an NFS mount that lasts the lifetime of a pod)
Server: master.lab.example.com
Path: /exports/registry
ReadOnly: false
No events.
3.oc set volume dc/docker-registry -n default --add --overwrite --name=registry-storage -t pvc --claim-name=registry-pvclaim --claim-size=15Gi --claim-mode="ReadWriteOnce"设置pvc资源控制器信息。oc get pvc查看pvc资源控制器信息。oc describe pvc registry-pvclaim查看pvc资源控制器详细信息。
[student@workstation ~]$ oc set volume dc/docker-registry -n default --add --overwrite --name=registry-storage -t pvc --claim-name=registry-pvclaim --claim-size=15Gi --claim-mode="ReadWriteOnce"
persistentvolumeclaims/registry-pvclaim
deploymentconfig "docker-registry" updated
[student@workstation ~]$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
registry-pvclaim Bound registry-volume 15Gi RWO 23s
student@workstation ~]$ oc describe pvc registry-pvclaim
Name: registry-pvclaim
Namespace: default
StorageClass:
Status: Bound
Volume: registry-volume
Labels: <none>
Capacity: 15Gi
Access Modes: RWO
No events.