Red Hat OCP (RHBA-2020:4196 )现已正式发布。此发行版本使用 Kubernetes 1.19 和 CRI-O 运行时。
OCP 4.6 需要运行在 Red Hat Enterprise Linux 7.7 及更新的版本,或 Red Hat Enterprise Linux CoreOS 4.6 上。必须使用 Red Hat Enterprise Linux CoreOS (RHCOS) 作为 control plane ( 也称为 master) 的系统,而 compute ( 也称为 worker) 机器可以使用 RHCOS ,或 Red Hat Enterprise Linux 7.7 及更新的版本。
CNI 网络供应商现在使用在集群节点上安装的 OVS; OpenShift SDN 和 OVN-Kubernetes Container Network Interface (CNI )集群网络供应商现在都使用在集群节点上安装的 Open vSwitch (OVS )版本。在以前的版本中,OVS 会在每个节点上运行由 DaemonSet 管理的容器中运行。使用主机 OVS 可避免任何可能的停机时间,如升级 OVS 容器化版本。
下面是在受限网络中的裸机上安装集群OCP4.6.4 的过程。
- 在镜像主机上创建镜像 registry ,并获取您的 OCP 版本的 imageContentSources 数据。 重要:由于安装介质位于堡垒主机上,因此请使用该计算机完成所有安装步骤。
【参考】
- 为集群置备持久性存储。若要部署私有镜像 registry ,您的存储必须提供 ReadWriteMany 访问模式。
- 查看有关 OCP 安装和更新流程的详细信息。
- 如果使用防火墙并计划使用遥测(telemetry ),您必须将防火墙配置为允许集群需要访问的站点。
- 平台选择会受到限制
- 如果选择在云平台中执行受限网络安装,仍然需要访问其云 API 。必定需要访问互联网
- 必须创建镜像 registry
受限网络中的集群还有以下额外限制:
ClusterVersion 状态包含 Unable to retrieve available updates 错误。
默认情况下,您无法使用 Developer Catalog 的内容,因为您无法访问所需的 ImageStreamTag 。
在 OCP 4.5 中,您需要访问互联网来获得用来安装集群的镜像。
默认运行的 Telemetry 服务提供有关集群健康状况和成功更新的指标,这也需要访问互联网。如果您的集群连接到互联网,Telemetry 会自动运行,而且集群会注册到 Red Hat OpenShift Cluster Manager (OCM )。
l 所需的机器
最小的 OCP 集群需要下列主机:
一个临时 bootstrap 机器
三台 control plane 或 master 机器
至少两台计算机器,也称为 worker 机器
*bootstrap 、control plane 以及计算(compute )机器必须使用 Red Hat Enterprise Linux CoreOS (RHCOS) 作为操作系统。
l 网络连接要求
所有 Red Hat Enterprise Linux CoreOS (RHCOS) 机器在启动过程中需要 initramfs 中的网络从 Machine Config Server 获取 Ignition 配置文件。在初次启动过程中,需要一个 DHCP 服务器或设置了静态 IP 地址来建立网络连接,以下载它们的 Ignition 配置文件。
l 最低资源要求
每台集群机器都必须满足以下最低要求:
|
机器 |
操作系统 |
vCPU |
虚拟内存 |
存储 |
|
bootstrap |
RHCOS |
4 |
16 GB |
120 GB |
|
Control plane |
RHCOS |
4 |
16 GB |
120 GB |
|
Compute |
RHCOS 或 RHEL 7.6 |
2 |
8 GB |
120 GB |
l 证书签名请求管理
在使用您置备的基础架构时,集群只能有限地访问自动机器管理,因此您必须提供一种在安装后批准集群证书签名请求 (CSR) 的机制。kube-controller-manager 只能批准 kubelet 客户端 CSR 。machine-approver 无法保证使用 kubelet 凭证请求的提供证书的有效性,因为它不能确认是正确的机器发出了该请求。您必须决定并实施一种方法,以验证 kubelet 提供证书请求的有效性并进行批准。
l 参考配置列表
|
角色 |
操作系统 |
vcpu/mem/disk |
IP 地址 |
备注 |
|
bootstrap |
RHCOS 4.6.1 |
4C16G120G |
192.168.4.117 |
测试集群2 |
|
Control plane |
RHCOS 4.6.1 |
4C16G120G |
192.168.4.118 |
|
|
Control plane |
RHCOS 4.6.1 |
4C16G120G |
192.168.4.119 |
|
|
Control plane |
RHCOS 4.6.1 |
4C16G120G |
192.168.4.120 |
|
|
Compute |
RHCOS 4.6.1 |
2C8G120G |
192.168.4.121 |
|
|
Compute |
RHCOS 4.6.1 |
2C8G120G |
192.168.4.122 |
|
|
cluster2server |
rhel7.7 |
2C8G100G |
192.168.4.123 |
dns/yum/haproxy/registry |
- 在每个节点上配置 DHCP 或设置静态 IP 地址。【静态IP 】
- 提供所需的负载均衡器
【参考】
- 配置机器的端口
- 配置 DNS
【参考】
在 Linux 上安装 OpenShift CLI (oc )二进制文件。
wget
1) 安装所需的软件包
yum -y install podman httpd-tools
mkdir -p /opt/registry/{auth,certs,data}
2) 为 registry 提供证书
如果您没有现有的可信证书颁发机构,您可以生成自签名证书:
$ cd /opt/registry/certs
# openssl req -newkey rsa:4096 -nodes -sha256 -keyout domain.key -x509 -days 365 -out domain.crt
或者
#export MIRRIR_REGISTRY=<FULL-DOMAIN-NAME>
export MIRRIR_REGISTRY=`hostname`
#openssl req -newkey rsa:4096 -nodes -sha256 -keyout /opt/registry/certs/registry.key -x509 -days 365 \
-out /opt/registry/certs/registry.crt \
-subj "/C=CN/ST=BEIJING/L=BJ/O=RedHat/OU=OpenShift.RedHat/CN=${MIRRIR_REGISTRY}/emailAddress=admin@${MIRRIR_REGISTRY}"
为 registry 生成使用 bcrpt 格式的用户名和密码:
# htpasswd -bBc /opt/registry/auth/htpasswd <user_name> <password>
htpasswd -bBc /opt/registry/auth/htpasswd aaa123
将自签名证书添加到可信证书列表中:
将自签名证书加到运行Mirror Registry 节点的可信证书中,然后确认前几行就是上一步添加的“OU=OpenShift.RedHat ”的证书。
$ cp /opt/registry/certs/registry.crt /etc/pki/ca-trust/source/anchors/
$ update-ca-trust
$ trust list | head -5
3) 创建 mirror-registry 容器以托管 registry :
# podman run --name mirror-registry -p <local_registry_host_port>:5000 \ # 对于 <local_registry_host_port> ,请指定您的镜像 registry 用于提供内容的端口
-v /opt/registry/data:/var/lib/registry:z \
-v /opt/registry/auth:/auth:z \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-v /opt/registry/certs:/certs:z \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
-e REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED=true \
-d docker.io/library/registry:2
实例:
# podman run --name mirror-registry -p 5000:5000 \
-v /opt/registry/data:/var/lib/registry:z \
-v /opt/registry/auth:/auth:z \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-v /opt/registry/certs:/certs:z \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/registry.key \
-e REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED=true \
-d docker.io/library/registry:2
4) 为 registry 打开所需的端口:
# firewall-cmd --add-port=<local_registry_host_port>/tcp --zone=internal --permanent
# firewall-cmd --add-port=<local_registry_host_port>/tcp --zone=public --permanent
# firewall-cmd --reload
实例:
firewall-cmd --add-port=5000/tcp --zone=internal --permanent
firewall-cmd --add-port=5000/tcp --zone=public --permanent
firewall-cmd --reload
5) 确认 registry 可用:
$ curl -u <user_name>:<password> -k
{"repositories":[]}
curl -u mirimg:aaa123 -k
配置允许对mirror registry 进行mirror 的凭证
1) 下载Pull Secret
从 Red Hat OpenShift Cluster Manager 站点的 Pull Secret 页面下载 registry.redhat.io 的 pull secret ,将它保存为一个 .json 文件。
pull secret :
[root@cluster2 ~]# wget -O jq
[root@cluster2 ~]# chmod +x ./jq
[root@cluster2 ~]# cp jq /usr/bin
2) 为您的镜像 registry 生成 base64 编码的用户名和密码或令牌:
$ echo -n '<user_name>:<password>' | base64 -w0
echo -n 'mirimg:aaa123' |base64 -w0
# 通过 <user_name> 和 <password> 指定 registry 的用户名和密码。
# echo 'bWlyaOjFxYXo3VUpN' |base64 -d
3) 以 JSON 格式创建您的 pull secret 副本:
$ cat ./pull-secret.text | jq . > <path>/<pull-secret-file>
[root@cluster2 ~]# cat pull-secret | jq . >all-secret.json
编辑新文件并添加描述 registry 的部分:
"auths": {
"<mirror_registry>": {
"auth": "<credentials>",
"email": "you@example.com"
},
实例:
"auths": {
"cluster2.pocchina.com:5000": {
"auth": "bWlyaOjFxYXo3VUpN",
"email": "admin@ pocchina.com"
},
l 对于 <mirror_registry> ,指定 registry 域名,以及您的镜像 registry 用来提供内容的可选端口。例如: registry.example.com 或 registry.example.com:5000
l 使用 <credentials> 为您的镜像 registry 指定 base64 编码的用户名和密码。
$ OCP_RELEASE=<release_version>
$ LOCAL_REGISTRY='<local_registry_host_name>:<local_registry_host_port>'
$ LOCAL_REPOSITORY='<local_repository_name>'
$ PRODUCT_REPO='openshift-release-dev'
$ LOCAL_SECRET_JSON='<path_to_pull_secret>'
$ RELEASE_NAME="ocp-release" # 对于生产环境版本,您必须指定 ocp-release
$ ARCHITECTURE=<server_architecture> # 例如:x86_64
$ REMOVABLE_MEDIA_PATH=<path> # 指定完整路径,包括开始的前斜杠(/) 字符。
实例:
export OCP_RELEASE=4.6.4
export LOCAL_REGISTRY='cluster2.pocchina.com:5000'
export LOCAL_REPOSITORY='ocp4/openshift4'
export PRODUCT_REPO='openshift-release-dev'
export LOCAL_SECRET_JSON=$HOME/all-secret.json
export RELEASE_NAME="ocp-release"
export ARCHITECTURE=x86_64
export REMOVABLE_MEDIA_PATH=$HOME
export GODEBUG=x509ignoreCN=0
l 如果您的镜像主机无法访问互联网,请执行以下操作:
将可移动介质连接到连接到互联网的系统。
查看要镜像的镜像和配置清单:
$ oc adm -a ${LOCAL_SECRET_JSON} release mirror \
--from=quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE}-${ARCHITECTURE} \
--to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY} \
--to-release-image=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}-${ARCHITECTURE} --dry-run
记录上一命令输出中的 imageContentSources 部分。您的镜像信息与您的镜像存储库相对应,您必须在安装过程中将 imageContentSources 部分添加到 install-config.yaml 文件中。
将image 镜像到可移动介质的目录中:
$ oc adm release mirror -a ${LOCAL_SECRET_JSON} --to-dir=${REMOVABLE_MEDIA_PATH}/mirror quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE}-${ARCHITECTURE}
将介质上传到受限网络环境中,并将镜像上传到本地容器 registry 。
$ oc image mirror -a ${LOCAL_SECRET_JSON} --from-dir=${REMOVABLE_MEDIA_PATH}/mirror "file://openshift/release:${OCP_RELEASE}*" ${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}
对于 REMOVABLE_MEDIA_PATH ,您必须使用与镜像镜像时指定的同一路径。
l 如果本地容器 registry 连接到镜像主机,请执行以下操作:
使用以下命令直接将发行版镜像推送到本地 registry:
$ oc adm -a ${LOCAL_SECRET_JSON} release mirror \
--from=quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE}-${ARCHITECTURE} \
--to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY} \
--to-release-image=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}-${ARCHITECTURE}
输出日志如下:
info: Mirroring 120 images to cluster2.pocchina.com:5000/ocp4/openshift4 ...
cluster2.pocchina.com:5000/
ocp4/openshift4
blobs:
quay.io/openshift-release-dev/ocp-release sha256:26f7cd4cf1fb9d0038d09a2702353455afddeb1d36706f1218d1569342453fc9 1.672KiB
… …
blobs:
quay.io/openshift-release-dev/ocp-v4.0-art-dev sha256:04ef0e69dcba4088b009d14d21e86cda00ddbf8e84a4d9746c5d8ec9d61803af 1.379KiB
… …
manifests:
sha256:003d999d37f8d2c043ad9370eaf1e7533b9306bcebea47d62546b6456b0f6924 -> 4.6.4-grafana
… …
stats: shared=5 unique=246 size=6.553GiB ratio=0.98
phase 0:
cluster2.pocchina.com:5000 ocp4/openshift4 blobs=251 mounts=0 manifests=120 shared=5
… …
Success
Update image: cluster2.pocchina.com:5000/ocp4/openshift4:4.6.4-x86_64
Mirror prefix: cluster2.pocchina.com:5000/ocp4/openshift4
To use the new mirrored repository to install, add the following section to the install-config.yaml:
imageContentSources:
- mirrors:
- cluster2.pocchina.com:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-release
- mirrors:
- cluster2.pocchina.com:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
To use the new mirrored repository for upgrades, use the following to create an ImageContentSourcePolicy:
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
name: example
spec:
repositoryDigestMirrors:
- mirrors:
- cluster2.pocchina.com:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-release
- mirrors:
- cluster2.pocchina.com:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev */
该命令将发行信息提取为摘要,其输出包括安装集群时所需的 imageContentSources 数据。
记录上一命令输出中的 imageContentSources 部分。您的镜像信息与您的镜像存储库相对应,您必须在安装过程中将 imageContentSources 部分添加到 install-config.yaml 文件中。
$ curl -u <USER>:<PASSWORD> -k {MIRRIR_REGISTRY}:5000/v2/_catalog
实例:
curl -u mirimg:aaa123 -k
export OCP_RELEASE=4.6.4
export LOCAL_REGISTRY='cluster2.pocchina.com:5000'
export LOCAL_REPOSITORY='ocp4/openshift4'
export PRODUCT_REPO='openshift-release-dev'
export LOCAL_SECRET_JSON=$HOME/all-secret.json
export RELEASE_NAME="ocp-release"
export ARCHITECTURE=x86_64
export REMOVABLE_MEDIA_PATH=$HOME
export GODEBUG=x509ignoreCN=0
oc adm release info -a ${LOCAL_SECRET_JSON} "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}-${ARCHITECTURE}"
[root@cluster2 ~]# oc adm release info -a ${LOCAL_SECRET_JSON} "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}-${ARCHITECTURE}"
Name: 4.6.4
Digest: sha256:6681fc3f83dda0856b43cecd25f2d226c3f90e8a42c7144dbc499f6ee0a086fc
Created: 2020-11-11T15:13:14Z
OS/Arch: linux/amd64
Manifests: 444
Pull From: cluster2.pocchina.com:5000/ocp4/openshift4@sha256:6681fc3f83dda0856b43cecd25f2d226c3f90e8a42c7144dbc499f6ee0a086fc
Release Metadata:
Version: 4.6.4
Upgrades: 4.5.16, 4.5.17, 4.5.18, 4.5.19, 4.6.1, 4.6.2, 4.6.3
Metadata:
url:
Component Versions:
kubernetes 1.19.0
machine-os 46.82.202011061621-0 Red Hat Enterprise Linux CoreOS
Images:
NAME DIGEST
aws-ebs-csi-driver sha256:307d07432e0913c7e3673bffe454ba8b11bdf55d2c537c43eda35c03b19d64e3
aws-ebs-csi-driver-operator sha256:5d396305893a2c5855a331f925a8ca59e1526e93df6c3834b78f36eca0a509fc
… …
thanos sha256:e9b7708abd519710c58d6f51870cd1085e436283164cf7ddeb44530a2c4ca12f
tools sha256:4b0c00d40c1f3860c89a7b0d6fd5113ad59c0bb96416850f3cda26071b709f46
[root@cluster2 ~]#
至此,mirror registry 已经配置完成
要创建基于您镜像内容的安装程序,请提取内容并 将其固定到发行版中:
l 如果您的镜像主机无法访问互联网,运行以下命令:
$ oc adm -a ${LOCAL_SECRET_JSON} release extract --command=openshift-install "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}"
l 如果本地容器 registry 连接到镜像主机,请运行以下命令:
$ oc adm -a ${LOCAL_SECRET_JSON} release extract --command=openshift-install "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}-${ARCHITECTURE}"
重要:(1) 要确保将正确的镜像用于您选择的 OpenShift Container Platform 版本,您必须从镜像内容中提取安装程序。(2) 您必须在有活跃互联网连接的机器上执行这个步骤。(3) 如果您位于断开连接的环境中, 请使用 --image 标志作为 must-gather 的一部分,指向有效负载镜像。
使用受限网络的集群必须导入默认的 must-gather 镜像,以便为红帽支持收集调试数据。在默认情况下,must-gather 镜像不会被导入,并且受限网络中的集群无法访问互联网来从远程存储库拉取最新的镜像。
$ oc import-image is/must-gather -n openshift
使用带有备用或镜像 registry 的 Cluster Samples Operator 镜像流。
openshift 命名空间中大多数由 Cluster Samples Operator 管理的镜像流指向位于 registry.redhat.io 上红帽容器镜像仓库中的镜像。镜像功能不适用于这些镜像流。
注意:
cli 、installer 、must-gather 和 test 镜像流虽然属于安装有效负载的一部分,但不由 Cluster Samples Operator 管理。此流程中不涉及这些镜像流。
先决条件
l 使用具有 cluster-admin 角色的用户访问集群。
l 为您的镜像 registry 创建 pull secret 。
过程:
1) 访问被镜像(mirror )的特定镜像流的镜像,例如:
$ oc get is <imagestream> -n openshift -o json | jq .spec.tags[].from.name | grep registry.redhat.io
2) 将 registry.redhat.io 中与您在受限网络环境中需要的任何镜像流关联的镜像,镜像 (mirror) 成一个定义的镜像 (mirror) :
$ oc image mirror registry.redhat.io/rhscl/ruby-25-rhel7:latest ${MIRROR_ADDR}/rhscl/ruby-25-rhel7:latest
3) 创建集群的镜像配置对象:
$ oc create configmap registry-config --from-file=${MIRROR_ADDR_HOSTNAME}..5000=$path/ca.crt -n openshift-config
4) 在集群的镜像配置对象中,为镜像添加所需的可信 CA :
$ oc patch image.config.openshift.io/cluster --patch '{"spec":{"additionalTrustedCA":{"name":"registry-config"}}}' --type=merge
5) 更新 Cluster Samples Operator 配置对象中的 samplesRegistry 字段,使其包含镜像配置中定义的镜像位置的 hostname 部分:
$ oc edit configs.samples.operator.openshift.io -n openshift-cluster-samples-operator
...
spec:
architectures:
- x86_64
managementState: Managed
samplesRegistry: registry.pocchina.com # add lines
注意:这是必要的,因为镜像流导入过程在此刻不使用镜像(mirror )或搜索机制。
6) 将所有未镜像的镜像流添加到 Cluster Samples Operator 配置对象的 skippedImagestreams 字段。或者,如果您不想支持任何示例镜像流,在 Cluster Samples Operator 配置对象中将 Cluster Samples Operator 设置为 Removed 。
openshift 命名空间中的许多模板都引用镜像流。因此,使用 Removed 清除镜像流和模板,将避免在因为缺少镜像流而导致镜像流和模板无法正常工作时使用它们。
$ ssh-keygen -t rsa -b 4096 -N '' -f <path>/<file_name>
$ eval "$(ssh-agent -s)"
$ ssh-add <path>/<file_name>
在安装 OCP 时,为安装程序提供 SSH 公钥。如果在您置备的基础架构上安装集群,您必须将此密钥提供给集群的机器。
创建用来存储您所需的安装资产的安装目录:$ mkdir <installation_directory>
自定义以下 install-config.yaml 文件模板,并将它保存到 <installation_directory> 中。
注意:此配置文件必须命名为 install-config.yaml
[root@cluster2 ocp4soft]# cat install-config.yaml
apiVersion: v1
baseDomain: pocchina.com
compute:
- hyperthreading: Enabled
name: worker
replicas: 0
controlPlane:
hyperthreading: Enabled
name: master
replicas: 3
metadata:
name: cluster2
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
networkType: OpenShiftSDN
serviceNetwork:
- 172.30.0.0/16
platform:
none: {}
fips: false
pullSecret: '{"auths":{"cluster2.pocchina.com:5000": {"auth": "bWlyaOjFxYXo3VUpN","email": "admin@pocchina.com"}}}'
sshKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC90U9/IAZvnawgeciYu4caVbYsy4kqqRBoidOPRxO4aOpuUzKvaYBuz4LJ1W7iThjCVtsg9jZPChht1kZir8v5SrBPE6p7rq+i78bZfWWi5hHKssO4aiRt6wRl97z5P3/HpEyZxXNULI/bchoxjFCIvsRdlbTCF8fzsSVnzcjJPPMMTOIxKJa/VdTCkpTM//Fwf5u81se3lQ4A2aT7DkwDsww4kYRMnutYQSXHvBMaqGOJeBYW6hIwJVaQ== root@cluster2.pocchina.com'
additionalTrustBundle: |
-----BEGIN CERTIFICATE-----
MIIGITCCBAmgAwIBAgIJAM1DFeIzMA0GCSqGSIb3DQEBCwUAMIGmMQswCQYD
wJDTjEQMA4GA1UECAwHQkVJSklORzELMAkGA1UEBwwCQkoxDzANBgNVBAoM
BlJlZEhhdDEZMBcGA1UECwwQT3BlblNoaWZ0LlJlZEhhdDEfMB0GA1UEAwwWY2x1
c3RlcjIuYWRkcGNoaW5hLmNvbTErMCkGCSqGSIb3DQEJARYcYWRtaW5AY2x1c3Rl
cjIuYWRkcGNoaW5hLmNvbTAeFw0yMDEyMTIwNjQzMzVaFw0yMTEyMTIwNjQzMzVa
MQswCQYDVQQGEwJDTjEQMA4GA1UECAwHQkVJSklORzELMAkGA1UEBwwCQkox
DzANBgNVBAoMBlJlZEhhdDEZMBcGA1UECwwQT3BlblNoaWZ0LlJlZEhhdDEfMB0G
A1UEAwwWY2x1c3RlcjIuYWRkcGNoaW5hLmNvbTErMCkGCSqGSIb3DQEJARYcYWRt
io7FwElhfkSPMvn6N4+xJhS7W6OMEfFCgcoizLZJZEszDYpbvqat1nYqanKS9AkE
7FlTSeDrwPCpMQRa7mSVUpLyISFrmrxbKshyXAUR+PQZTVgCRXuPVuR7AgMBAAGj
MB0GA1UdDgQWBBS2PZXoEmlgZeOd9f4FlD+ObmEzDTAfBgNVHSMEGDAWgBS2
oEmlgZeOd9f4FlD+ObmEzDTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA
A4ICAQB5mabSmNh9e9FgL6x/HNGb0/BBzeO13SchBZ2g2m4jGzYH8T5ObZ3rCjxK
giTfkNg/iyARE2aeMN1Cey9t36OAZHWB6Um+y6Lu93Kw0tf7NZbjZvXe9jnKWWPA
leObbVwOLw8B89N+7BAuCy3EEbxcekiMl8rkpIFnz/Nsxxx4kXm5Ud4fTLy4VN7x
Wj2xUx2ZT49FVJJmV9owJumGi5K1e6BxS7aDfGVa2NCymg+OUzeJic0uoLioCDtF
NN0UdQCzmhZuEifESzz2bI8mao3VLMKR/L+DNhB/Z9lcMRIInQ==
-----END CERTIFICATE-----
imageContentSources:
- mirrors:
- cluster2.pocchina.com:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-release
- mirrors:
- cluster2.pocchina.com:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
[root@cluster2 ocp4soft]#
备份 install-config.yaml 文件,以便用于安装多个集群。
您可在没有 worker 的 OCP 中安装和运行三节点集群。这为集群管理员和开发人员提供了较小的、效率更高的集群,用于开发、生产及测试。
即:编辑 install-config.yaml 文件,将计算副本(也称为 worker 副本)数设为 0
compute:
- name: worker
platform: {}
replicas: 0
由于您必须修改一些集群定义文件并要手动启动集群机器,因此您必须生成 Kubernetes 清单和 Ignition 配置文件,集群需要这两项来创建其机器。
l 为集群生成 Kubernetes 清单
$ ./openshift-install create manifests --dir=<installation_directory>
对于 <installation_directory> ,请指定含有您创建的 install-config.yaml 文件的安装目录。
[root@cluster2 ocp4soft]# ./openshift-install create manifests --dir=/root/ocp4inst
INFO Consuming Install Config from target directory
WARNING Making control-plane schedulable by setting MastersSchedulable to true for Scheduler cluster settings
INFO Manifests created in: /root/ocp4inst/manifests and /root/ocp4inst/openshift
[root@cluster2 ocp4soft]#
警告: 如果您要运行一个三节点集群,请跳过以下步骤,以便可以调度 master 。
- 修改 <installation_directory>/manifests/cluster-scheduler-02-config.yml 中 mastersSchedulable 参数,并将其值设为 False ,以防止在 control plane 机器上调度 Pod;
l 获取 Ignition 配置文件
$ ./openshift-install create ignition-configs --dir=<installation_directory>
[root@cluster2 ocp4soft]# ./openshift-install create ignition-configs --dir=/root/ocp4inst
INFO Consuming Master Machines from target directory
INFO Consuming Common Manifests from target directory
INFO Consuming Openshift Manifests from target directory
INFO Consuming Worker Machines from target directory
INFO Consuming OpenShift Install (Manifests) from target directory
INFO Ignition-Configs created in: /root/ocp4inst and /root/ocp4inst/auth
[root@cluster2 ocp4soft]#
installation_directory 中将生成以下文件:
.
├── auth
│ ├── kubeadmin-password
│ └── kubeconfig
├── bootstrap.ign
├── master.ign
├── metadata.json
└── worker.ign
查看ign 文件:
cat master.ign |jq
在您置备的裸机基础架构上安装集群前,必须先创建 RHCOS(Red Hat Enterprise Linux CoreOS) 机器供其使用。要创建机器,请按照步骤操作使用 ISO 镜像或网络 PXE 引导。
1) 将安装程序创建的 control plane 、compute 和 bootstrap Ignition 配置文件上传到 HTTP 服务器。记下这些文件的 URL 。
【配置http 服务器】
2) 从红帽客户门户上的产品下载页面或 RHCOS 镜像页面,获取您选择的操作系统实例安装方法所需的 RHCOS 镜像。
例如:
rhcos-<version>-live.<architecture>.iso
3) 使用 ISO 启动 RHCOS 安装,使用如下安装选项之一:将 ISO 镜像刻录到磁盘并直接启动/ 通过 LOM 接口使用 ISO 重定向
4) 引导 ISO 镜像。您应该使用 coreos-installer 命令而不是添加内核参数。如果您在没有选项或中断的情况下运行 live 安装程序,安装程序将引导至 live 系统上的 shell 提示符,准备好将 RHCOS 安装到磁盘中。
5) 运行 coreos-installer 命令。您至少必须识别节点类型的 Ignition 配置文件位置,以及您要安装到的磁盘位置。
下面是一个示例:
$ coreos-installer install --ignition-url= /dev/sda
coreos-installer install /dev/sda --ignition-url=http://192.168.4.123/ocp4inst/bootstrap.ign --insecure-ignition --copy-network
在运行 coreos-installer 前,请参阅" 高级 RHCOS 安装参考" 部分,以了解配置功能的不同方法,如联网和磁盘分区。
- 安装 RHCOS 后,系统会重启。系统重启过程中,它会应用您指定的 Ignition 配置文件。
/* 实例:
coreos-installer install /dev/sda --ignition-url=https://192.168.4.123/ocp4inst/bootstrap.ign --insecure-ignition \
--append-karg ip=192.168.4.1.117::192.168.4.1:255.255.255.0:c2b1.pocchina.com:ens192:none \
--append-karg nameserver=192.168.4.128
coreos-installer install /dev/sda --ignition-url=http://192.168.4.123/ocp4inst/bootstrap.ign --insecure-ignition --copy-network
########## c2b1.pocchina.com
sudo su -
hostnamectl set-hostname c2b1.pocchina.com
nmcli conn mod 'Wired Connection' ipv4.address 192.168.4.117/24
nmcli conn mod 'Wired Connection' ipv4.gateway 192.168.4.1
nmcli conn mod 'Wired Connection' ipv4.dns "192.168.4.1 192.168.4.123"
nmcli conn mod 'Wired Connection' ipv4.method manual
nmcli conn up 'Wired Connection'
或者
sudo su -
hostnamectl set-hostname c2b1.pocchina.com
nmcli conn mod 'Wired Connection' ipv4.address 192.168.4.117/24 ipv4.gateway 192.168.4.1 ipv4.dns 192.168.4.123 ipv4.method manual
nmcli conn up 'Wired Connection'
coreos-installer install /dev/sda --ignition-url=http://192.168.4.123/ocp4inst/bootstrap.ign --insecure-ignition --copy-network
########## c2m1.pocchina.com
sudo su -
hostnamectl set-hostname c2m1.pocchina.com
nmcli conn mod 'Wired Connection' ipv4.address 192.168.4.118/24
nmcli conn mod 'Wired Connection' ipv4.gateway 192.168.4.1
nmcli conn mod 'Wired Connection' ipv4.dns "192.168.4.1 192.168.4.123"
nmcli conn mod 'Wired Connection' ipv4.method manual
nmcli conn up 'Wired Connection'
或者
sudo su -
hostnamectl set-hostname c2m1.pocchina.com
nmcli conn mod 'Wired Connection' ipv4.address 192.168.4.118/24 ipv4.gateway 192.168.4.1 ipv4.dns 192.168.4.123 ipv4.method manual
nmcli conn up 'Wired Connection'
示例1 (使用):
coreos-installer install /dev/sda --ignition-url=http://192.168.4.123/ocp4inst/master.ign --insecure-ignition --append-karg ip=192.168.4.118::192.168.4.1:255.255.255.0:c2m1.pocchina.com:ens192:none --append-karg nameserver=192.168.4.123
示例2 :
coreos-installer install /dev/sda --ignition-url=http://192.168.4.123/ocp4inst/master.ign --insecure-ignition --copy-network --insecure
示例3 :
coreos-installer install /dev/sda --image-url=http://192.168.4.123/ocp4inst/rhcos-4.6.1-x86_64-metal.x86_64.raw.gz --ignition-url=http://192.168.4.123/ocp4inst/master.ign --insecure-ignition --copy-network --insecure
示例4 :
coreos-installer install /dev/sda --image-url=http://192.168.4.123/ocp4inst/rhcos-4.6.1-x86_64-metal.x86_64.raw.gz --ignition-url=http://192.168.4.123/ocp4inst/master.ign --insecure --insecure-ignition --append-karg ip=192.168.4.118::192.168.4.1:255.255.255.0:c2m1.pocchina.com:ens192:none --append-karg nameserver=192.168.4.123
*/
6) 重复 coreos-installer 命令,安装其他集群机器
要创建 OCP 集群,请等待您通过安装程序生成的 Ignition 配置文件所置备的机器上完成 bootstrap 过程。
- 监控 bootstrap 过程:$ ./openshift-install --dir=<installation_directory> wait-for bootstrap-complete --log-level=info
输出示例:
INFO Waiting up to 30m0s for the Kubernetes API at
INFO API v1.19.0 up
INFO Waiting up to 30m0s for bootstrapping to complete...
INFO It is now safe to remove the bootstrap resources
Kubernetes API 服务器提示已在 control plane 机器上完成 bootstrap 时,命令运行成功。
[root@cluster2 ocp4soft]# ./openshift-install --dir=/root/ocp4inst/ wait-for bootstrap-complete --log-level=info
INFO Waiting up to 20m0s for the Kubernetes API at
INFO API v1.19.0+9f84db3 up
INFO Waiting up to 30m0s for bootstrapping to complete...
INFO It is now safe to remove the bootstrap resources
INFO Time elapsed: 0s
[root@cluster2 ocp4soft]#
- bootstrap 过程完成后,请从负载均衡器中删除 bootstrap 机器。
此时您必须从负载均衡器中删除 bootstrap 机器。您还可以删除或重新格式化机器本身。
$ export KUBECONFIG=<installation_directory>/auth/kubeconfig
$ oc whoami
export KUBECONFIG=/root/ocp4inst/auth/kubeconfig
将机器添加到集群时,会为您添加的每台机器生成两个待处理证书签名请求(CSR )。您必须确认这些 CSR 已获得批准,或根据需要自行批准。
$ oc get nodes
$ oc get csr
若要单独批准,请对每个有效的 CSR 运行以下命令:
$ oc adm certificate approve <csr_name>
要批准所有待处理的 CSR ,请运行以下命令:
$ oc get csr -o go-template='{{range .items}}{{if not .status}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}' | xargs oc adm certificate approve
或者
oc adm certificate approve $(oc get csr -o go-template='{{range .items}}{{if not .status}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}')
在 control plane 初始化后,您必须立即配置一些 Operator 以便它们都可用。
观察集群组件上线:
$ watch -n5 oc get clusteroperators
配置不可用的 Operator
确认所有集群组件都已上线:
$ watch -n5 oc get clusteroperators
当所有集群 Operator 状态都是 AVAILABLE 时,您可以完成安装。
监控集群完成:
$ ./openshift-install --dir=<installation_directory> wait-for install-complete
输出示例:
INFO Waiting up to 30m0s for the cluster to initialize...
Cluster Version Operator 完成从 Kubernetes API 服务器部署 OCP 集群时,命令运行成功。
[root@cluster2 ocp4soft]# ./openshift-install --dir=/root/ocp4inst wait-for install-complete
INFO Waiting up to 40m0s for the cluster at to initialize...
INFO Waiting up to 10m0s for the openshift-console route to be created...
INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/root/ocp4inst/auth/kubeconfig'
INFO Access the OpenShift web-console here:
INFO Login to the console with user: "kubeadmin", and password: "98rmK-ULvWs-Icu7g-IN8IR"
INFO Time elapsed: 0s
重要: 安装程序生成的 Ignition 配置文件中所含的证书会在 24 小时后过期。您必须以非降级状态持续运行集群 24 小时,以确保完成第一次证书轮转。
确认 Kubernetes API 服务器正在与 pod 通信:
$ oc get pods --all-namespaces
$ oc logs <pod_name> -n <namespace>
在 Cluster registration 页面注册您的集群:
OCM (Redhat Openshift Cluster Manager )-->Cluster --> Register disconnected cluster
自定义集群。
如果您用来安装集群的镜像 registry 具有一个可信任的 CA ,通过配置额外的信任存储将其添加到集群中。
如果需要,您可以选择不使用远程健康报告。
【资料】
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16976507/viewspace-2850088/ ,如需转载,请注明出处,否则将追究法律责任。