Proxy Defaults Configuration Entry

The proxy-defaults configuration entry (ProxyDefaults on Kubernetes) allows you to globally configure passthrough Envoy settings for proxies in the service mesh, including both sidecars and gateways. It is different from the mesh configuration entry, which sets Consul features for cluster peering, transparent proxy, and TLS behavior that also affect Consul servers.

Only one global entry is supported. For Consul Enterprise, only the global entry in the default partition is recognized.

Introduction

You can customize some service registration settings for service mesh proxies centrally using the proxy-defaults configuration entry in the kind field.

You can still override this centralized configuration for specific services with the service-defaults configuration entry kind or for individual proxy instances in their sidecar service definitions.

Usage

  1. Verify that your datacenter meets the conditions specified in the Requirements.
  2. Determine the settings you want to implement (see Configuration). You can create a file containing the configuration or pass them to the state store directly to apply the configuration.
  3. Apply the configuration using one of the following methods:

Configuration

Configure the following parameters to define a proxy-defaults configuration entry:

Proxy defaults configuration syntax

Proxy defaults configuration syntax

  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. Meta {
  4. <arbitrary string key> = "<arbitrary string value>"
  5. }
  6. Config {
  7. <arbitrary string key> = <arbitrary value>
  8. }
  9. Mode = "<name of proxy mode>"
  10. TransparentProxy {
  11. OutboundListenerPort = <port the proxy should listen on for outbound traffic>
  12. DialedDirectly = <true if proxy instances should be dialed directly>
  13. }
  14. MutualTLSMode = "<mutual TLS mode for all proxies>"
  15. MeshGateway {
  16. Mode = "<name of mesh gateway configuration for all proxies>"
  17. }
  18. Expose {
  19. Checks = <true to expose all HTTP and gRPC checks through Envoy>
  20. Paths = [
  21. {
  22. Path = "<the HTTP path to expose>"
  23. LocalPathPort = <port where the local service is listening for connections to the path>
  24. ListenerPort = <port where the proxy will listen for connections>
  25. Protocol = "<protocol of the listener>"
  26. }
  27. ]
  28. }
  29. AccessLogs {
  30. Enabled = < true | false >
  31. DisableListenerLogs = < true | false , disables listener access logs for unrecognized traffic>
  32. Type = "< file | stdout | stdout, the destination for access logs >"
  33. Path = "< set the output path for 'file' based access logs >"
  34. JSONFormat = "< json representation of access log format >"
  35. TextFormat = "< text representation of access log format >"
  36. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. spec:
  6. meta:
  7. <arbitrary string key>: <arbitrary string value>
  8. config:
  9. <arbitrary string key>: <arbitrary value>
  10. mode: <name of proxy mode>
  11. transparentProxy:
  12. outboundListenerPort: <port the proxy should listen on for outbound traffic>
  13. dialedDirectly: <true if proxy instances should be dialed directly>
  14. mutualTLSMode: <mutual TLS mode for all proxies>
  15. meshGateway:
  16. mode: <name of mesh gateway configuration for all proxies>
  17. expose:
  18. checks: <true to expose all HTTP and gRPC checks through Envoy>
  19. paths:
  20. - path: <the HTTP path to expose>
  21. localPathPort: <port where the local service is listening for connections to the path>
  22. listenerPort: <port where the proxy will listen for connections>
  23. protocol:= <protocol of the listener>
  24. accessLogs:
  25. enabled: < true | false >
  26. disableListenerLogs: < true | false , disables listener access logs for unrecognized traffic>
  27. type: < file | stdout | stdout, the destination for access logs >
  28. path: < set the output path for 'file' based access logs >
  29. jsonFormat: < json representation of access log format >
  30. textFormat: < text representation of access log format >
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "Meta": {
  5. "<arbitrary string key>": "<arbitrary string value>"
  6. },
  7. "Config": {
  8. "<arbitrary string key>": <arbitrary value>
  9. },
  10. "MutualTLSMode": "<mutual TLS mode for all proxies>",
  11. "Mode": "<name of proxy mode>",
  12. "TransparentProxy": {
  13. "OutboundListenerPort": <port the proxy should listen on for outbound traffic>,
  14. "DialedDirectly": <true if proxy instances should be dialed directly>
  15. },
  16. "MeshGateway": {
  17. "Mode": = "<name of mesh gateway configuration for all proxies>"
  18. },
  19. "Expose": {
  20. "Checks": <true to expose all HTTP and gRPC checks through Envoy>,
  21. "Paths": [
  22. {
  23. "Path": "<the HTTP path to expose>",
  24. "LocalPathPort": <port where the local service is listening for connections to the path>,
  25. "ListenerPort": <port where the proxy will listen for connections>,
  26. "Protocol": "<protocol of the listener>"
  27. }
  28. ]
  29. },
  30. "AccessLogs": {
  31. "Enabled": < true | false >,
  32. "DisableListenerLogs": < true | false , disables listener access logs for unrecognized traffic>,
  33. "Type": "< file | stdout | stdout, the destination for access logs >",
  34. "Path": "< set the output path for 'file' based access logs >",
  35. "JSONFormat": "< json representation of access log format >",
  36. "TextFormat": "< text representation of access log format >"
  37. }
  38. }

