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.6. 为裸机配置 registry
3.6.1. 安装过程中删除的镜像 registry 复制链接链接已复制到粘贴板!
在不提供可共享对象存储的平台上,OpenShift Image Registry Operator bootstraps 本身为 Removed
。这允许 openshift-installer
在这些平台类型上完成安装。
安装后,您必须编辑 Image Registry Operator 配置,将 managementState
从 Removed
切换到 Managed
。
Prometheus 控制台提供了一个 ImageRegistryRemoved
警报,例如:
"镜像注册表已被删除。镜像流标签、
BuildConfig 和
DeploymentConfig,
引用 ImageStreamTags
可能无法正常工作。Please configure storage and update the config to Managed
state by editing configs.imageregistry.operator.openshift.io."
3.6.2. 更改镜像 registry 的管理状态 复制链接链接已复制到粘贴板!
要启动镜像 registry,您必须将 Image Registry Operator 配置的 managementState
从 Removed 改为
Managed
。
流程
将
managementState
Image 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.6.3. 镜像 registry 存储配置 复制链接链接已复制到粘贴板!
对于不提供默认存储的平台,Image Registry Operator 最初不可用。安装后,您必须将 registry 配置为使用存储,以便 Registry Operator 可用。
显示配置生产集群所需的持久性卷的说明。如果适用,显示有关将空目录配置为存储位置的说明,这仅适用于非生产集群。
提供了在升级过程中使用 Recreate
rollout 策略来允许镜像 registry 使用块存储类型的说明。
3.6.4. 为裸机和其他手动安装配置 registry 存储 复制链接链接已复制到粘贴板!
作为集群管理员,在安装后需要配置 registry 来使用存储。
先决条件
-
您可以使用具有
cluster-admin
角色的用户访问集群。 - 您有一个使用手动置备的 Red Hat Enterprise Linux CoreOS(RHCOS)节点(如裸机)的集群。
已为集群置备了持久性存储,如 Red Hat OpenShift Container Storage。
重要当您只有一个副本时,OpenShift Container Platform 支持对镜像 registry 存储的
ReadWriteOnce
访问。ReadWriteOnce
访问还要求 registry 使用Recreate
rollout 策略。要部署支持高可用性的镜像 registry,需要两个或多个副本,ReadWriteMany
访问。- 必须具有 100Gi 容量。
流程
要将 registry 配置为使用存储,修改
configs.imageregistry/cluster
资源中的spec.storage.pvc
。注意使用共享存储时,请查看您的安全设置以防止外部访问。
验证您没有 registry pod:
oc get pod -n openshift-image-registry -l docker-registry=default
$ oc get pod -n openshift-image-registry -l docker-registry=default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
No resourses found in openshift-image-registry namespace
No resourses found in openshift-image-registry namespace
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注意如果您的输出中有一个 registry pod,则不需要继续这个过程。
检查 registry 配置:
oc edit configs.imageregistry.operator.openshift.io
$ oc edit configs.imageregistry.operator.openshift.io
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
storage: pvc: claim:
storage: pvc: claim:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将
claim
字段留空以允许自动创建image-registry-storage
PVC。检查
clusteroperator
状态:oc get clusteroperator image-registry
$ oc get clusteroperator image-registry
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE MESSAGE image-registry 4.9 True False False 6h50m
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE MESSAGE image-registry 4.9 True False False 6h50m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 确保 registry 设置为 managed,以启用镜像的构建和推送。
运行:
oc edit configs.imageregistry/cluster
$ oc edit configs.imageregistry/cluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 然后,更改行
managementState: Removed
managementState: Removed
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 至
managementState: Managed
managementState: Managed
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.6.5. 在非生产集群中为镜像 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 found
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 等待几分钟,然后再次运行 命令。
3.6.6. 配置块 registry 存储 复制链接链接已复制到粘贴板!
要允许镜像 registry 在作为集群管理员升级过程中使用块存储类型,您可以使用 Recreate rollout 策略
。
支持块存储卷,但不建议将其用于生产环境中的镜像 registry。在块存储上配置 registry 的安装不具有高可用性,因为 registry 无法具有多个副本。
流程
要将镜像 registry 存储设置为块存储类型,对 registry 进行补丁,使其使用
Recreate rollout 策略
,并只使用一个(1
)副本运行:oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"rolloutStrategy":"Recreate","replicas":1}}'
$ oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"rolloutStrategy":"Recreate","replicas":1}}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 为块存储设备置备 PV,并为该卷创建 PVC。请求的块卷使用 ReadWriteOnce(RWO)访问模式。
- 编辑 registry 配置,使其引用正确的 PVC。