如何通过Terraform将GKE节点添加为Google Cloud Armor防护目标?
GKE集群Cloud Armor防护目标关联的Terraform实现问题
我搭建了一个GKE集群,部署了若干工作负载及对应的NodePort服务,并且提前创建了会自动生成负载均衡器的Ingress。目前已经通过Terraform配置了Cloud Armor安全策略,具体代码如下:
白名单规则(指定IP地址)
resource "google_compute_security_policy" "my_security_policy" { name = "my-security-policy" project = var.project_id rule { action = "allow" priority = 1000 description = "Whitelist Your IP" match { versioned_expr = "SRC_IPS_V1" config { src_ip_ranges = ["x.x.x.x"] } } }
黑名单规则(拦截其他所有流量)
rule { action = "deny(403)" priority = 2000 description = "Block All Other Traffic" match { versioned_expr = "SRC_IPS_V1" config { src_ip_ranges = ["x.x.x.x"] } } }
默认允许规则
rule { action = "allow" priority = 2147483647 description = "Default allow-all rule" match { versioned_expr = "SRC_IPS_V1" config { src_ip_ranges = ["*"] } } } }
我可以通过手动点击操作将GKE节点添加为Cloud Armor的防护目标,但找不到通过Terraform实现该操作的方法,这个问题和GitHub Issue#4973一致,但目前还没找到解决方案。
内容的提问来源于stack exchange,提问作者Saikiran Tamide
相关产品推荐
相关产品推荐

