7. 接下来, 我们要给我们的集群添加 GlusterFS 的 永久存储( Persistent Volume )
# 首先, 给 gluster 创建 service
# 端口是会被忽略的, 所以写 1 就可以
$ oc create -f gluster-svc.yaml
apiVersion: v1 kind: Service metadata: name: glusterfs-cluster spec: ports: - port: 1
# 然后, 创建 endpoint
$ oc create -f gluster-endpoint.yaml
apiVersion: v1 kind: Endpoints metadata: name: glusterfs-cluster subsets: - addresses: - ip: 192.168.1.201 ports: - port: 1 - addresses: - ip: 192.168.1.202 ports: - port: 1 - addresses: - ip: 192.168.1.203 ports: - port: 1
# 最后, 创建 pv
$ oc create -f gluster-volume.yaml
apiVersion: v1 kind: PersistentVolume metadata: name: glusterfs-volume spec: capacity: storage: 60Gi accessModes: - ReadWriteMany glusterfs: endpoints: glusterfs-cluster path: openshift readOnly: false persistentVolumeReclaimPolicy: Retain
# 查看一下 PV
$ oc get pv
NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE
glusterfs-volume 60Gi RWX Retain Available 2m
8. 我们给 docker-registry 创建一个 pvc
$ oc create -f docker-registry-pvc.yaml
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: docker-registry-pvc spec: resources: requests: storage: 10Gi accessModes: - ReadWriteMany volumeName: glusterfs-volume
# 查看一下 pvc
$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE
docker-registry-pvc Bound glusterfs-volume 60Gi RWX 4s
# 编辑一下 dc/docker-registry, 使用 pvc
$ oc edit dc docker-registry
...... volumes: - emptyDir: {} - persistentVolumeClaim: claimName: docker-registry-pvc name: registry-storage ......
至此, OpenShift Origin 就部署完成了