【问题标题】:Whitelisting IP addresses for network traffic through Istio gateways通过 Istio 网关将网络流量的 IP 地址列入白名单
【发布时间】:2019-04-19 22:30:46
【问题描述】:

我尝试使用 this 示例将我的 kubernetes 集群的传入流量中的 IP 地址列入白名单:

虽然这按预期工作,但想更进一步,尝试在设置 Istio 规则时是否可以使用 istio 网关或虚拟服务,而不是 Loadbalancer(ingressgateway)。

apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
  name: checkip
  namespace: my-namespace
spec:
  match: source.labels["app"] == "my-app"
  actions:
  - handler: whitelistip.listchecker
    instances:
    - sourceip.listentry
---

其中my-app 属于具有特定主机和端口的kind: Gateway,并标记为app=my-app

我正在使用 istio 版本 1.1.1 此外,我的集群的所有 istio 系统都在几乎所有服务 pod 上运行 envoy sidecar。

【问题讨论】:

  • 那么你的问题是什么?我认为将 Istio Ingress Gateway 与 Istio 策略结合使用没有任何问题。
  • 问题是当我使用标签匹配器而不是负载均衡器指向网关时,它不起作用。所以 source.label 必须指向入口 lb 本身才能工作。我不能在网关上配置它吗?想象一个实例,我希望有多个网关及其自己的规则与同一个负载均衡器关联。
  • Istio Ingress Gateway pod 已经有了自己的标签,其中之一是 istio=ingress-gateway。我想你可以用那个。希望对您有所帮助。

标签: kubernetes istio whitelist


【解决方案1】:

你混淆了一件事,在上面的规则中,match: source.labels["app"] == "my-app" 不是指任何资源的标签,而是指 pod 的标签。

来自OutputTemplate Documentation

sourceLabels |指源 pod 标签。 属性绑定可以使用 $out.sourcelabels 引用该字段

您可以通过以下方式查找带有“app=istio-ingressgateway”标签的资源来验证:

kubectl get pods,svc -n istio-system -l "app=istio-ingressgateway" --show-labels

您可以查看来自 istio 的关于 Mixer Adapter Model 的 blog,以了解完整的混合器模型、其处理程序、实例和规则。

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    • 2012-11-29
    • 2021-01-06
    • 2019-02-03
    相关资源
    最近更新 更多