apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: {{ include "gatewayName" . | trimPrefix "istio-" }}-listener-tcp-keepalive
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "kubezero-lib.labels" . | nindent 4 }}
spec:
  workloadSelector:
    labels:
      {{- include "gatewaySelectorLabels" . | nindent 6 }}
  configPatches:
  - applyTo: LISTENER
    patch:
      operation: MERGE
      value:
        socket_options:
          - level: 1 # SOL_SOCKET = 1
            name: 9 # SO_KEEPALIVE = 9
            int_value: 1
            state: STATE_PREBIND
          - level: 6 # IPPROTO_TCP = 6
            name: 4 # TCP_KEEPIDLE = 4
            int_value: 120
            state: STATE_PREBIND
          - level: 6 # IPPROTO_TCP = 6
            name: 5 # TCP_KEEPINTVL = 5
            int_value: 60
            state: STATE_PREBIND
