apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: {{ include "gatewayName" . | trimPrefix "istio-" }}-proxy-protocol
  namespace: {{ .Release.Namespace }}
  labels:
    {{ include "kubezero-lib.labels" . | nindent 4 }}
spec:
  workloadSelector:
    labels:
      {{- include "gatewaySelectorLabels" . | nindent 6 }}
  configPatches:
  - applyTo: LISTENER
    patch:
      operation: MERGE
      value:
        listener_filters:
        {{- if .Values.proxyProtocol }}
        - name: envoy.filters.listener.proxy_protocol
          typed_config:
            "@type": type.googleapis.com/envoy.extensions.filters.listener.proxy_protocol.v3.ProxyProtocol
          filter_disabled:
            destination_port_range:
              start: 1025
              end: 1026
        {{- end }}
        - name: envoy.filters.listener.tls_inspector
          typed_config:
            "@type": type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector
          filter_disabled:
            destination_port_range:
              start: 1025
              end: 1026
