apiVersion: v1
kind: ConfigMap
metadata:
  name: envoy-config-p-front-envoy
  labels:
    name: envoy-config-p-front-envoy
data:
  config: |-
    ---
    static_resources:
      listeners:
      - address:
          socket_address:
            address: 0.0.0.0
            port_value: 80
        filter_chains:
        - filters:
          - name: envoy.http_connection_manager
            config:
              generate_request_id: true
              tracing:
                operation_name: egress
              codec_type: auto
              stat_prefix: ingress_http
              route_config:
                name: p-service1-route
                virtual_hosts:
                - name: p-service1-vh
                  domains:
                  - "*"
                  routes:
                  - match:
                      prefix: "/"
                    route:
                      cluster: p-service1-envoy
                    decorator:
                      operation: p-service1-call
              http_filters:
              - name: envoy.router
                config: {}
      - address:
          socket_address:
            address: 0.0.0.0
            port_value: 8080
        filter_chains:
        - filters:
          - name: envoy.http_connection_manager
            config:
              generate_request_id: true
              tracing:
                operation_name: egress
              codec_type: auto
              stat_prefix: ingress_http
              route_config:
                name: p-grpc-wrapper-route
                virtual_hosts:
                - name: p-grpc-wrapper-vh
                  domains:
                  - "*"
                  routes:
                  - match:
                      prefix: "/"
                    route:
                      cluster: p-grpc-service-envoy
                    decorator:
                      # #Note: operations are case insensitive.
                      operation: p-grpc-service-call
              http_filters:
              - name: envoy.router
                config: {}
      - address:
          socket_address:
            address: 0.0.0.0
            port_value: 8090
        filter_chains:
        - filters:
          - name: envoy.http_connection_manager
            config:
              generate_request_id: true
              tracing:
                operation_name: egress
              codec_type: auto
              stat_prefix: ingress_http
              route_config:
                name: p-grpc-wrapper-route
                virtual_hosts:
                - name: p-grpc-wrapper-vh
                  domains:
                  - "*"
                  routes:
                  - match:
                      prefix: "/"
                    route:
                      cluster: p-grpc-wrapper-envoy
                    decorator:
                      operation: p-grpc-wrapper-call
              http_filters:
              - name: envoy.router
                config: {}
      - address: # #Note: This is an example for passive routing. ie: Routing traffic without doing anything to it.
          socket_address:
            address: 0.0.0.0
            port_value: 9411
        filter_chains:
        - filters:
          - name: envoy.http_connection_manager
            config:
              codec_type: auto
              stat_prefix: ingress_http
              route_config:
                name: zipkin-route
                virtual_hosts:
                - name: zipkin-vh
                  domains:
                  - "*"
                  routes:
                  - match:
                      prefix: "/"
                    route:
                      cluster: zipkin
              http_filters:
              - name: envoy.router
                config: {}
      clusters:
      - name: p-service1-envoy
        connect_timeout: 0.250s
        type: strict_dns
        lb_policy: round_robin
        http2_protocol_options: {}
        hosts:
        - socket_address:
            address: p-service1
            port_value: 80
      - name: p-grpc-service-envoy
        connect_timeout: 0.250s
        type: strict_dns
        lb_policy: round_robin
        http2_protocol_options: {}
        hosts:
        - socket_address:
            address: p-grpc-service
            port_value: 80
      - name: p-grpc-wrapper-envoy
        connect_timeout: 0.250s
        type: strict_dns
        lb_policy: round_robin
        http2_protocol_options: {}
        hosts:
        - socket_address:
            address: p-grpc-wrapper
            port_value: 80
      - name: statsd-exporter
        connect_timeout: 1s
        type: strict_dns
        lb_policy: round_robin
        hosts:
        - socket_address:
            address: statsd-exporter
            port_value: 9125
      - name: zipkin
        connect_timeout: 1s
        type: strict_dns
        lb_policy: round_robin
        hosts:
        - socket_address:
            address: zipkin
            port_value: 9411
    tracing:
      http:
        name: envoy.zipkin
        config:
          collector_cluster: zipkin
          collector_endpoint: "/api/v1/spans"
    stats_sinks:
      - name: envoy.statsd
        config:
          tcp_cluster_name: statsd-exporter
          # address: # #Pending: Use UDP for better performance, if possible.
          #   socket_address:
          #     protocol: UDP
          #     address: 127.0.0.1
          #     port_value: 8125
    stats_config: {} # #Check: https://www.envoyproxy.io/docs/envoy/v1.5.0/api-v2/bootstrap.proto#envoy-api-msg-statsconfig
    stats_flush_interval: 5s
    admin:
      access_log_path: "/dev/null"
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 8001
