部署持久化镜像仓库

Posted hixiaowei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了部署持久化镜像仓库相关的知识,希望对你有一定的参考价值。

 1.将/registry数据导出
mkdir /export/registry_bak
oc get pods
docker-registry-2-4qcr6
[[email protected] registry_bak]# oc rsync docker-registry-1-91s28:/registry .
2.使用NFS,创建pv和pvc
 mkdir -p /export/pv/docker_registry
yum install nfs-utils rpcbind -y
chown -R nfsnobody:nfsnobody /export/pv/
systemctl restart rpcbind
[[email protected] ~]# systemctl enable rpcbind
exportfs -r
systemctl restart nfs-server
 echo "/export/pv/docker_registry/  *(rw,sync,all_squash)" >> /etc/exports
 mkdir /opt/pv/
[[email protected] ~]# setenforce 0
3.创建pv
[[email protected] pv]# cat pv.json 
{
  "apiVersion": "v1",
  "kind": "PersistentVolume",
  "metadata": {
    "name": "registrypv"
  },
  "spec": {
    "capacity": {
      "storage": "100Gi"
    },
    "accessModes": [ "ReadWriteOnce" ],
    "nfs": {
      "path": "/export/pv/docker_registry",
      "server": "192.168.10.110"
    },
    "persistentVolumeReclaimPolicy": "Retain"
  }
}

[[email protected] pv]# oc create -f pv.json 
persistentvolume "registrypv" created
给pv添加标签
[[email protected] pv]# oc label pv registrypv disktype=registry
4.创建PVC
[[email protected] pv]# cat registry_pvc.json 
{
  "apiVersion": "v1",
  "kind": "PersistentVolumeClaim",
  "metadata": {
    "name": "docker-registry-claim"
  },
  "spec": {
    "accessModes": [
      "ReadWriteOnce"
    ],
    "selector": {
      "matchLabels": {
        "disktype": "registry"
      }
    },
    "resources": {
      "requests": {
        "storage": "100Gi"
      }
    }
  }
}

[[email protected] pv]# oc create -f registry_pvc.json 
persistentvolumeclaim "docker-registry-claim" created
6.将备份的数据恢复到创建的NFS目录 #########################关键地点---registry目录下的./* -->
[[email protected] ~]# cd /export/
[[email protected] export]# mv registry_bak/registry/* pv/docker_registry/
[[email protected] export]# ls pv/docker_registry/
docker
[[email protected] export]# chown -R nfsnobody:nfsnobody /export/
7.为registry添加持久化卷请求,并与挂载点关联
oc volumes dc/docker-registry --add --name=registry-storage -t pvc --claim-name=docker-registry-claim --overwrite
参考:https://www.cnblogs.com/dukuan/p/8735017.html










以上是关于部署持久化镜像仓库的主要内容,如果未能解决你的问题,请参考以下文章

docker私有镜像仓库搭建和镜像删除

五十四.自定义镜像及仓库持久化存储 Docker网络架构

44_自定义镜像及仓库持久化存储 Docker网络架构

离线手动部署docker镜像仓库——harbor仓库

离线手动部署docker镜像仓库——harbor仓库

利用阿里云ECS部署自己的私有harbor镜像仓库