×

删除使用安装程序配置的基础设施的集群

您可以从云中删除使用安装程序配置的基础设施的集群。

卸载后,检查您的云提供商是否存在任何未正确删除的资源,尤其是在使用用户配置的基础设施 (UPI) 集群时。安装程序可能没有创建某些资源,或者安装程序无法访问某些资源。

先决条件
  • 您拥有用于部署集群的安装程序副本。

  • 您拥有安装程序在创建集群时生成的的文件。

步骤
  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 安装程序。

使用 Cloud Credential Operator 实用程序删除 Amazon Web Services 资源

卸载使用在集群外部管理的短期凭据的 OpenShift Container Platform 集群后,您可以使用 CCO 实用程序 (ccoctl) 删除ccoctl在安装过程中创建的 Amazon Web Services (AWS) 资源。

先决条件
  • 提取并准备ccoctl二进制文件。

  • 卸载使用短期凭据的 AWS 上的 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 文档。

删除配置了 AWS 本地区域基础设施的集群

将集群安装到 Amazon Web Services (AWS) 中的现有虚拟专用云 (VPC) 后,并且您为每个本地区域位置设置了子网,您可以删除集群及其关联的任何 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. 删除本地区域子网的 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>
其他资源