搜索

14.2. 使用 CLI 的 vSphere 安装后配置

download PDF

在启用了平台集成功能的 vSphere 上使用 Assisted Installer 安装 OpenShift Container Platform 集群后,您必须手动更新以下 vSphere 配置设置:

  • vCenter 用户名
  • vCenter 密码
  • vCenter 地址
  • vCenter 集群
  • 数据中心
  • 数据存储
  • 目录

先决条件

流程

  1. 为 vCenter 生成 base64 编码的用户名和密码:

    $ echo -n "<vcenter_username>" | base64 -w0

    <vcenter_username> 替换为您的 vCenter 用户名。

    $ echo -n "<vcenter_password>" | base64 -w0

    <vcenter_password> 替换为您的 vCenter 密码。

  2. 备份 vSphere 凭证:

    $ oc get secret vsphere-creds -o yaml -n kube-system > creds_backup.yaml
  3. 编辑 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 编码版本。

  4. 替换 vSphere 凭证:

    $ oc replace -f vsphere-creds.yaml
  5. 重新部署 kube-controller-manager pod:

    $ oc patch kubecontrollermanager cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$( date --rfc-3339=ns )"'"}}' --type=merge
  6. 备份 vSphere 云供应商配置:

    $ oc get cm cloud-provider-config -o yaml -n openshift-config > cloud-provider-config_backup.yaml
  7. 编辑云供应商配置:

    $ 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> 替换为包含集群虚拟机的文件夹。

  8. 应用云供应商配置:

    $ oc apply -f cloud-provider-config.yaml
  9. 使用 uninitialized 污点为集群加污点:

    重要

    如果要安装 OpenShift Container Platform 4.13 或更高版本,请执行以下的第 9 步到第 12 步。

    1. 识别要加污点的节点:

      $ oc get nodes
    2. 对每个节点运行以下命令:

      $ 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

  10. 备份基础架构配置:

    $ oc get infrastructures.config.openshift.io -o yaml > infrastructures.config.openshift.io.yaml.backup
  11. 编辑基础架构配置:

    $ 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 集群。

  12. 应用基础架构配置:

    $ oc apply -f infrastructures.config.openshift.io.yaml --overwrite=true
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.