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.2.10. 在构建中使用红帽订阅
按照以下小节中的内容在 OpenShift Container Platform 上运行授权构建。
2.10.1. 为红帽通用基础镜像创建镜像流标签 复制链接链接已复制到粘贴板!
要在构建中使用红帽订阅,您可以创建一个镜像流标签来引用通用基础镜像(UBI)。
要让 UBI 在集群中的每个项目中都可用,您需要将镜像流标签添加到 openshift
命名空间中。否则,若要使其在一个特定项目中可用,您要将镜像流标签添加到该项目。
以这种方式使用镜像流标签的好处是,根据安装 pull secret 中的 registry.redhat.io
凭证授予对 UBI 的访问权限,而不会向其他用户公开 pull secret。这比要求每个开发人员使用项目中的 registry.redhat.io
凭证安装 pull secret 更为方便。
流程
要在
openshift
命名空间中创建ImageStreamTag
,因此所有项目中的开发人员可使用它,请输入:oc tag --source=docker registry.redhat.io/ubi7/ubi:latest ubi:latest -n openshift
$ oc tag --source=docker registry.redhat.io/ubi7/ubi:latest ubi:latest -n openshift
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 要在单个项目中创建
ImageStreamTag
,请输入:oc tag --source=docker registry.redhat.io/ubi7/ubi:latest ubi:latest
$ oc tag --source=docker registry.redhat.io/ubi7/ubi:latest ubi:latest
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.10.2. 将订阅权利添加为构建 secret 复制链接链接已复制到粘贴板!
使用红帽订阅安装内容的构建需要包括做为一个构件 secret 的权利密钥。
先决条件
您必须可通过您的订阅访问红帽权利。Insights Operator 会自动创建授权 secret。
使用 Red Hat Enterprise Linux(RHEL)7 执行 Entitlement Build 时,在运行任何 yum
命令前,必须在 Dockerfile 中包含以下指令:
RUN rm /etc/rhsm-host
RUN rm /etc/rhsm-host
流程
在构建配置中将 etc-pki-entitlement secret 添加为构建输入:
source: secrets: - secret: name: etc-pki-entitlement destinationDir: etc-pki-entitlement
source: secrets: - secret: name: etc-pki-entitlement destinationDir: etc-pki-entitlement
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.10.3. 使用 Subscription Manager 运行构建 复制链接链接已复制到粘贴板!
2.10.3.1. 使用 Subscription Manager 执行 Docker 构建 复制链接链接已复制到粘贴板!
Docker 策略构建可以使用 Subscription Manager 来安装订阅内容。
先决条件
必须添加授权密钥、Subscription Manager 配置和 Subscription Manager 证书颁发机构,作为构建输入。
流程
使用以下示例 Dockerfile 来通过 Subscription Manager 安装内容:
2.10.4. 使用 Red Hat Satellite 订阅运行构建 复制链接链接已复制到粘贴板!
2.10.4.1. 将 Red Hat Satellite 配置添加到构建中 复制链接链接已复制到粘贴板!
使用 Red Hat Satellite 安装内容的构建必须提供适当的配置,以便从 Satellite 存储库获取内容。
先决条件
您必须提供或创建与
yum
兼容的存储库配置文件,该文件将从 Satellite 实例下载内容。仓库配置示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
流程
创建包含 Satellite 存储库配置文件的
ConfigMap
:oc create configmap yum-repos-d --from-file /path/to/satellite.repo
$ oc create configmap yum-repos-d --from-file /path/to/satellite.repo
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在
BuildConfig
中添加 Satellite 存储库配置:source: configMaps: - configMap: name: yum-repos-d destinationDir: yum.repos.d
source: configMaps: - configMap: name: yum-repos-d destinationDir: yum.repos.d
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.10.4.2. 使用 Red Hat Satellite 订阅构建 Docker 复制链接链接已复制到粘贴板!
Docker 策略构建可以使用 Red Hat Satellite 软件仓库来安装订阅内容。
先决条件
- 必须将权利密钥和 Satellite 存储库配置添加为构建输入。
流程
使用以下示例 Dockerfile 来通过 Satellite 安装内容:
- 1
- 如果使用
enabled=1
在构建中添加 Satellite 配置失败,请将RUN sed -i".org" -e "s#^enabled=1#enabled=0#g" /etc/yum/pluginconf.d/subscription-manager.conf
添加到 Dockerfile。