1. 程式人生 > >OPENSHIFT-280-2-永久儲存

OPENSHIFT-280-2-永久儲存

0.lab deploy-registry setup進行初始環境檢查和配置。showmount -e檢視掛載目錄的情況。

[[email protected] ~]$ 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.
[[email protected] ~]# 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指定使用哪個專案。

[[email protected] ~]$ 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.
[[email protected] ~]$ oc project
Using project "default" on server "https://master.lab.example.com:8443".
[[email protected] ~]$ 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資源詳細資訊。

[[email protected] ~]$ 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
[[email protected] ~]$ oc apply -f DO280/labs/deploy-registry/registry-volume.yml
persistentvolume "registry-volume" created
[[email protected] ~]$ oc get pv
NAME              CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS      CLAIM                      REASON    AGE
registry-volume   15Gi       RWO           Recycle         Available   default/registry-pvclaim             24s

[[email protected] ~]$ 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資源控制器詳細資訊。
[[email protected] ~]$ 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
[[email protected] ~]$ oc get pvc
NAME               STATUS    VOLUME            CAPACITY   ACCESSMODES   AGE
registry-pvclaim   Bound     registry-volume   15Gi       RWO           23s

[email protected] ~]$ 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.