7.3. 使用 Cloud Credential Operator 工具更新云供应商资源

升级使用 CCO 实用程序 (ccoctl) 配置的 OpenShift Container Platform 集群的过程与在安装过程中创建云供应商资源类似。

注意

默认情况下,ccoctl 在运行命令的目录中创建对象。要在其他目录中创建对象,请使用 --output-dir 标志。此流程使用 <path_to_ccoctl_output_dir> 来引用这个目录。

在 AWS 集群中,一些 ccoctl 命令会发出 AWS API 调用来创建或修改 AWS 资源。您可以使用 --dry-run 标志来避免 API 调用。使用此标志可在本地文件系统中创建 JSON 文件。您可以使用 --cli-input-json 参数查看和修改 JSON 文件,然后使用 AWS CLI 工具应用它们。

先决条件

  • 获取您要升级到的版本的 OpenShift Container Platform 发行镜像。
  • 从发行镜像中提取并准备 ccoctl 二进制文件。

流程

  1. 运行以下命令,从 OpenShift Container Platform 发行镜像中提取 CredentialsRequest 自定义资源 (CR) 列表:

    $ oc adm release extract --credentials-requests \
      --cloud=<provider_type> \
      --to=<path_to_directory_with_list_of_credentials_requests>/credrequests \
      quay.io/<path_to>/ocp-release:<version>

    其中:

    • <provider_type> 是云供应商的值。有效值为 alibabacloudawsgcpibmcloudnutanix
    • credrequests 是存储 CredentialsRequest 对象列表的目录。如果该目录不存在,此命令就会创建该目录。
  2. 对于发行镜像中的每个 CredentialsRequest CR,请确保集群中存在与 spec.secretRef.namespace 字段中的文本匹配的命名空间。此字段是保存凭证配置的生成的 secret 的位置。

    AWS CredentialsRequest 对象示例

    apiVersion: cloudcredential.openshift.io/v1
    kind: CredentialsRequest
    metadata:
      name: cloud-credential-operator-iam-ro
      namespace: openshift-cloud-credential-operator
    spec:
      providerSpec:
        apiVersion: cloudcredential.openshift.io/v1
        kind: AWSProviderSpec
        statementEntries:
        - effect: Allow
          action:
          - iam:GetUser
          - iam:GetUserPolicy
          - iam:ListAccessKeys
          resource: "*"
      secretRef:
        name: cloud-credential-operator-iam-ro-creds
        namespace: openshift-cloud-credential-operator 1

    1
    此字段指示需要存在的命名空间来存放生成的 secret。

    其他平台的 CredentialsRequest CR 具有与不同平台值类似的格式。

  3. 对于任何集群的 CredentialsRequest CR 还没有在 spec.secretRef.namespace 中指定的命名空间,运行以下命令创建命名空间:

    $ oc create namespace <component_namespace>
  4. 通过为您的云供应商运行命令,使用 ccoctl 工具处理 credrequests 目录中的所有 CredentialsRequest 对象。以下命令处理 CredentialsRequest 对象:

    • Alibaba Cloud: ccoctl alibabacloud create-ram-users
    • Amazon Web Services (AWS): ccoctl aws create-iam-roles
    • Google Cloud Platform (GCP): ccoctl gcp create-all
    • IBM Cloud: ccoctl ibmcloud create-service-id
    • Nutanix: ccoctl nutanix create-shared-secrets
    重要

    有关所需参数和特殊注意事项,请参阅云供应商的安装内容中的 ccoctl 工具说明。

    对于每个 CredentialsRequest 对象,ccoctl 会创建所需的供应商资源和 OpenShift Container Platform 发行镜像中的每个 CredentialsRequest 对象中定义的权限策略。

  5. 运行以下命令,将 secret 应用到集群:

    $ ls <path_to_ccoctl_output_dir>/manifests/*-credentials.yaml | xargs -I{} oc apply -f {}

验证

您可以通过查询云供应商来验证是否已创建所需的供应商资源和权限策略。如需更多信息,请参阅有关列出角色或服务帐户的云供应商文档。

后续步骤

  • 更新 upgradeable-to 注解,以指示集群已准备好升级。