$ oc apply -f registry-config.yaml
在断开连接的环境中,托管控制平面的部署与独立的 OpenShift Container Platform 不同。
托管控制平面涉及两个不同的环境
控制平面:位于管理集群中,托管控制平面 Pod 在此处由控制平面操作员运行和管理。
数据平面:位于托管集群的工作节点中,工作负载和一些其他 Pod 在此处运行,由托管集群配置操作员管理。
数据平面的ImageContentSourcePolicy
(ICSP) 自定义资源通过托管集群清单中的ImageContentSources
API 进行管理。
对于控制平面,ICSP 对象在管理集群中管理。这些对象由 HyperShift 运算符解析,并作为registry-overrides
条目与控制平面运算符共享。这些条目作为参数注入托管控制平面命名空间中任何一个可用的部署中。
要在托管控制平面中使用断开连接的注册表,您必须首先在管理集群中创建相应的 ICSP。然后,要在数据平面中部署断开连接的工作负载,您需要将所需的条目添加到托管集群清单中的ImageContentSources
字段中。
镜像注册表。有关更多信息,请参见“使用 Red Hat OpenShift 的镜像注册表创建镜像注册表”。
断开连接安装的镜像镜像。有关更多信息,请参见“使用 oc-mirror 插件镜像断开连接安装的镜像”。
要从管理集群拉取镜像注册表镜像,您必须首先向管理集群添加镜像注册表的凭据和证书颁发机构。使用以下步骤
通过运行以下命令创建包含镜像注册表证书的ConfigMap
$ oc apply -f registry-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: registry-config
namespace: openshift-config
data:
<mirror_registry>: |
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
修补image.config.openshift.io
集群范围的对象以包含以下条目
spec:
additionalTrustedCA:
- name: registry-config
更新管理集群拉取密钥以添加镜像注册表的凭据。
通过运行以下命令以 JSON 格式从集群中获取拉取密钥
$ oc get secret/pull-secret -n openshift-config -o json | jq -r '.data.".dockerconfigjson"' | base64 -d > authfile
编辑获取的密钥 JSON 文件以包含包含证书颁发机构凭据的部分
"auths": {
"<mirror_registry>": { (1)
"auth": "<credentials>", (2)
"email": "[email protected]"
}
},
1 | 提供镜像注册表的名称。 |
2 | 提供镜像注册表的凭据以允许获取镜像。 |
通过运行以下命令更新集群上的拉取密钥
$ oc set data secret/pull-secret -n openshift-config --from-file=.dockerconfigjson=authfile
当您对镜像使用镜像注册表时,代理需要信任注册表的证书才能安全地拉取镜像。您可以通过创建ConfigMap
来将镜像注册表的证书颁发机构添加到AgentServiceConfig
自定义资源。
您必须已安装 Kubernetes 运算符的多集群引擎。
在安装多集群引擎运算符的同一命名空间中,使用镜像注册表详细信息创建一个ConfigMap
资源。此ConfigMap
资源确保您授予托管集群工作节点从镜像注册表检索镜像的功能。
apiVersion: v1
kind: ConfigMap
metadata:
name: mirror-config
namespace: multicluster-engine
labels:
app: assisted-service
data:
ca-bundle.crt: |
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
registries.conf: |
[[registry]]
location = "registry.stage.redhat.io"
insecure = false
blocked = false
mirror-by-digest-only = true
prefix = ""
[[registry.mirror]]
location = "<mirror_registry>"
insecure = false
[[registry]]
location = "registry.redhat.io/multicluster-engine"
insecure = false
blocked = false
mirror-by-digest-only = true
prefix = ""
[[registry.mirror]]
location = "<mirror_registry>/multicluster-engine" (1)
insecure = false
1 | 其中:<mirror_registry> 是镜像注册表的名称。 |
修补AgentServiceConfig
资源以包含您创建的ConfigMap
资源。如果AgentServiceConfig
资源不存在,请创建包含以下内容的AgentServiceConfig
资源
spec:
mirrorRegistryRef:
name: mirror-config
在断开连接的环境中在 IBM Z 上部署托管控制平面时,请包含additional-trust-bundle
和image-content-sources
资源。这些资源允许托管集群将证书颁发机构注入数据平面工作节点,以便从注册表中提取镜像。
使用image-content-sources
信息创建icsp.yaml
文件。
image-content-sources
信息可在使用oc-mirror
镜像镜像后生成的ImageContentSourcePolicy
YAML 文件中找到。
# cat icsp.yaml
- mirrors:
- <mirror_registry>/openshift/release
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
- mirrors:
- <mirror_registry>/openshift/release-images
source: quay.io/openshift-release-dev/ocp-release
创建托管集群并提供additional-trust-bundle
证书以使用证书更新计算节点,如下例所示
$ hcp create cluster agent \
--name=<hosted_cluster_name> \ (1)
--pull-secret=<path_to_pull_secret> \ (2)
--agent-namespace=<hosted_control_plane_namespace> \ (3)
--base-domain=<basedomain> \ (4)
--api-server-address=api.<hosted_cluster_name>.<basedomain> \
--etcd-storage-class=<etcd_storage_class> \ (5)
--ssh-key <path_to_ssh_public_key> \ (6)
--namespace <hosted_cluster_namespace> \ (7)
--control-plane-availability-policy SingleReplica \
--release-image=quay.io/openshift-release-dev/ocp-release:<ocp_release_image> \ (7)
--additional-trust-bundle <path for cert> \ (8)
--image-content-sources icsp.yaml
1 | 将<hosted_cluster_name> 替换为您托管集群的名称。 |
2 | 替换拉取密钥的路径,例如/user/name/pullsecret 。 |
3 | 将<hosted_control_plane_namespace> 替换为托管控制平面命名空间的名称,例如clusters-hosted 。 |
4 | 将名称替换为您基本域名,例如example.com 。 |
5 | 替换 etcd 存储类名称,例如lvm-storageclass 。 |
6 | 替换 SSH 公钥的路径。默认文件路径为~/.ssh/id_rsa.pub 。 |
7 | 替换为您要使用的受支持的 OpenShift Container Platform 版本,例如4.17.0-multi 。 |
8 | 替换镜像注册表的证书颁发机构的路径。 |