kubernetes 在Istio中禁用集群内通信的代理协议

4ioopgfo  于 9个月前  发布在  Kubernetes
关注(0)|答案(1)|浏览(97)

我有istio安装在一个LoadBalancer与代理协议后面,所以我必须安装以下EnvoyProxy:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: proxy-protocol
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
    - applyTo: LISTENER
      patch:
        operation: MERGE
        value:
          listener_filters:
            - name: envoy.filters.listener.proxy_protocol
            - name: envoy.filters.listener.tls_inspector
---
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: ingressgateway-settings
  namespace: istio-system
spec:
  configPatches:
    - applyTo: NETWORK_FILTER
      match:
        listener:
          filterChain:
            filter:
              name: envoy.http_connection_manager
      patch:
        operation: MERGE
        value:
          name: envoy.http_connection_manager
          typed_config:
            "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
            skip_xff_append: false
            use_remote_address: true
            xff_num_trusted_hops: 1

字符串
一切正常,但问题是这也影响了集群内的通信。当在集群内通信时,我不想使用代理协议。这影响了我的用例,我想设置VirtualService,然后将请求路由到相关的服务,这些服务也是istio实体(特别是Istio VirtualService/ knative服务):

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: "app-virtual-service"
spec:
  gateways:
    - knative-serving/knative-local-gateway
    - "app-gateway"
  hosts:
    - hub.example.com
  http:
    # GraphQL API
    - match:
        - uri:
            prefix: "/graphql"
      rewrite:
        authority: app-api.app.svc.cluster.local
      route:
        - destination:
            host: app-api.app.svc.cluster.local
          weight: 100
    # Hall service
    - match:
        - uri:
            prefix: "/hall"
      rewrite:
        authority: app-hall.app.svc.cluster.local
      route:
        - destination:
            host: app-hall.app.svc.cluster.local
          weight: 100
    # Manager frontend
    - match:
        - uri:
            exact: /
        {{- range .Values.manager.paths }}
        - uri:
            prefix: {{ . | quote }}
        {{- end }}
      rewrite:
        authority: app-manager.app.svc.cluster.local
      route:
        - destination:
            host: app-manager.app.svc.cluster.local
          weight: 100


例如,每当我尝试查询http://hub.example.com/graphql时,它都会尝试在没有代理协议的情况下查询app-api.app.svc.cluster.local(这是Istio VirtualService)(当它由于规则而被期望时,或者至少这是我理解它的方式)。所以失败并出现以下错误:
upstream connect error or disconnect/reset before headers. reset reason: connection termination
如果我禁用代理规则,它就可以正常工作,如果我试图直接从LoadBalancer访问knative服务,它也可以工作。
当某个VirtualService试图将请求转发给另一个VirtualService时,它就不起作用了。
External LoadBalancer -> Istio Ingress LoadBalancer - Gateway - VirtualService(接受代理协议payload)-> End-service VirtualService(也接受代理协议payload,但之前的服务发送的是raw query)
有什么方法可以避免在集群通信中使用代理协议吗?我想过的可能的解决方案是创建多个网关,但我不确定我应该如何去做,并在过滤器中使用它。

ygya80vv

ygya80vv1#

在这个官方的Istio文档中,他们解释了如何绕过特定IP范围的代理,global.proxy.includeIPRangesglobal.proxy.excludeIPRanges选项将帮助您绕过envoy代理。在文档中,他们已经解释了如何绕过外部服务的代理,您需要执行相反的操作。检查群集的内部IP范围,并使用global.proxy.excludeIPRanges选项,然后将内部IP范围传递给此命令。如下面的命令中所述,

kubectl describe pod kube-apiserver -n kube-system | grep 'service-cluster-ip-range' 
#command for getting the IP range of the cluster

个字符

相关问题