如何以编程方式检查 GKE 集群是否正在使用次要 IP 服务范围?

huangapple go评论59阅读模式
英文:

How do I programmatically check if a secondary ip service range is in use by a GKE cluster?

问题

我预先为我的GKE集群创建了辅助范围以供使用。

我如何以编程方式检查辅助范围当前是否被集群使用或空闲?

我使用Python API。

我甚至不知道如何列出VPC中的辅助范围。查看文档,我唯一看到与VPC有关的事情是VPC访问连接器。

英文:

I pre-create secondary ranges for my GKE clusters to use.

How do I programmatically check if a secondary range is currently in use by a cluster or is free?

I use the python API.

I can't even see how to list secondary ranges in a VPC. Looking at the docs the only thing I see remotely related to VPC is for VPC access connectors:

如何以编程方式检查 GKE 集群是否正在使用次要 IP 服务范围?

答案1

得分: 2

The VPC components are part of the google-cloud-compute, you should check the SubnetworksClient

The SubnetworkSecondaryRange is an attribute of the class Subnetwork

如何以编程方式检查 GKE 集群是否正在使用次要 IP 服务范围?

There is no flag "use" in the secondary ranges because the secondary ranges can be used in more than one cluster, because of that you need to implement some logic to loop through all the clusters and check for the secondary ranges in use.

英文:

The VPC components are part of the google-cloud-compute you should check the SubnetworksClient

The SubnetworkSecondaryRange is an attribute of the class Subnetwork

如何以编程方式检查 GKE 集群是否正在使用次要 IP 服务范围?

There is no flag "use" in the secondary ranges because the secondary ranges can be used in more than one cluster, because of that you need to implement some logic to loop through all the clusters and check for the secondary ranges in use.

huangapple
  • 本文由 发表于 2023年4月19日 23:07:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056098.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定