Consul
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
- Verify that your datacenter meets the conditions specified in the Requirements.
- 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.
- Apply the configuration using one of the following methods:
- Kubernetes CRD: Refer to the Custom Resource Definitions documentation for details.
- Issue the
consul config write
command: Refer to the Consul Config Write documentation for details.
Configuration
Configure the following parameters to define a proxy-defaults
configuration entry:
Proxy defaults configuration syntax
Kind = "proxy-defaults"
Name = "global"
Meta {
<arbitrary string key> = "<arbitrary string value>"
}
Config {
<arbitrary string key> = <arbitrary value>
}
Mode = "<name of proxy mode>"
TransparentProxy {
OutboundListenerPort = <port the proxy should listen on for outbound traffic>
DialedDirectly = <true if proxy instances should be dialed directly>
}
MeshGateway {
Mode = "<name of mesh gateway configuration for all proxies>"
}
Expose {
Checks = <true to expose all HTTP and gRPC checks through Envoy>
Paths = [
{
Path = "<the HTTP path to expose>"
LocalPathPort = <port where the local service is listening for connections to the path>
ListenerPort = <port where the proxy will listen for connections>
Protocol = "<protocol of the listener>"
}
]
}
AccessLogs {
Enabled = < true | false >
DisableListenerLogs = < true | false , disables listener access logs for unrecognized traffic>
Type = "< file | stdout | stdout, the destination for access logs >"
Path = "< set the output path for 'file' based access logs >"
JSONFormat = "< json representation of access log format >"
TextFormat = "< text representation of access log format >"
}
Configuration Parameters
Kind
- Must be set toproxy-defaults
Name
- Must be set toglobal
Namespace
(string: "default")
Enterprise - Must be set todefault
. 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.
ApplyingEnvoyExtensions
toProxyDefaults
may produce unintended consequences. We recommend enablingEnvoyExtensions
withServiceDefaults
in most cases.Name
(string: "")
- Name of the extension.Required
(string: "")
- WhenRequired
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 ofdirect
ortransparent
.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 ofnone
,local
, orremote
.
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 ofhttp
orhttp2
. For gRPC usehttp2
.
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 totrue
if you do not want to log unknown requests that Envoy is not forwardingType
(string: "stdout")
- The destination for access logs. One ofstdout
,stderr
, orfile
.Path
(string: "")
- The destination file for access logs. Only valid withType
set tofile
.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.
Kind = "proxy-defaults"
Name = "global"
Config {
protocol = "http"
}
Prometheus
The following example configures all proxies to expose Prometheus metrics.
Kind = "proxy-defaults"
Name = "global"
Config {
envoy_prometheus_bind_addr = "0.0.0.0:9102"
}
Access Logs
The following example is a minimal configuration for enabling access logs for all proxies. Refer to access logs for advanced configurations.
Kind = "proxy-defaults"
Name = "global"
AccessLogs {
Enabled = true
}
Proxy-specific defaults
The following example configures some custom default values for all proxies.
Kind = "proxy-defaults"
Name = "global"
Config {
local_connect_timeout_ms = 1000
handshake_timeout_ms = 10000
}
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
.