This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.3.4. 为 vSphere 配置 registry
3.4.1. 安装过程中删除的镜像 registry 复制链接链接已复制到粘贴板!
在不提供可共享对象存储的平台上,OpenShift Image Registry Operator bootstraps 本身的状态是 Removed。这允许 openshift-installer 在这些平台类型上完成安装。
将 ManagementState Image Registry Operator 配置从 Removed 改为 Managed。
Prometheus 控制台提供了一个 ImageRegistryRemoved 警报,例如:
"Image Registry has been removed.ImageStreamTags, BuildConfigs and DeploymentConfigs which reference ImageStreamTags may not work as expected.Please configure storage and update the config to Managed state by editing configs.imageregistry.operator.openshift.io."
3.4.2. 更改镜像 registry 的管理状态 复制链接链接已复制到粘贴板!
要启动镜像 registry,需要把 Image Registry Operator 配置的 managementState 从 Removed 改为 Managed。
流程
将
ManagementStateImage Registry Operator 配置从Removed改为Managed。例如:oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"managementState":"Managed"}}'$ oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"managementState":"Managed"}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4.2.1. 镜像 registry 存储配置 复制链接链接已复制到粘贴板!
对于不提供默认存储的平台,Image-registry Operator 最初将不可用。安装后,您必须配置 registry 使用的存储,这样 Registry Operator 才可用。
提供了配置 PersistentVolume 的说明,这是生产集群所需要的;也提供了将空目录配置为存储位置的说明,这仅适用于非生产集群。
3.4.3. 为 VMware vSphere 配置 registry 存储 复制链接链接已复制到粘贴板!
作为集群管理员,在安装后需要配置 registry 来使用存储。
先决条件
- 具有 Cluster Administrator 权限
- VMware vSphere上有一个集群。
为集群置备持久性存储。若要部署私有镜像 registry,您的存储必须提供 ReadWriteMany 访问模式。
重要vSphere卷不支持
ReadWriteMany访问模式。您必须使用其他存储后端(例如NFS)来配置 registry 注存储。- 必须有“ 100Gi”容量。
测试显示,在 RHEL 中使用 NFS 服务器作为核心服务的存储后端可能会出现问题。这包括 OpenShift Container Registry 和 Quay,Prometheus 用于监控存储,以及 Elasticsearch 用于日志存储。因此,不推荐使用 RHEL NFS 作为 PV 后端用于核心服务。
市场上的其他 NFS 实现可能没有这些问题。如需了解更多与此问题相关的信息,请联络相关的 NFS 厂商。
流程
为了配置 registry 使用存储,需要修改
configs.imageregistry/cluster资源中的spec.storage.pvc。注意当使用类似 NFS 的共享存储时,强烈建议使用
supplementalGroups策略,即指明安全性上下文的允许补充组,而不是fsGroupID。详情请参考 NFS 组 ID 文档。验证您没有 registry Pod:
oc get pod -n openshift-image-registry
$ oc get pod -n openshift-image-registryCopy to Clipboard Copied! Toggle word wrap Toggle overflow 注意-
如果存储类型为
emptyDIR,则副本数不能超过1。 如果存储类型是
NFS,您必须启用no_wdelay和root_squash挂载选项。例如:cat /etc/exports /mnt/data *(rw,sync,no_wdelay,root_squash,insecure,fsid=0) sh-4.3# exportfs -rv exporting *:/mnt/data
# cat /etc/exports /mnt/data *(rw,sync,no_wdelay,root_squash,insecure,fsid=0) sh-4.3# exportfs -rv exporting *:/mnt/dataCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
如果存储类型为
检查 registry 配置:
oc edit configs.imageregistry.operator.openshift.io
$ oc edit configs.imageregistry.operator.openshift.io storage: pvc: claim:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将
claim字段留空以允许自动创建一个image-registry-storagePVC。可选:在 PV 中添加新存储类:
创建 PV:
oc create -f -
$ oc create -f -Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pv
$ oc get pvCopy to Clipboard Copied! Toggle word wrap Toggle overflow 创建 PVC:
oc create -n openshift-image-registry -f -
$ oc create -n openshift-image-registry -f -Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get pvc -n openshift-image-registry
$ oc get pvc -n openshift-image-registryCopy to Clipboard Copied! Toggle word wrap Toggle overflow 最后,添加 PVC 的名称:
oc edit configs.imageregistry.operator.openshift.io -o yaml
$ oc edit configs.imageregistry.operator.openshift.io -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow storage: pvc: claim: image-registry-pvcstorage: pvc: claim: image-registry-pvc1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 通过创建自定义 PVC,您可以将
claim字段留空以用于默认自动创建image-registry-storagePVC。
检查
clusteroperator的状态:oc get clusteroperator image-registry
$ oc get clusteroperator image-registryCopy to Clipboard Copied! Toggle word wrap Toggle overflow
有关使用补充组来处理 NFS 访问的详情,请参阅 组 ID。
3.4.4. 在非生产集群中配置镜像 registry 存储 复制链接链接已复制到粘贴板!
您必须为 Image Registry Operator 配置存储。对于非生产集群,您可以将镜像 registry 设置为空目录。如果您这样做,重启 registry 后会丢失所有镜像。
流程
将镜像 registry 存储设置为空目录:
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'$ oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 警告仅可为非生产集群配置这个选项。
如果在 Image Registry Operator 初始化其组件前运行此命令,
oc patch命令会失败并显示以下错误:Error from server (NotFound): configs.imageregistry.operator.openshift.io "cluster" not found
Error from server (NotFound): configs.imageregistry.operator.openshift.io "cluster" not foundCopy to Clipboard Copied! Toggle word wrap Toggle overflow 等待几分钟,然后再次运行该命令。
3.4.5. 其它资源 复制链接链接已复制到粘贴板!
有关为 vSphere 配置 registry 存储的详情,请参考推荐的可配置存储技术。