为每个虚拟主机应用envoyfilter ext_authz

时间:2020-06-08 20:22:17

标签: kubernetes filter istio envoyproxy

我有ext_authz过滤器,

kind: EnvoyFilter
metadata:
  name: authn-filter
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: "envoy.http_connection_manager"
            subFilter:
              name: "envoy.router"
    patch:
      operation: INSERT_BEFORE
      value:
        name: envoy.ext_authz
        config:
          http_service:
            server_uri:
              uri: http://authservice.istio-system.svc.cluster.local
              cluster: outbound|8080||authservice.istio-system.svc.cluster.local
              failure_mode_allow: false
              timeout: 10s
            authorization_request:
              allowed_headers:
                patterns:
                - exact: "cookie"
                - exact: "X-Auth-Token"
            authorization_response:
              allowed_upstream_headers:
                patterns:
                - exact: "kubeflow-userid"
          status_on_error:
            code: GatewayTimeout

问题在于它适用于同一入口下的所有虚拟主机。我只想将其应用于特定的虚拟主机。目前,我正在使用以下方法排除某些主机:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: bypass-auth-filter
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
  - applyTo: VIRTUAL_HOST
    match:
      routeConfiguration:
        vhost:
          name: a.example.com:80
    patch:
        operation: MERGE
        value:
          per_filter_config:
            envoy.ext_authz:
              disabled: true

但是,如果可以的话,我希望将过滤器应用于特定的虚拟主机,而不必排除不需要身份验证的每台主机(更像是白名单解决方案,而不是黑名单)

任何提示将不胜感激!

0 个答案:

没有答案