6.17. 在 AWS 上卸载集群

您可以删除部署到 Amazon Web Services (AWS) 的集群。

6.17.1. 删除使用安装程序置备的基础架构的集群

您可以从云中删除使用安装程序置备的基础架构的集群。

注意

卸载后,检查云供应商是否有未正确删除的资源,特别是在用户置备基础架构集群中。可能存在安装程序没有创建或安装程序无法访问的资源。

先决条件

  • 有用于部署集群的安装程序副本。
  • 有创建集群时安装程序生成的文件。

流程

  1. 在用来安装集群的计算机中,进入包含安装程序的目录,并运行以下命令:

    $ ./openshift-install destroy cluster \
    --dir <installation_directory> --log-level info 1 2
    1
    对于 <installation_directory>,请指定安装文件保存到的目录的路径。
    2
    要查看不同的详情,请指定 warndebugerror,而不是 info
    注意

    您必须为集群指定包含集群定义文件的目录。安装程序需要此目录中的 metadata.json 文件来删除集群。

  2. 可选:删除 <installation_directory> 目录和 OpenShift Container Platform 安装程序。

6.17.2. 使用 Cloud Credential Operator 实用程序删除 AWS 资源

要在通过带有 STS 的手动模式使用 Cloud Credential Operator(CCO)卸载 OpenShift Container Platform 集群后清除资源,您可以使用 CCO 实用程序(ccoctl)删除 ccoctl 在安装过程中创建的 AWS 资源。

先决条件

  • 提取并准备 ccoctl 二进制文件。
  • 通过带有 STS 的手动模式使用 CCO 安装 OpenShift Container Platform 集群。

流程

  • 删除 ccoctl 创建的 AWS 资源:

    $ ccoctl aws delete \
      --name=<name> \ 1
      --region=<aws_region> 2
    1
    <name> 与最初用于创建和标记云资源的名称匹配。
    2
    <aws_region> 是要删除云资源的 AWS 区域。

    输出示例:

    2021/04/08 17:50:41 Identity Provider object .well-known/openid-configuration deleted from the bucket <name>-oidc
    2021/04/08 17:50:42 Identity Provider object keys.json deleted from the bucket <name>-oidc
    2021/04/08 17:50:43 Identity Provider bucket <name>-oidc deleted
    2021/04/08 17:51:05 Policy <name>-openshift-cloud-credential-operator-cloud-credential-o associated with IAM Role <name>-openshift-cloud-credential-operator-cloud-credential-o deleted
    2021/04/08 17:51:05 IAM Role <name>-openshift-cloud-credential-operator-cloud-credential-o deleted
    2021/04/08 17:51:07 Policy <name>-openshift-cluster-csi-drivers-ebs-cloud-credentials associated with IAM Role <name>-openshift-cluster-csi-drivers-ebs-cloud-credentials deleted
    2021/04/08 17:51:07 IAM Role <name>-openshift-cluster-csi-drivers-ebs-cloud-credentials deleted
    2021/04/08 17:51:08 Policy <name>-openshift-image-registry-installer-cloud-credentials associated with IAM Role <name>-openshift-image-registry-installer-cloud-credentials deleted
    2021/04/08 17:51:08 IAM Role <name>-openshift-image-registry-installer-cloud-credentials deleted
    2021/04/08 17:51:09 Policy <name>-openshift-ingress-operator-cloud-credentials associated with IAM Role <name>-openshift-ingress-operator-cloud-credentials deleted
    2021/04/08 17:51:10 IAM Role <name>-openshift-ingress-operator-cloud-credentials deleted
    2021/04/08 17:51:11 Policy <name>-openshift-machine-api-aws-cloud-credentials associated with IAM Role <name>-openshift-machine-api-aws-cloud-credentials deleted
    2021/04/08 17:51:11 IAM Role <name>-openshift-machine-api-aws-cloud-credentials deleted
    2021/04/08 17:51:39 Identity Provider with ARN arn:aws:iam::<aws_account_id>:oidc-provider/<name>-oidc.s3.<aws_region>.amazonaws.com deleted

验证

  • 要验证资源是否已删除,请查询 AWS。如需更多信息,请参阅 AWS 文档。

6.17.3. 使用配置的 AWS Local Zone 基础架构删除集群

在 Amazon Web Services (AWS) 上安装集群后,进入现有的 Virtual Private Cloud (VPC),并为每个 Local Zone 位置设置子网,您可以删除集群以及与之关联的任何 AWS 资源。

该流程中的示例假设您使用 CloudFormation 模板创建了 VPC 及其子网。

先决条件

  • 您知道创建网络期间使用的 CloudFormation 堆栈 <local_zone_stack_name><vpc_stack_name> 的名称。您需要堆栈的名称来删除集群。
  • 您可以访问包含安装程序创建的安装文件的目录的权限。
  • 您的帐户包含一个策略,为您提供了删除 CloudFormation 堆栈的权限。

流程

  1. 进入包含存储的安装程序的目录,并使用 destroy cluster 命令删除集群:

    $ ./openshift-install destroy cluster --dir <installation_directory> \1
       --log-level=debug 2
    1
    对于 <installation_directory>,请指定保存安装程序创建的任何文件的目录。
    2
    要查看不同的日志详细信息,请指定 errorinfowarn,而不是 debug
  2. 删除 Local Zone 子网的 CloudFormation 堆栈:

    $ aws cloudformation delete-stack --stack-name <local_zone_stack_name>
  3. 删除代表 VPC 的资源堆栈:

    $ aws cloudformation delete-stack --stack-name <vpc_stack_name>

验证

  • 通过在 AWS CLI 中执行以下命令,检查您是否删除了堆栈资源。AWS CLI 输出没有模板组件。

    $ aws cloudformation describe-stacks --stack-name <local_zone_stack_name>
    $ aws cloudformation describe-stacks --stack-name <vpc_stack_name>

其他资源