创建PV
{ "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.json
{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "docker-registry-claim" }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "5Gi" } } } }
# oc create -f pvc.json
docker-registry 仓库持久化案例
[root@master ~]# oc project default Already on project "default" on server "https://master:8443".
查看现有数据大小
[root@master ~]# oc rsh docker-registry-7-w19hb 'du' '-sh' '/registry' 568 M /registry
备份数据
[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 .
关联数据卷
[root@master ~]# oc volume dc/docker-registry --remove --name=registry-storage -t pvc --claim-name=docker-registry-claim --overwrite deploymentconfigs/docker-registry
#触发生效
[root@master mnt]# oc delete pod docker-registry-7-w19hb