OpenShift 4 - 配置OpenShift可使用的外部Image Registry和Mirror Registry
《OpenShift 4.x HOL教程汇总》
文章目录
- 概念
- 配置OpenShift的Image Registry
- 配置OpenShift的Mirror Image Registry
- 参考
概念
OpenShift可访问的Image Registy包括其自身内部的Image Registry和其外部的Image Registry,而外部的Image Registry又可分为运行在远端的Image Registry,以及为了加速远端访问而运行在本地(或近地的)Mirror Image Registry。Mirror Image Registry除了可以用来加速访问外部Image外,我们在离线安装OpenShift的时候也会用到它。
以上OpenShift用到的Image Registry配置是以对象的方式存放在Etcd中。当OpenShift的Machine Config Operator发现这些对象变化后会自动将其推送到每个Node并写入 /etc/containers/registries.conf 文件,OpenShift然后会重启对应的Node使配置生效。
配置OpenShift的Image Registry
OpenShift 4把它能访问到的外部Registry的配置信息是保存在“image.config.openshift.io/cluster”对象中。当OpenShift的Machine Config Operator(MCO)发现image.config.openshift.io配置变化后,会将最新配置对送到所有Node并写入 /etc/containers/registries.conf 文件,然后重启对应的Node使配置生效。
OpenShift使用一个名为cluster的image.config.openshift.io对象管理其能访问到的Image Registry目标和策略。
$ oc get image.config.openshift.io
NAME AGE
cluster 12d
查看OpenShift可以访问到Registry的配置,其中“External Registry Hostnames”和“Internal Registry Hostname”定义了外部和内部Registry。
$ oc describe image.config.openshift.io cluster
Name: cluster
Namespace:
Labels: <none>
Annotations: release.openshift.io/create-only: true
API Version: config.openshift.io/v1
Kind: Image
Metadata:Creation Timestamp: 2020-07-18T09:54:27ZGeneration: 1Resource Version: 25273Self Link: /apis/config.openshift.io/v1/images/clusterUID: c94ebed4-684a-4c98-86aa-658a8685ef79
Spec:
Status:External Registry Hostnames:default-route-openshift-image-registry.apps.cluster-beijing-959a.beijing-959a.example.opentlc.comInternal Registry Hostname: image-registry.openshift-image-registry.svc:5000
Events: <none>
上面只是Registry的配置信息,其中OpenShift内部的Registry是通过以下的Cluster Operator运行的。
$ oc get co image-registry
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE
image-registry 4.5.4 True False False 2d2h
如果要修改OpenShift可访问的Registry目标,可先编辑image.config.openshift.io/cluster对象:
$ oc edit image.config.openshift.io/cluster
增加“registrySources”部分内容。
spec:registrySources:insecureRegistries:- ocr.example.comallowedRegistries:- quay.io- ocr.example.com
保存后OpenShift会自动通过MCO将最新的配置同步到各个节点。可以从Node的Events查看节点的重启过程。
如果需要查看一个Node的Registry配置,可先通过debug进入该Node,然后查看/etc/containers/registries.conf(该文件是podman可以访问的registry的配置),确认最新的Registry配置已经加进去了。(如果使用非完整名称的Image,podman会去由“unqualified-search-registries”定义的Registry查找该镜像)
$ oc debug node/<NODE-NAME>
sh-4.2# chroot /host
sh-4.2# cat /etc/containers/registries.conf
unqualified-search-registries = ['registry.access.redhat.com', 'docker.io']
[[registry]]prefix = ""location = "ocr.example.com"insecure = true[[registry]]prefix = ""location = "quay.io"allowed = true
配置OpenShift的Mirror Image Registry
在一个受限的网络中(或访问远程Image Registry的网速比较慢),可以为OpenShift使用的外部Image Registry建一个Mirror,以加速OpenShift访问远程Registry上Image。Registry Mirror可以是运行在自己本地(或区域)的Docker Distribution、Quay等提供的Registry服务。
Image Registry Mirror的配置信息是保存在OpenShift集群范围的ImageContentSourcePolicy对象。当OpenShift的Machine Config Operator(MCO)发现ImageContentSourcePolicy配置变化后,会将最新配置对送到所有Node并写入 /etc/containers/registries.conf 文件,然后重启对应的Node使配置生效。
注意:本文只对说明如何将Mirror Image Registry的配置加到OpenShift中,而部署一套Mirror Image Registry可参见《OpenShift 4 - 部署Mirror Registry》。
- 创建如下内容的registryrepomirror.yaml文件,其中为“registry.access.redhat.com/ubi8/ubi-minimal”镜像提供了2个Mirror,一个是“ example.io/example/ubi-minimal”,另一个是“example.com/example/ubi-minimal”,OpenShift会按照顺序访问Mirror的。
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:name: ubi8repo
spec:repositoryDigestMirrors:- mirrors:- example.io/example/ubi-minimalsource: registry.access.redhat.com/ubi8/ubi-minimal- mirrors:- example.com/example/ubi-minimalsource: registry.access.redhat.com/ubi8/ubi-minimal
- 创建ImageContentSourcePolicy对象。
$ oc create -f registryrepomirror.yaml
- 查看Node的状态,确认Node会重启以使得配置生效。
$ oc get node
NAME STATUS ROLES AGE VERSION
ip-10-0-131-190.ap-southeast-1.compute.internal Ready master 13d v1.18.3+012b3ec
ip-10-0-141-25.ap-southeast-1.compute.internal Readyy,SchedulingDisabled worker 13d v1.18.3+012b3ec
ip-10-0-165-133.ap-southeast-1.compute.internal Ready master 13d v1.18.3+012b3ec
ip-10-0-174-85.ap-southeast-1.compute.internal Ready worker 13d v1.18.3+012b3ec
ip-10-0-216-155.ap-southeast-1.compute.internal Ready master 13d v1.18.3+012b3ec
- 确认配置已经更新,有2个registry.mirror的配置。
$ oc debug node <NODE-NAME>
sh-4.2# chroot /host
sh-4.4# cat /etc/containers/registries.conf
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"][[registry]]prefix = ""location = "registry.access.redhat.com/ubi8/ubi-minimal"mirror-by-digest-only = true[[registry.mirror]]location = "example.com/example/ubi-minimal"[[registry.mirror]]location = "example.io/example/ubi-minimal"[[registry]]prefix = ""location = "ocr.example.com"insecure = true[[registry]]prefix = ""location = "untrusted.com"blocked = true
- 在Node内部发起对远程镜像“registry.access.redhat.com/ubi8/ubi-minimal”的访问,通过日志确认系统是从Mirror中获得该Image的。
sh-4.2# podman pull --log-level=debug registry.access.redhat.com/ubi8/ubi-minimal
参考
- https://computingforgeeks.com/how-to-setup-red-hat-quay-registry-on-centos-rhel/
- https://access.redhat.com/documentation/zh-cn/openshift_container_platform/4.7/html-single/images/index#installation-restricted-network-samples_samples-operator-alt-registry
- https://access.redhat.com/documentation/zh-cn/openshift_container_platform/4.7/html-single/images/index#images-configuration-parameters_image-configuration
- https://computingforgeeks.com/allow-insecure-registries-in-openshift-okd-4-cluster/
- https://rhthsa.github.io/openshift-demo/build-with-oc.html
- https://docs.openshift.com/container-platform/4.7/post_installation_configuration/preparing-for-users.html#images-configuration-shortname_post-install-preparing-for-users
- https://www.redhat.com/sysadmin/manage-container-registries
OpenShift 4 - 配置OpenShift可使用的外部Image Registry和Mirror Registry相关推荐
- OpenShift 4 - 配置OpenShift集群日志环境EFK
<OpenShift 4.x HOL教程汇总> 说明:本文已经在OpenShift 4.6环境中验证 文章目录 安装Elastic Search Operator 安装Cluster Lo ...
- OpenShift 4 - 部署Mirror Registry并复制Image
<OpenShift 4.x HOL教程汇总> 文章目录 安装Mirror Registry运行环境 复制Image到Mirror Registry 准备登陆认证文件 生成远程Regist ...
- OpenShift 4 之配置Insecure Registry和Blocked Registry镜像源
OpenShift 4安装后缺省是将registry.access.redhat.com和docker.io作为容器镜像源.我们可以通过修改配置为OpenShift 4添加其他镜像源,例如Insecu ...
- OpenShift 4 - 向OpenShift内部Image Registry推送Image
<OpenShift 4.x HOL教程汇总> 说明:本文已经在OpenShift 4.6环境中验证 文章目录 了解OpenShift内部Image Registry 向内部Image R ...
- OpenShift 4 概念 - OpenShift是如何通过ImageStream访问Image的
<OpenShift 4.x HOL教程汇总> 说明:本文已经在OpenShift 4.6环境中验证 文章目录 ImageStream基本概念 Internal Image 和 Exter ...
- openshift java_在OpenShift上部署Java应用程序的快速指南
在本文中,我将向您展示如何在OpenShift(Minishift)上部署应用程序,将它们与其中暴露的其他服务连接起来,还是使用由OpenShift提供的其他一些有趣的部署功能.OpenShift构建 ...
- OpenShift 4 Hands-on Lab (12) 通过 KubeFed 配置 OpenShift 联邦集群
<OpenShift 4.x HOL教程汇总> 文章目录 Kubernetes Federation 准备环境 OpenShift集群环境 配置客户端环境 安装配置KubeFed Oper ...
- 配置OpenShift 4 单机版环境 - CodeReady Container
<OpenShift 4.x HOL教程汇总> 注意:对应OpenShift 4.6的最新版CRC 已经不支持Virtualbox了,最新CRC的说明文档请参见:<OpenShift ...
- OpenShift 4 - 配置本地Neuxs Registry并通过Pull Secret访问
<OpenShift 4.x HOL教程汇总> 说明:本文已经在OpenShift 4.6环境中验证 文章目录 部署Neuxs Registry 更新OpenShift的Pull Secr ...
最新文章
- MongoDB修改删除数据
- DMG MORI AKTIENGESELLSCHAFT
- jsp判断字符串相等_最长回文字符串三种解法
- Hadoop的TextInputFormat的作用,如何自定义实现的
- C++primer第九章 顺序容器 9.3 顺序容器操作
- 模拟退火算法解决TSP问题
- 面经——小马智行2022秋招嵌入式
- mysql grant权限分配(转)。
- 计算机校准颜色,显示器颜色校正,教您怎么校准显示器颜色
- wifi技术扫盲-MIMO
- 操作系统进程同步之吸烟者问题,C语言实现
- 雅加达建筑_雅加达EE:干净的板岩
- 【kaggle比赛记录】SHOPPE商品分类多模态分析
- 我裂了,换领导后,竟然每天都要写日报
- 无人机通信无线电开放频段
- php get defined,php中get_defined_constants函数用法实例分析
- WOL网络唤醒远程开机的关键步骤,魔术唤醒一步都不能少!
- 【C++】二分法查找某个数字在数组中的下标
- 副业怎么样通过手游达到月入过万
- visio跨职能流程图带区背景及大小及改变格式 (转)
热门文章
- mysql 处理数据_MySQL数据库,如何处理重复的数据?
- django orm关联查询_Django ORM 聚合查询和分组查询实现详解
- idea js检查太卡_IntelliJ IDEA抑制、禁用与启用检查
- mysql通过日志恢复数据_mysql通过binlog日志来恢复数据
- oracle12输出文件性能慢,输出选项 (Oracle Solaris Studio 12.2:性能分析器)
- github 码云 获取_开发记录篇使用VS2019管理github项目
- ajax上送src,使用script的src实现跨域和类似ajax效果
- 核心期刊 计算机应用与软件,计算机应用与软件 统计源期刊北大核心期刊
- 设计灵感|各种孟菲斯风格海报,让你眼花缭乱
- 根据进程名判断该进程是否存在(C++)