---
apiVersion: v1
kind: ConfigMap
metadata:
  name: envoy-config
  namespace: apc
data:
  config-file: |
        static_resources:
          listeners:
            - address:
                socket_address:
                  address: 0.0.0.0
                  port_value: 5000
              filter_chains:
                - filters:
                    - name: envoy.filters.network.http_connection_manager
                      typed_config:
                        '@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
                        codec_type: auto
                        stat_prefix: ingress_http
                        route_config:
                          name: local_route
                          virtual_hosts:
                            - name: backend
                              domains:
                                - '*'
                              routes:
                                - match:
                                    path_separated_prefix: /user
                                  route:
                                    cluster: user-service
                                - match:
                                    path_separated_prefix: /submission
                                  route:
                                    cluster: submission-service
                                - match:
                                    path_separated_prefix: /tasks
                                  route:
                                    cluster: submission-service
                                - match:
                                    path_separated_prefix: /cases
                                  route:
                                    cluster: test-service
                                - match:
                                    path_separated_prefix: /test
                                  route:
                                    cluster: test-service
                        http_filters:
                          - name: envoy.filters.http.router
                            typed_config:
                              '@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
                        access_log:
                          - name: envoy.access_loggers.file
                            typed_config:
                              '@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
                              path: /dev/stdout
        
          clusters:
            - name: user-service
              type: strict_dns
              load_assignment:
                cluster_name: user-service
                endpoints:
                  - lb_endpoints:
                      - endpoint:
                          address:
                            socket_address:
                              address: userservice-service.apc
                              port_value: 80
            - name: test-service
              type: strict_dns
              load_assignment:
                cluster_name: test-service
                endpoints:
                  - lb_endpoints:
                      - endpoint:
                          address:
                            socket_address:
                              address: testservice-service.apc
                              port_value: 80
            - name: submission-service
              type: strict_dns
              load_assignment:
                cluster_name: submission-service
                endpoints:
                  - lb_endpoints:
                      - endpoint:
                          address:
                            socket_address:
                              address: submissionsservice-service.apc
                              port_value: 80
