1 回答

TA贡献1847条经验 获得超7个赞
gcloud CLI我不熟悉 Python,但如果您想按照GKE 文档列出它们。
$ gcloud compute firewall-rules list
在我的项目中,我有大约 46 条防火墙规则:
$ gcloud compute firewall-rules list | wc -l
To show all fields of the firewall, please show in JSON format: --format=json
To show all fields in table format, please see the examples in --help.
46
如果你想获得特定于你的集群的防火墙规则,你需要使用类似的东西:
$ gcloud compute firewall-rules list --project <project-name> --filter="name~gke-<your-cluster-name>-[0-9a-z]*"
在我的例子中,它只为这个测试集群指定了 3 条规则cluster。
$ gcloud compute firewall-rules list --project <myproject> --filter="name~gke-cluster-[0-9a-z]*"
NAME NETWORK DIRECTION PRIORITY ALLOW DENY DISABLED
gke-cluster-XXX-all default INGRESS 1000 tcp,udp,XXX False
gke-cluster-XXX-ssh default INGRESS 1000 tcp:XX False
gke-cluster-XXX-vms default INGRESS 1000 icmp,tcp:1-XXXXX,udp:1-XXXXX False
添加回答
举报