apiVersion: v1
data:
  envoy.yaml: |-
    admin:
      access_log_path: "/dev/stdout"
      address:
        socket_address: { address: 127.0.0.1, port_value: 9901 }

    static_resources:
      listeners:
      - name: listener_0
        address:
          socket_address: { address: 0.0.0.0, port_value: 10000 }
        filter_chains:
        - filters:
          - name: envoy.http_connection_manager
            typed_config:
              "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
              stat_prefix: ingress_http
              codec_type: AUTO
              access_log:
              - name: envoy.file_access_log
                config:
                  path: "/dev/stdout"   
              route_config:
                name: local_route
                virtual_hosts:
                - name: local_service
                  domains: ["*"]
                  request_headers_to_add:
                  - header:
                      key: "authorization"
                      value: "Bearer eyJrIjoiMk5pMXVvNVNQSjA0MHk4MFpuWWZ2Y2J2cmlRRjFTekIiLCJuIjoicHVibGljIiwiaWQiOjF9" #Use an ENV var once this is created by Grafana
                    append: true
                  routes:
                  - match:
                      prefix: "/"
                    route: 
                      cluster: grafana 
              http_filters:
              - name: envoy.router
      clusters:
      - name: grafana
        connect_timeout: 0.25s
        type: STRICT_DNS
        lb_policy: ROUND_ROBIN
        load_assignment:
          cluster_name: grafana
          endpoints:
          - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: grafana
                    port_value: 3000
kind: ConfigMap
metadata:
  name: envoy-config