# https://www.envoyproxy.io/docs/envoy/v1.17.1/configuration/best_practices/edge#configuring-envoy-as-an-edge-proxy
# https://github.com/istio/istio/issues/24715
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "gatewayName" . | trimPrefix "istio-" }}-bootstrap-config
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
data:
  custom_bootstrap.json: |
    {
      "overload_manager": {
        "actions": [
          {
            "name": "envoy.overload_actions.shrink_heap",
            "triggers": [
              {
                "name": "envoy.resource_monitors.fixed_heap",
                "threshold": {
                  "value": 0.92
                }
              }
            ]
          },
          {
            "name": "envoy.overload_actions.stop_accepting_requests",
            "triggers": [
              {
                "name": "envoy.resource_monitors.fixed_heap",
                "threshold": {
                  "value": 0.98
                }
              }
            ]
          }
        ],
        "refresh_interval": "0.25s",
        "resource_monitors": [
          {
            "name": "envoy.resource_monitors.fixed_heap",
            "typed_config": {
              "@type": "type.googleapis.com/envoy.extensions.resource_monitors.fixed_heap.v3.FixedHeapConfig",
              "max_heap_size_bytes": 536870912
            }
          }
        ]
      },
      "layeredRuntime": {
        "layers": [
          {
            "name": "static_layer_0",
            "staticLayer": {
              "envoy.resource_monitors.downstream_connections": 50000
            }
          }
        ]
      }
    }
