Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 通过istio在GCP上创建防火墙_Kubernetes_Google Cloud Platform_Google Kubernetes Engine_Istio - Fatal编程技术网

Kubernetes 通过istio在GCP上创建防火墙

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集群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实现吗?

AFAIK不可能仅从istio配置影响GCP防火墙上的istio入口网关负载平衡器默认规则


但是,

这种过滤可以通过使用istio策略来实现。因此,请求将到达
istio入口网关
,但如果IP地址未列入白名单,则将被策略拒绝

根据文件:

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

  • 验证您是否可以访问位于http://$GATEWAY\u URL/productpage的Bookinfo
    productpage
    。应用以下规则后,您将无法访问它

  • 在入口网关处为白名单子网
    “10.57.0.0\16”
    的适配器应用配置:

  • 混音器规则拒绝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 ]
    ---
    
  • 尝试访问
    http://$GATEWAY\u URL/productpage
    上的Bookinfo
    productpage
    ,并验证是否收到类似以下错误:
    PERMISSION\u DENIED:staticversion.istio-system:未列入白名单
  • 文档中的示例包含一部分,因此请确保满足的要求

    编辑:

    澄清一下,

    Istio和GCP防火墙规则在不同级别工作。Istio仅在其网格内启用,也就是说,无论您在何处注入侧车

    为了使istio入口网关工作,GCE提供了一个网络负载平衡器,它具有一些预配置的规则,完全独立于istio网格


    因此,基本上: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 ]
    ---