首页 > 解决方案 > 如何使用 python 删除 GKE(Google Kubernetes Engine)集群?

问题描述

我是 GKE-Python 的新手。我想使用 python 脚本删除我的 GKE(Google Kubernetes Engine)集群。我从google-cloud-container python 库中找到了一个 API delete_cluster()来删除 GKE 集群。 https://googleapis.dev/python/container/latest/index.html

但我不确定如何通过在 python 中传递所需的参数来使用该 API。任何人都可以用一个例子来解释我吗?

或者如果还有其他方法可以在python中删除GKE集群?

提前致谢。

标签: python-3.xkubernetesgoogle-cloud-platformcontainersgoogle-kubernetes-engine

解决方案


页面包含您尝试执行的命令的示例。

要提供命令成功所需的更多详细信息 - 您的环境需要包含环境变量,此页面包含有关如何执行此操作的说明。

一旦您的环境成功通过身份验证,我们就可以像这样运行删除集群命令 -

from google.cloud import container_v1

client = container_v1.ClusterManagerClient()

response = client.delete_cluster(name=projects/<project>/locations/<location>/clusters/<cluster>)

推荐阅读