Proxy Defaults

v1.8.4+: On Kubernetes, the ProxyDefaults custom resource is supported in Consul versions 1.8.4+.
v1.5.0+: On other platforms, this config entry is supported in Consul versions 1.5.0+.

The proxy-defaults config entry kind (ProxyDefaults on Kubernetes) allows for configuring global config defaults across all services for Connect proxy configuration. Currently, only one global entry is supported.

Sample Config Entries

Default protocol

Set the default protocol for all sidecar proxies:

Proxy Defaults - 图1

Proxy Defaults - 图2

Set the default protocol for all sidecar proxies:

HCL

Proxy Defaults - 图3

  • HCL
  • Kubernetes YAML
  • JSON
  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. Config {
  4. protocol = "http"
  5. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. spec:
  6. config:
  7. protocol: http
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "Config": {
  5. "protocol": "http"
  6. }
  7. }

Prometheus

Expose prometheus metrics:

HCL

Proxy Defaults - 图4

  • HCL
  • Kubernetes YAML
  • JSON
  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. Config {
  4. envoy_prometheus_bind_addr = "0.0.0.0:9102"
  5. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. spec:
  6. config:
  7. envoy_prometheus_bind_addr: '0.0.0.0:9102'
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "Config": {
  5. "envoy_prometheus_bind_addr": "0.0.0.0:9102"
  6. }
  7. }

Proxy-specific defaults

Set proxy-specific defaults:

HCL

Proxy Defaults - 图5

  • HCL
  • Kubernetes YAML
  • JSON
  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. Config {
  4. local_connect_timeout_ms = 1000
  5. handshake_timeout_ms = 10000
  6. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. spec:
  6. config:
  7. local_connect_timeout_ms: 1000
  8. handshake_timeout_ms: 10000
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "Config": {
  5. "local_connect_timeout_ms": 1000,
  6. "handshake_timeout_ms": 10000
  7. }
  8. }

Available Fields

Proxy Defaults - 图6

Proxy Defaults - 图7

  • Kind - Must be set to proxy-defaults

  • Name - Must be set to global

  • Namespace (string: "default")

    Enterprise

    - Specifies the namespace the config entry will apply to.

  • Meta (map<string|string>: nil) - Specifies arbitrary KV metadata pairs. Added in Consul 1.8.4.

  • Config (map[string]arbitrary) - An arbitrary map of configuration values used by Connect proxies. The available configurations depend on the Connect proxy you use. Any values that your proxy allows can be configured globally here. To explore these options please see the documentation for your chosen proxy.

  • Mode (string: "") - One of direct or transparent. transparent represents that inbound and outbound application traffic is being captured and redirected through the proxy. This mode does not enable the traffic redirection itself. Instead it signals Consul to configure Envoy as if traffic is already being redirected. direct represents that the proxy’s listeners must be dialed directly by the local application and other proxies. Added in v1.10.0.

  • TransparentProxy (TransparentProxyConfig: <optional>) - Controls configuration specific to proxies in transparent mode. Added in v1.10.0.

    • OutboundListenerPort (int: "15001") - The port the proxy should listen on for outbound traffic. This must be the port where outbound application traffic is captured and redirected to.

    • DialedDirectly (bool: false) - Determines whether this proxy instance’s IP address can be dialed directly by transparent proxies. Typically transparent proxies dial upstreams using the “virtual” tagged address, which load balances across instances. Dialing individual instances can be helpful in cases like stateful services such as a database cluster with a leader.

  • MeshGateway (MeshGatewayConfig: <optional>) - Controls the default mesh gateway configuration for all proxies. Added in v1.6.0.

    • Mode (string: "") - One of none, local, or remote.
  • Expose (ExposeConfig: <optional>) - Controls the default expose path configuration for Envoy. Added in v1.6.2.

    Exposing paths through Envoy enables a service to protect itself by only listening on localhost, while still allowing non-Connect-enabled applications to contact an HTTP endpoint. Some examples include: exposing a /metrics path for Prometheus or /healthz for kubelet liveness checks.

    • Checks (bool: false) - If enabled, all HTTP and gRPC checks registered with the agent are exposed through Envoy. Envoy will expose listeners for these checks and will only accept connections originating from localhost or Consul’s advertise address. The port for these listeners are dynamically allocated from expose_min_port to expose_max_port. This flag is useful when a Consul client cannot reach registered services over localhost.

    • Paths (array<Path>: []) - A list of paths to expose through Envoy.

      • Path (string: "") - The HTTP path to expose. The path must be prefixed by a slash. ie: /metrics.

      • LocalPathPort (int: 0) - The port where the local service is listening for connections to the path.

      • ListenerPort (int: 0) - The port where the proxy will listen for connections. This port must be available for the listener to be set up. If the port is not free then Envoy will not expose a listener for the path, but the proxy registration will not fail.

      • Protocol (string: "http") - Sets the protocol of the listener. One of http or http2. For gRPC use http2.

ACLs

Configuration entries may be protected by ACLs.

Reading a proxy-defaults config entry requires no specific privileges.

Creating, updating, or deleting a proxy-defaults config entry requires operator:write.