apiVersion: v1
kind: ConfigMap
metadata:
  name: envoy-conf
data:
  envoy.yaml: |
    static_resources:
      listeners:
      - address:
          socket_address:
            address: 0.0.0.0
            port_value: 50051 # <- grpc port direct foward
        filter_chains:
        - filters:
          - name: envoy.http_connection_manager
            config:
              access_log:
              - name: envoy.file_access_log
                config:
                  path: "/dev/stdout"
              codec_type: AUTO
              stat_prefix: ingress_http
              route_config:
                name: local_route
                virtual_hosts:
                - name: grpc # <- no meaning, just a name.
                  domains:
                  - "*"
                  routes:
                  - match:
                      prefix: "/"
                    route:
                      cluster: greet-grpc-svc # <- cluster name
              http_filters:
              - name: envoy.health_check
                config:
                  pass_through_mode: false
                  headers:
                  - name: ":path"
                    exact_match: "/healthz"
                  - name: "x-envoy-livenessprobe"
                    exact_match: "healthz"
              - name: envoy.router
                config: {}
      clusters:
      - name: greet-grpc-svc
        connect_timeout: 0.5s
        type: STRICT_DNS
        dns_lookup_family: V4_ONLY
        lb_policy: ROUND_ROBIN
        drain_connections_on_host_removal: true # <- must on grpc loadbalance with envoy. drain when pod was removed from backend service.
        http2_protocol_options: {}
        hosts:
          socket_address:
            #address: greet-grpc-svc.default.svc.cluster.local # <- if no namespace, `default` will be used.
            address: greet-grpc-svc.grpc-lab-nlb.svc.cluster.local # <- if you specify namespace `grpc-lab-nlb`, set here.
            port_value: 50051  # <- grpc port direct foward
        health_checks: # <- required for cluster health check.
          timeout: 1s
          interval: 10s
          unhealthy_threshold: 2
          healthy_threshold: 2
          grpc_health_check: {
            service_name: Check # <- set your grpc server pod's grpc health check servie_name. Normaly name as Check.
          }
    admin:
      access_log_path: "/dev/stdout"
      address:
        socket_address:
          address: 127.0.0.1
          port_value: 8001
