美文网首页
istio includeIPRanges includeOut

istio includeIPRanges includeOut

作者: Yellowtail | 来源:发表于2019-06-26 09:59 被阅读0次

    概述

    在安装和使用 istio 的过程中,接触到了 includeIPRangesincludeOutboundIPRanges 两个概念
    分享、记录一下坑和对其的认识
    只是对一些经验的分享,不涉及具体概念和原理哦

    includeIPRanges

    这个是一个安装参数,全称是 global.proxy.includeIPRanges
    默认值是 *

    默认值的意思是说,Envoy 对所有的请求进行劫持
    此时,部署在istio里的服务是无法访问外部服务的,必须要配置 ServiceEntry 之类的才可以

    如果在安装的时候,把集群ip设置到这个值,那么就可以阻止Envoy 对外部请求的劫持
    也就实现了随意访问外部服务的功能,如果你需要的话

    详见 中文文档

    includeOutboundIPRanges

    这个是一个 ConfigMap 注解参数,全称是 traffic.sidecar.istio.io/includeOutboundIPRanges

    查看命令是
    kubectl get cm -n istio-system istio-sidecar-injector -o yaml

    作用是 集群内服务间调用 流量策略 (大概是这么个意思,具体的也不是很懂)

    • traffic.sidecar.istio.io/includeOutboundIPRanges
      这个是阻止ip范围
      (不允许这个范围内的pod/服务进行服务调用)
    • traffic.sidecar.istio.io/excludeOutboundIPRanges
      这个是放行ip范围

    这里没有配置好的时候,会发生服务间无法调用的问题,当用curl 测试的时候,会报
    curl: (56) Recv failure: Connection reset by peer

    如以下命令

    [root@izwz9xxxxxx]# kubectl -n backend exec -it $(kubectl -n backend get pod -l app=sleep -o jsonpath='{.items[0].metadata.name}') -c sleep -- curl -v  proxy-b.backend:8080/
    *   Trying 172.23.8.120...
    * TCP_NODELAY set
    * Connected to proxy-b.backend (172.23.8.120) port 8080 (#0)
    > GET / HTTP/1.1
    > Host: proxy-b.backend:8080
    > User-Agent: curl/7.60.0
    > Accept: */*
    >
    * Recv failure: Connection reset by peer
    * stopped the pause stream!
    * Closing connection 0
    curl: (56) Recv failure: Connection reset by peer
    command terminated with exit code 56  
    

    一般来说,没有特殊需求的时候,
    includeOutboundIPRanges 这个可以设置为空 ""
    excludeOutboundIPRanges 这个可以设置为所有 "*" ,也可以把pod ip地址和service ip地址填进去

    image.png

    上图是我们自己集群的配置
    那么 excludeOutboundIPRanges 可以设置为 172.22.0.0/16,172.23.0.0/20

    注意
    修改这个配置之后,
    首先需要重启 istio-sidecar-injector这个pod
    然后重启你自己的pod

    重启完成之后再验证一下

    [root@izwz98xxxxx]# kubectl -n backend exec -it $(kubectl -n backend get pod -l app=sleep -o jsonpath='{.items[0].metadata.name}') -c sleep -- curl -v  proxy-b.backend:8080/
    *   Trying 172.23.8.120...
    * TCP_NODELAY set
    * Connected to proxy-b.backend (172.23.8.120) port 8080 (#0)
    > GET / HTTP/1.1
    > Host: proxy-b.backend:8080
    > User-Agent: curl/7.60.0
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < content-type: application/json; charset=utf-8
    < date: Wed, 26 Jun 2019 04:40:25 GMT
    < content-length: 38
    < x-envoy-upstream-service-time: 135
    < server: istio-envoy
    < x-envoy-decorator-operation: proxy-b.backend.svc.cluster.local:8080/*
    <
    {"message":"proxy is ok","type":"ok"}
    * Connection #0 to host proxy-b.backend left intact
    

    相关文章

      网友评论

          本文标题:istio includeIPRanges includeOut

          本文链接:https://www.haomeiwen.com/subject/ndeqcctx.html