NOTE: The proxy-defaults config entry can only be created in the default namespace and it will configure proxies in all namespaces.

Proxy defaults configuration syntax

Proxy defaults configuration syntax

  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. Namespace = "default" # Can only be set to "default".
  4. Meta {
  5. <arbitrary string key> = "<arbitrary string value>"
  6. }
  7. Config {
  8. <arbitrary string key> = <arbitrary value>
  9. }
  10. Mode = "<name of proxy mode>"
  11. TransparentProxy {
  12. OutboundListenerPort = <port the proxy should listen on for outbound traffic>
  13. DialedDirectly = <true if proxy instances should be dialed directly>
  14. }
  15. MutualTLSMode = "<mutual TLS mode for all proxies>"
  16. MeshGateway {
  17. Mode = "<name of mesh gateway configuration for all proxies>"
  18. }
  19. Expose {
  20. Checks = <true to expose all HTTP and gRPC checks through Envoy>
  21. Paths = [
  22. {
  23. Path = "<the HTTP path to expose>"
  24. LocalPathPort = <port where the local service is listening for connections to the path>
  25. ListenerPort = <port where the proxy will listen for connections>
  26. Protocol = "<protocol of the listener>"
  27. }
  28. ]
  29. }
  30. AccessLogs {
  31. Enabled = < true | false >
  32. DisableListenerLogs = < true | false , disables listener access logs for unrecognized traffic>
  33. Type = "< file | stdout | stdout, the destination for access logs >"
  34. Path = "< set the output path for 'file' based access logs >"
  35. JSONFormat = "< json representation of access log format >"
  36. TextFormat = "< text representation of access log format >"
  37. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. namespace: default
  6. spec:
  7. meta:
  8. <arbitrary string key>: <arbitrary string value>
  9. config:
  10. <arbitrary string key>: <arbitrary value>
  11. mode: <name of proxy mode>
  12. transparentProxy:
  13. outboundListenerPort: <port the proxy should listen on for outbound traffic>
  14. dialedDirectly: <true if proxy instances should be dialed directly>
  15. mutualTLSMode: <mutual TLS mode for all proxies>
  16. meshGateway:
  17. mode: <name of mesh gateway configuration for all proxies>
  18. expose:
  19. checks: <true to expose all HTTP and gRPC checks through Envoy>
  20. paths:
  21. - path: <the HTTP path to expose>
  22. localPathPort: <port where the local service is listening for connections to the path>
  23. listenerPort: <port where the proxy will listen for connections>
  24. protocol:= <protocol of the listener>
  25. accessLogs:
  26. enabled: < true | false >
  27. disableListenerLogs: < true | false , disables listener access logs for unrecognized traffic>
  28. type: < file | stdout | stdout, the destination for access logs >
  29. path: < set the output path for 'file' based access logs >
  30. jsonFormat: < json representation of access log format >
  31. textFormat: < text representation of access log format >
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "Namespace": "default",
  5. "Meta": {
  6. "<arbitrary string key>": "<arbitrary string value>"
  7. },
  8. "Config": {
  9. "<arbitrary string key>": <arbitrary value>
  10. },
  11. "Mode": "<name of proxy mode>",
  12. "TransparentProxy": {
  13. "OutboundListenerPort": <port the proxy should listen on for outbound traffic>,
  14. "DialedDirectly": <true if proxy instances should be dialed directly>
  15. },
  16. "MutualTLSMode": "<mutual TLS mode for all proxies>",
  17. "MeshGateway": {
  18. "Mode": = "<name of mesh gateway configuration for all proxies>"
  19. },
  20. "Expose": {
  21. "Checks": <true to expose all HTTP and gRPC checks through Envoy>,
  22. "Paths": [
  23. {
  24. "Path": "<the HTTP path to expose>",
  25. "LocalPathPort": <port where the local service is listening for connections to the path>,
  26. "ListenerPort": <port where the proxy will listen for connections>,
  27. "Protocol": "<protocol of the listener>"
  28. }
  29. ]
  30. },
  31. "AccessLogs": {
  32. "Enabled": < true | false >,
  33. "DisableListenerLogs": < true | false , disables listener access logs for unrecognized traffic>,
  34. "Type": "< file | stdout | stdout, the destination for access logs >",
  35. "Path": "< set the output path for 'file' based access logs >",
  36. "JSONFormat": "< json representation of access log format >",
  37. "TextFormat": "< text representation of access log format >"
  38. }
  39. }

