Kubernetes 通过istio在GCP上创建防火墙
我的配置: GKE集群v。1.15.7-gke.23 istio:1.4.3 Istio使用默认防火墙规则作为Loadbalacner创建Istio入口网关服务:Kubernetes 通过istio在GCP上创建防火墙,kubernetes,google-cloud-platform,google-kubernetes-engine,istio,Kubernetes,Google Cloud Platform,Google Kubernetes Engine,Istio,我的配置: GKE集群v。1.15.7-gke.23 istio:1.4.3 Istio使用默认防火墙规则作为Loadbalacner创建Istio入口网关服务: 类型:入口 目标:GKE集群上的虚拟机 过滤器:0.0.0.0/0 协议/端口:tcp:15020、tcp:80、tcp:443、, tcp:15029,tcp:15030,tcp:15031,tcp:15032,tcp:15443 我的目标是更新规则中的过滤器,只允许从允许列表IP地址访问端点 可以通过istio实现吗?AFAI
- 类型:入口
- 目标:GKE集群上的虚拟机
- 过滤器:0.0.0.0/0
- 协议/端口:tcp:15020、tcp:80、tcp:443、, tcp:15029,tcp:15030,tcp:15031,tcp:15032,tcp:15443
可以通过istio实现吗?AFAIK不可能仅从istio配置影响GCP防火墙上的istio入口网关负载平衡器默认规则
但是, 这种过滤可以通过使用istio策略来实现。因此,请求将到达
istio入口网关
,但如果IP地址未列入白名单,则将被策略拒绝
根据文件:
Istio支持基于IP地址的白名单和黑名单。您可以将Istio配置为接受或拒绝来自特定IP地址或子网的请求
productpage
。应用以下规则后,您将无法访问它“10.57.0.0\16”
的适配器应用配置:apiVersion: config.istio.io/v1alpha2
kind: handler
metadata:
name: whitelistip
spec:
compiledAdapter: listchecker
params:
# providerUrl: ordinarily black and white lists are maintained
# externally and fetched asynchronously using the providerUrl.
overrides: ["10.57.0.0/16"] # overrides provide a static list
blacklist: false
entryType: IP_ADDRESSES
---
apiVersion: config.istio.io/v1alpha2
kind: instance
metadata:
name: sourceip
spec:
compiledTemplate: listentry
params:
value: source.ip | ip("0.0.0.0")
---
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
name: checkip
spec:
match: source.labels["istio"] == "ingressgateway"
actions:
- handler: whitelistip
instances: [ sourceip ]
---
http://$GATEWAY\u URL/productpage
上的Bookinfoproductpage
,并验证是否收到类似以下错误:PERMISSION\u DENIED:staticversion.istio-system:未列入白名单
因此,基本上:GCE防火墙规则只会影响连接到集群的网络负载平衡器,以便允许流量进入Istio网格,而Istio中的过滤规则只会在网格内的所有POD/服务/端点中工作。这并不能回答问题。您只需使Istio不接受某些特定IP范围的请求,但此防火墙规则仍然对所有人开放。您是对的。我编辑了我的答案来解决这个问题。
apiVersion: config.istio.io/v1alpha2
kind: handler
metadata:
name: whitelistip
spec:
compiledAdapter: listchecker
params:
# providerUrl: ordinarily black and white lists are maintained
# externally and fetched asynchronously using the providerUrl.
overrides: ["10.57.0.0/16"] # overrides provide a static list
blacklist: false
entryType: IP_ADDRESSES
---
apiVersion: config.istio.io/v1alpha2
kind: instance
metadata:
name: sourceip
spec:
compiledTemplate: listentry
params:
value: source.ip | ip("0.0.0.0")
---
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
name: checkip
spec:
match: source.labels["istio"] == "ingressgateway"
actions:
- handler: whitelistip
instances: [ sourceip ]
---