2019-07-09 02:11:19 +00:00
---
2020-04-07 18:55:19 +00:00
layout: docs
2020-04-06 20:27:35 +00:00
page_title: 'Configuration Entry Kind: Proxy Defaults'
2021-01-06 19:01:01 +00:00
sidebar_title: Proxy Defaults
2020-04-07 18:55:19 +00:00
description: >-
The proxy-defaults config entry kind allows for configuring global config
defaults across all services for Connect proxy configuration. Currently, only
one global entry is supported.
2019-07-09 02:11:19 +00:00
---
# Proxy Defaults
2020-12-16 16:57:43 +00:00
-> **v1.8.4+:** On Kubernetes, the `ProxyDefaults` custom resource is supported in Consul versions 1.8.4+.<br />
**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
2019-07-09 02:11:19 +00:00
defaults across all services for Connect proxy configuration. Currently, only
one global entry is supported.
## Sample Config Entries
2020-12-16 16:57:43 +00:00
### Default protocol
<Tabs>
<Tab heading="HCL">
Set the default protocol for all sidecar proxies:
2019-07-09 02:11:19 +00:00
```hcl
2020-06-16 18:28:21 +00:00
Kind = "proxy-defaults"
Name = "global"
Config {
2019-07-09 02:11:19 +00:00
protocol = "http"
}
```
2020-12-16 16:57:43 +00:00
</Tab>
<Tab heading="HCL (Consul Enterprise)">
Set the default protocol for all sidecar proxies.
**NOTE:** The `proxy-defaults` config entry can only be created in the `default`
namespace and it will configure proxies in **all** namespaces.
2019-07-09 02:11:19 +00:00
```hcl
2020-12-16 16:57:43 +00:00
Kind = "proxy-defaults"
Name = "global"
Namespace = "default" # Can only be set to "default".
2020-06-16 18:28:21 +00:00
Config {
2020-12-16 16:57:43 +00:00
protocol = "http"
2019-07-09 02:11:19 +00:00
}
```
2020-12-16 16:57:43 +00:00
</Tab>
<Tab heading="Kubernetes YAML">
Set the default protocol for all sidecar proxies:
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ProxyDefaults
metadata:
name: global
spec:
config:
protocol: http
```
2019-07-09 02:11:19 +00:00
2020-12-16 16:57:43 +00:00
</Tab>
<Tab heading="Kubernetes YAML (Consul Enterprise)">
2019-07-09 02:11:19 +00:00
2020-12-16 16:57:43 +00:00
Set the default protocol for all sidecar proxies:
2019-07-09 02:11:19 +00:00
2020-12-16 16:57:43 +00:00
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ProxyDefaults
metadata:
name: global
spec:
config:
protocol: http
```
</Tab>
</Tabs>
2021-01-26 18:51:31 +00:00
### Prometheus
<Tabs>
<Tab heading="HCL">
Expose prometheus metrics:
```hcl
Kind = "proxy-defaults"
Name = "global"
Config {
envoy_prometheus_bind_addr = "0.0.0.0:9102"
}
```
</Tab>
<Tab heading="Kubernetes YAML">
Expose prometheus metrics:
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ProxyDefaults
metadata:
name: global
spec:
config:
envoy_prometheus_bind_addr: '0.0.0.0:9102'
```
</Tab>
</Tabs>
2020-12-16 16:57:43 +00:00
### Proxy-specific defaults
<Tabs>
<Tab heading="HCL">
2020-03-09 20:51:21 +00:00
2020-12-16 16:57:43 +00:00
Set proxy-specific defaults:
2020-09-02 19:10:25 +00:00
2020-12-16 16:57:43 +00:00
```hcl
Kind = "proxy-defaults"
Name = "global"
Config {
local_connect_timeout_ms = 1000
handshake_timeout_ms = 10000
}
```
2019-07-09 02:11:19 +00:00
2020-12-16 16:57:43 +00:00
</Tab>
<Tab heading="Kubernetes YAML">
2019-07-09 02:11:19 +00:00
2020-12-16 16:57:43 +00:00
Set proxy-specific defaults:
2019-07-09 02:25:25 +00:00
2020-12-16 16:57:43 +00:00
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ProxyDefaults
metadata:
name: global
spec:
config:
local_connect_timeout_ms: 1000
handshake_timeout_ms: 10000
```
2020-04-06 20:27:35 +00:00
2020-12-16 16:57:43 +00:00
</Tab>
</Tabs>
2019-09-26 02:55:52 +00:00
2020-12-16 16:57:43 +00:00
## Available Fields
2020-03-09 20:51:21 +00:00
2020-12-16 16:57:43 +00:00
<ConfigEntryReference
keys={[
{
name: 'apiVersion',
description: 'Must be set to `consul.hashicorp.com/v1alpha1`',
hcl: false,
},
{
name: 'Kind',
description: {
hcl: 'Must be set to `proxy-defaults`',
yaml: 'Must be set to `ProxyDefaults`',
},
},
{
name: 'Name',
description: 'Must be set to `global`',
yaml: false,
},
{
name: 'Namespace',
type: `string: "default"`,
enterprise: true,
description: 'Specifies the namespace the config entry will apply to.',
yaml: false,
},
{
name: 'Meta',
type: 'map<string|string>: nil',
description:
'Specifies arbitrary KV metadata pairs. Added in Consul 1.8.4.',
yaml: false,
},
{
name: 'metadata',
2021-01-27 20:07:40 +00:00
children: [
{
name: 'name',
description: 'Must be set to `global`',
},
{
name: 'namespace',
description:
'If running Consul Open Source, the namespace is ignored (see [Kubernetes Namespaces in Consul OSS](/docs/k8s/crds#consul-oss)). If running Consul Enterprise see [Kubernetes Namespaces in Consul Enterprise](/docs/k8s/crds#consul-enterprise) for more details.',
},
],
2020-12-16 16:57:43 +00:00
hcl: false,
},
{
name: 'Config',
type: 'map[string]arbitrary',
description: `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.
<ul><li>[Envoy](/docs/connect/proxies/envoy#bootstrap-configuration)</li>
<li>[Consul's built-in proxy](/docs/connect/proxies/built-in)</li></ul>`,
},
{
name: 'MeshGateway',
type: 'MeshGatewayConfig: <optional>',
description: `Controls the default
[mesh gateway configuration](/docs/connect/mesh-gateway#connect-proxy-configuration)
for all proxies. Added in v1.6.0.`,
children: [
{
name: 'Mode',
type: 'string: ""',
description: 'One of `none`, `local`, or `remote`.',
},
],
},
{
name: 'Expose',
type: 'ExposeConfig: <optional>',
description: `Controls the default
[expose path configuration](/docs/connect/registration/service-registration#expose-paths-configuration-reference)
for Envoy. Added in v1.6.2.<br><br>
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.`,
children: [
{
name: 'Checks',
type: 'bool: false',
description: `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](/docs/agent/options#advertise). The port for these listeners are dynamically allocated from
[expose_min_port](/docs/agent/options#expose_min_port) to [expose_max_port](/docs/agent/options#expose_max_port).
This flag is useful when a Consul client cannot reach registered services over localhost. One example is when running
Consul on Kubernetes, and Consul agents run in their own pods.`,
},
{
name: 'Paths',
type: 'array<Path>: []',
description: 'A list of paths to expose through Envoy.',
children: [
{
name: 'Path',
type: 'string: ""',
description:
'The HTTP path to expose. The path must be prefixed by a slash. ie: `/metrics`.',
},
{
name: 'LocalPathPort',
type: 'int: 0',
description:
'The port where the local service is listening for connections to the path.',
},
{
name: 'ListenerPort',
type: 'int: 0',
description: `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.`,
},
{
name: 'Protocol',
type: 'string: "http"',
description:
'Sets the protocol of the listener. One of `http` or `http2`. For gRPC use `http2`.',
},
],
},
],
},
]}
/>
2019-07-09 02:25:25 +00:00
2019-07-09 02:11:19 +00:00
## ACLs
2020-10-14 15:23:05 +00:00
Configuration entries may be protected by [ACLs](/docs/security/acl).
2019-07-09 02:11:19 +00:00
Reading a `proxy-defaults` config entry requires no specific privileges.
Creating, updating, or deleting a `proxy-defaults` config entry requires
`operator:write`.