14.2. 使用 CLI 的 vSphere 安装后配置
在启用了平台集成功能的 vSphere 上使用 Assisted Installer 安装 OpenShift Container Platform 集群后,您必须手动更新以下 vSphere 配置设置:
- vCenter 用户名
- vCenter 密码
- vCenter 地址
- vCenter 集群
- 数据中心
- 数据存储
- 目录
先决条件
- Assisted Installer 成功完成安装集群。
- 集群连接到 console.redhat.com。
流程
为 vCenter 生成 base64 编码的用户名和密码:
$ echo -n "<vcenter_username>" | base64 -w0
将
<vcenter_username>
替换为您的 vCenter 用户名。$ echo -n "<vcenter_password>" | base64 -w0
将
<vcenter_password>
替换为您的 vCenter 密码。备份 vSphere 凭证:
$ oc get secret vsphere-creds -o yaml -n kube-system > creds_backup.yaml
编辑 vSphere 凭证:
$ cp creds_backup.yaml vsphere-creds.yaml
$ vi vsphere-creds.yaml
apiVersion: v1 data: <vcenter_address>.username: <vcenter_username_encoded> <vcenter_address>.password: <vcenter_password_encoded> kind: Secret metadata: annotations: cloudcredential.openshift.io/mode: passthrough creationTimestamp: "2022-01-25T17:39:50Z" name: vsphere-creds namespace: kube-system resourceVersion: "2437" uid: 06971978-e3a5-4741-87f9-2ca3602f2658 type: Opaque
将
<vcenter_address>
替换为 vCenter 地址。将<vcenter_username_encoded>
替换为 vSphere 用户名的 base64 编码版本。将<vcenter_password_encoded>
替换为 vSphere 密码的 base64 编码版本。替换 vSphere 凭证:
$ oc replace -f vsphere-creds.yaml
重新部署 kube-controller-manager pod:
$ oc patch kubecontrollermanager cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$( date --rfc-3339=ns )"'"}}' --type=merge
备份 vSphere 云供应商配置:
$ oc get cm cloud-provider-config -o yaml -n openshift-config > cloud-provider-config_backup.yaml
编辑云供应商配置:
$ cloud-provider-config_backup.yaml cloud-provider-config.yaml
$ vi cloud-provider-config.yaml
apiVersion: v1 data: config: | [Global] secret-name = "vsphere-creds" secret-namespace = "kube-system" insecure-flag = "1" [Workspace] server = "<vcenter_address>" datacenter = "<datacenter>" default-datastore = "<datastore>" folder = "/<datacenter>/vm/<folder>" [VirtualCenter "<vcenter_address>"] datacenters = "<datacenter>" kind: ConfigMap metadata: creationTimestamp: "2022-01-25T17:40:49Z" name: cloud-provider-config namespace: openshift-config resourceVersion: "2070" uid: 80bb8618-bf25-442b-b023-b31311918507
将
<vcenter_address>
替换为 vCenter 地址。将<datacenter>
替换为数据中心的名称。将<datastore>
替换为数据存储的名称。将<folder>
替换为包含集群虚拟机的文件夹。应用云供应商配置:
$ oc apply -f cloud-provider-config.yaml
使用
uninitialized
污点为集群加污点:重要如果要安装 OpenShift Container Platform 4.13 或更高版本,请执行以下的第 9 步到第 12 步。
识别要加污点的节点:
$ oc get nodes
对每个节点运行以下命令:
$ oc adm taint node <node_name> node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
将
<node_name>
替换为节点的名称。
Example
$ oc get nodes NAME STATUS ROLES AGE VERSION master-0 Ready control-plane,master 45h v1.26.3+379cd9f master-1 Ready control-plane,master 45h v1.26.3+379cd9f worker-0 Ready worker 45h v1.26.3+379cd9f worker-1 Ready worker 45h v1.26.3+379cd9f master-2 Ready control-plane,master 45h v1.26.3+379cd9f $ oc adm taint node master-0 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule $ oc adm taint node master-1 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule $ oc adm taint node master-2 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule $ oc adm taint node worker-0 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule $ oc adm taint node worker-1 node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
备份基础架构配置:
$ oc get infrastructures.config.openshift.io -o yaml > infrastructures.config.openshift.io.yaml.backup
编辑基础架构配置:
$ cp infrastructures.config.openshift.io.yaml.backup infrastructures.config.openshift.io.yaml
$ vi infrastructures.config.openshift.io.yaml
apiVersion: v1 items: - apiVersion: config.openshift.io/v1 kind: Infrastructure metadata: creationTimestamp: "2022-05-07T10:19:55Z" generation: 1 name: cluster resourceVersion: "536" uid: e8a5742c-6d15-44e6-8a9e-064b26ab347d spec: cloudConfig: key: config name: cloud-provider-config platformSpec: type: VSphere vsphere: failureDomains: - name: assisted-generated-failure-domain region: assisted-generated-region server: <vcenter_address> topology: computeCluster: /<data_center>/host/<vcenter_cluster> datacenter: <data_center> datastore: /<data_center>/datastore/<datastore> folder: "/<data_center>/path/to/folder" networks: - "VM Network" resourcePool: /<data_center>/host/<vcenter_cluster>/Resources zone: assisted-generated-zone nodeNetworking: external: {} internal: {} vcenters: - datacenters: - <data_center> server: <vcenter_address> kind: List metadata: resourceVersion: ""
将
<vcenter_address>
替换为您的 vCenter 地址。将<datacenter>
替换为 vCenter 数据中心的名称。将<datastore>
替换为 vCenter 数据存储的名称。将<folder>
替换为包含集群虚拟机的文件夹。将<vcenter_cluster>
替换为安装 OpenShift Container Platform 的 vSphere vCenter 集群。应用基础架构配置:
$ oc apply -f infrastructures.config.openshift.io.yaml --overwrite=true