Configuration Parameters

  • Kind - Must be set to proxy-defaults

  • Name - Must be set to global

  • Namespace (string: "default")Enterprise - Must be set to default. The configuration will apply to all namespaces.

  • Partition (string: "default")Enterprise - Specifies the name of the admin partition in which the configuration entry applies. Refer to the Admin Partitions documentation for additional information.

  • 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 service mesh proxies. The available configurations depend on the mesh 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.

  • EnvoyExtensions (array<EnvoyExtension>: []) - A list of extensions to modify Envoy proxy configuration.

    Applying EnvoyExtensions to ProxyDefaults may produce unintended consequences. We recommend enabling EnvoyExtensions with ServiceDefaults in most cases.

    • Name (string: "") - Name of the extension.

    • Required (string: "") - When Required is true and the extension does not update any Envoy resources, an error is returned. Use this parameter to ensure that extensions required for secure communication are not unintentionally bypassed.

    • Arguments (map<string|Any>: nil) - Arguments to pass to the extension executable.

  • 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.

  • MutualTLSMode (string: "") - Controls the default mutual TLS mode for all proxies. This setting is only supported for services with transparent proxy enabled. One of "", strict, or permissive. When unset or "", the mode defaults to strict. When set to strict, the sidecar proxy requires mutual TLS for incoming traffic. When set to permissive, the sidecar proxy accepts mutual TLS traffic on the sidecar proxy service port and accepts any traffic on the destination service port. We recommend only using permissive mode if necessary while onboarding services to the service mesh.

  • 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-mesh-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.

  • FailoverPolicy (ServiceResolverFailoverPolicy: <optional>) - Policy specifies the exact mechanism used for failover. Added in v1.16.0.

    • Mode (string: "") - One of "", default, or order-by-locality.
  • AccessLogs (AccessLogsConfig: <optional>) - Controls the configuration of Envoy’s access logging for all proxies in the mesh, including gateways. It also configures access logs on Envoy’s administration interface.

    • Enabled (bool: false) - When enabled, access logs are emitted for all proxies in the mesh, including gateways.

    • DisableListenerLogs (bool: false) - When enabled, access logs for traffic rejected at the listener-level are not emitted. This traffic includes connections that do not match any of Envoy’s configured filters, such as Consul upstream services. Set this option to true if you do not want to log unknown requests that Envoy is not forwarding

    • Type (string: "stdout") - The destination for access logs. One of stdout, stderr, or file.

    • Path (string: "") - The destination file for access logs. Only valid with Type set to file.

    • JSONFormat (string: (default as follows)) - A JSON-formatted string that represents the format of each emitted access log. By default, it is set to the default access log format. You can use Envoy command operators to customize the emitted data. Nesting is supported. Invalid if a custom format is specified with TextFormat.

    • TextFormat (string: "") - A formatted string that represents the format of each emitted access log. Envoy command operators can be used to customize the data emitted. A new line is added to the string automatically. Invalid when a custom JSONFormat is already specified.

  • apiVersion - Must be set to consul.hashicorp.com/v1alpha1

  • kind - Must be set to ProxyDefaults

  • metadata

  • spec

    • config (map[string]arbitrary) - An arbitrary map of configuration values used by service mesh proxies. The available configurations depend on the mesh 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.

    • envoyExtensions (array<EnvoyExtension>: []) - A list of extensions to modify Envoy proxy configuration.

      Applying EnvoyExtensions to ProxyDefaults may produce unintended consequences. We recommend enabling EnvoyExtensions with ServiceDefaults in most cases.

      • name (string: "") - Name of the extension.

      • required (string: "") - When Required is true and the extension does not update any Envoy resources, an error is returned. Use this parameter to ensure that extensions required for secure communication are not unintentionally bypassed.

      • arguments (map<string|Any>: nil) - Arguments to pass to the extension executable.

    • 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.

    • mutualTLSMode (string: "") - Controls the default mutual TLS mode for all proxies. This setting is only supported for services with transparent proxy enabled. One of "", strict, or permissive. When unset or "", the mode defaults to strict. When set to strict, the sidecar proxy requires mutual TLS for incoming traffic. When set to permissive, the sidecar proxy accepts mutual TLS traffic on the sidecar proxy service port and accepts any traffic on the destination service port. We recommend only using permissive mode if necessary while onboarding services to the service mesh.

    • 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-mesh-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.

    • failoverPolicy (ServiceResolverFailoverPolicy: <optional>) - Policy specifies the exact mechanism used for failover. Added in v1.16.0.

      • mode (string: "") - One of "", default, or order-by-locality.
    • accessLogs (AccessLogsConfig: <optional>) - Controls the configuration of Envoy’s access logging for all proxies in the mesh, including gateways. It also configures access logs on Envoy’s administration interface.

      • enabled (bool: false) - When enabled, access logs are emitted for all proxies in the mesh, including gateways.

      • disableListenerLogs (bool: false) - When enabled, access logs for traffic rejected at the listener-level are not emitted. This traffic includes connections that do not match any of Envoy’s configured filters, such as Consul upstream services. Set this option to true if you do not want to log unknown requests that Envoy is not forwarding

      • type (string: "stdout") - The destination for access logs. One of stdout, stderr, or file.

      • path (string: "") - The destination file for access logs. Only valid with Type set to file.

      • jsonFormat (string: (default as follows)) - A JSON-formatted string that represents the format of each emitted access log. By default, it is set to the default access log format. You can use Envoy command operators to customize the emitted data. Nesting is supported. Invalid if a custom format is specified with TextFormat.

      • textFormat (string: "") - A formatted string that represents the format of each emitted access log. Envoy command operators can be used to customize the data emitted. A new line is added to the string automatically. Invalid when a custom JSONFormat is already specified.

Examples

Default protocol

The following example configures the default protocol for all proxies.

  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. }

NOTE: The proxy-defaults config entry can only be created in the default namespace and it will configure proxies in all namespaces.

  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. Namespace = "default" # Can only be set to "default".
  4. Config {
  5. protocol = "http"
  6. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. namespace: default
  6. spec:
  7. config:
  8. protocol: http
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "Namespace": "default",
  5. "Config": {
  6. "protocol": "http"
  7. }
  8. }

Prometheus

The following example configures all proxies to expose Prometheus metrics.

  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. }

Access Logs

The following example is a minimal configuration for enabling access logs for all proxies. Refer to access logs for advanced configurations.

  1. Kind = "proxy-defaults"
  2. Name = "global"
  3. AccessLogs {
  4. Enabled = true
  5. }
  1. apiVersion: consul.hashicorp.com/v1alpha1
  2. kind: ProxyDefaults
  3. metadata:
  4. name: global
  5. spec:
  6. accessLogs:
  7. enabled: true
  1. {
  2. "Kind": "proxy-defaults",
  3. "Name": "global",
  4. "AccessLogs": {
  5. "Enabled": true
  6. }
  7. }

Proxy-specific defaults

The following example configures some custom default values for all proxies.

  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. }

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.