OpenShift nfs 持久化

建立PVdocker

{
    "apiVersion": "v1",
    "kind": "PersistentVolume",
    "metadata": {
        "name": "pv0001"
    },
    "spec": {
        "capacity": {
            "storage": "100Gi"
        },
        "accessModes": [
            "ReadWriteOnce"
        ],
        "nfs": {
            "path": "/volume1/server/oc",
            "server": "192.168.4.245"
        },
        "persistentVolumeReclaimPolicy": "Retain"
    }
}

# oc create -f pv.jsonjson

{
    "apiVersion": "v1",
    "kind": "PersistentVolumeClaim",
    "metadata": {
        "name": "docker-registry-claim"
    },
    "spec": {
        "accessModes": [
            "ReadWriteOnce"
        ],
        "resources": {
            "requests": {
                "storage": "5Gi"
            }
        }
    }
}

 

# oc create -f pvc.jsonapi

docker-registry 倉庫持久化案例spa

[root@master ~]# oc project default 
Already on project "default" on server "https://master:8443".

 

查看現有數據大小code

[root@master ~]# oc rsh docker-registry-7-w19hb 'du' '-sh' '/registry'
568 M    /registry

備份數據server

[root@master ~]# mount -t nfs 192.168.4.245:/volume1/server/oc /mnt/
[root@master ~]# cd /mnt/
[root@master mnt]# oc rsync docker-registry-7-w19hb:/registry .

 

關聯數據卷blog

[root@master ~]# oc volume dc/docker-registry --remove --name=registry-storage -t pvc --claim-name=docker-registry-claim --overwrite deploymentconfigs/docker-registry

#觸發生效ci

[root@master mnt]# oc delete pod docker-registry-7-w19hb
相關文章
相關標籤/搜索