通过istio在GCP上创建防火墙

问题描述 投票:0回答:1

我的配置:GKE群集v.1.15.7-gke.23istio:1.4.3

Istio使用默认的防火墙规则以Loadbalacner的身份创建了istio-ingressgateway服务:

  • 类型:入口
  • 目标:GKE群集上的VMs
  • 过滤器:0.0.0.0/0
  • 协议/端口:tcp:15020,tcp:80,tcp:443,tcp:15029,tcp:15030,tcp:15031,tcp:15032,tcp:15443

我的目标是在规则上更新过滤器,仅允许从允许列表IP地址访问端点。

可以通过istio实现吗?

kubernetes google-cloud-platform google-kubernetes-engine istio
1个回答
1
投票

AFAIK不能仅通过istio配置来影响GCP防火墙上的istio-ingressgateway负载均衡器默认规则。


但是,

这种过滤可以通过使用istio策略来实现。这样,请求将到达istio-ingressgateway,但是如果IP地址未列入白名单,则策略将拒绝该请求。

根据istio文档:

Istio支持基于IP地址的白名单黑名单。您可以将Istio配置为接受或拒绝来自特定IP地址或子网的请求。

  1. 验证您可以访问在productpage找到的Bookinfo http://$GATEWAY_URL/productpage。一旦应用以下规则,您将无法访问它。

  2. 为在入口网关处将子网list列入白名单的"10.57.0.0\16"适配器应用配置:

$ kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.4/samples/bookinfo/policy/mixer-rule-deny-ip.yaml)

mixer-rule-deny-ip.yaml的内容:

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 ]
---
  1. 尝试访问productpage处的Bookinfo http://$GATEWAY_URL/productpage,并确认您收到类似以下错误:PERMISSION_DENIED:staticversion.istio-system:<your mesh source ip> is not whitelisted

文档中的示例具有Before you begin部分,因此请确保满足Enabling Policy Enforcement的要求。

© www.soinside.com 2019 - 2024. All rights reserved.