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
添加回答
舉報