{
  "node": {
    "id": "{{ .nodeID }}",
    "cluster": "{{ .cluster }}",
{{ if .zone }}
    "locality": {
        "zone": "{{ .zone }}"
    },
{{ end }}
    "metadata": {
{{- range $a, $s := .meta }}
          "{{$a}}": "{{$s}}",
{{- end}}
      "istio": "sidecar"
    }
  },
  "stats_config": {
    "use_all_default_tags": false
  },
  "admin": {
    "access_log_path": "/dev/stdout",
    "address": {
      "socket_address": {
        "address": "127.0.0.1",
        "port_value": 15000
      }
    }
  },
  "dynamic_resources": {
    "lds_config": {
        "ads": {}
    },
    "cds_config": {
        "ads": {}
    },
    "ads_config": {
      "api_type": "GRPC",
      "refresh_delay": {{ .refresh_delay }},
      "grpc_services": [
        {
          "envoy_grpc": {
            "cluster_name": "xds-grpc"
          }
        }
      ]
    }
  },
  "static_resources": {
    "clusters": [
    {
    "name": "xds-grpc",
    "type": "STRICT_DNS",
    "connect_timeout": {{ .connect_timeout }},
    "lb_policy": "ROUND_ROBIN",
{{ if eq .config.ControlPlaneAuthPolicy 1 }}
      "tls_context": {
        "common_tls_context": {
          "alpn_protocols": "h2",
          "tls_certificates": {
            "certificate_chain": {
              "filename": "/etc/certs/cert-chain.pem"
            },
            "private_key": {
              "filename": "/etc/certs/key.pem"
            }
          },
          "validation_context": {
            "trusted_ca": {
              "filename": "/etc/certs/root-cert.pem"
            },
            "verify_subject_alt_name": [
              {{- range $a, $s := .pilot_SAN }}
              "{{$s}}"
              {{- end}}
            ]
          }
        }
      },
{{ end }}
    "hosts": [
    {
    "socket_address": {{ .pilot_grpc_address }}
    }
    ],
    "circuit_breakers": {
        "thresholds": [
      {
        "priority": "default",
        "max_connections": "100000",
        "max_pending_requests": "100000",
        "max_requests": "100000"
      },
      {
        "priority": "high",
        "max_connections": "100000",
        "max_pending_requests": "100000",
        "max_requests": "100000"
      }]
    },
    "upstream_connection_options": {
      "tcp_keepalive": {
        "keepalive_time": 300
      }
    },
    "http2_protocol_options": { }
    }

    {{ if .zipkin }}
    ,
      {
        "name": "zipkin",
        "type": "STRICT_DNS",
        "connect_timeout": {
          "seconds": 1
        },
        "lb_policy": "ROUND_ROBIN",
        "hosts": [
          {
            "socket_address": {{ .zipkin }}
          }
        ]
      }
      {{ end }}
    ]
  },
  {{ if .zipkin }}
  "tracing": {
    "http": {
      "name": "envoy.zipkin",
      "config": {
        "collector_cluster": "zipkin"
      }
    }
  },
  {{ end }}
  {{ if .statsd }}
  "stats_sinks": [
    {
      "name": "envoy.statsd",
      "config": {
        "address": {
          "socket_address": {{ .statsd }}
        }
      }
    }
  ]
{{ end }}
}
