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: Service Defaults'
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: service-defaults
|
2020-04-07 18:55:19 +00:00
|
|
|
description: >-
|
|
|
|
The service-defaults config entry kind controls default global values for a
|
|
|
|
service, such as its protocol.
|
2019-07-09 02:11:19 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Service Defaults
|
|
|
|
|
|
|
|
The `service-defaults` config entry kind controls default global values for a
|
|
|
|
service, such as its protocol.
|
|
|
|
|
|
|
|
## Sample Config Entries
|
|
|
|
|
2020-03-09 20:51:21 +00:00
|
|
|
Set the default protocol for a service in the default namespace to HTTP:
|
2019-07-09 02:11:19 +00:00
|
|
|
|
|
|
|
```hcl
|
2020-06-16 18:28:21 +00:00
|
|
|
Kind = "service-defaults"
|
|
|
|
Name = "web"
|
2020-03-09 20:51:21 +00:00
|
|
|
Namespace = "default"
|
2020-06-16 18:28:21 +00:00
|
|
|
Protocol = "http"
|
2019-07-09 02:11:19 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Available Fields
|
|
|
|
|
|
|
|
- `Kind` - Must be set to `service-defaults`
|
|
|
|
|
|
|
|
- `Name` `(string: <required>)` - Set to the name of the service being configured.
|
|
|
|
|
2020-04-23 22:13:18 +00:00
|
|
|
- `Namespace` `(string: "default")` <EnterpriseAlert inline /> - Specifies the namespace the config entry will apply to.
|
2020-03-09 20:51:21 +00:00
|
|
|
|
2020-09-03 16:08:59 +00:00
|
|
|
- `Meta` `(map<string|string>: nil)` - Specifies arbitrary KV metadata pairs. Added in Consul 1.8.4.
|
2020-09-02 19:10:25 +00:00
|
|
|
|
2019-07-09 02:11:19 +00:00
|
|
|
- `Protocol` `(string: "tcp")` - Sets the protocol of the service. This is used
|
|
|
|
by Connect proxies for things like observability features and to unlock usage
|
2020-04-09 23:46:54 +00:00
|
|
|
of the [`service-splitter`](/docs/agent/config-entries/service-splitter) and
|
2020-10-14 15:23:05 +00:00
|
|
|
[`service-router`](/docs/agent/config-entries/service-router) config entries
|
|
|
|
for a service. It also unlocks the ability to define L7 intentions via
|
|
|
|
[`service-intentions`](/docs/agent/config-entries/service-intentions).
|
|
|
|
Supported values are one of `tcp`, `http`, `http2`, or `grpc`.
|
2019-07-09 02:11:19 +00:00
|
|
|
|
2019-08-21 21:23:08 +00:00
|
|
|
- `MeshGateway` `(MeshGatewayConfig: <optional>)` - Controls the default
|
2020-05-28 19:19:17 +00:00
|
|
|
[mesh gateway configuration](/docs/connect/mesh-gateway#connect-proxy-configuration)
|
2019-08-21 21:23:08 +00:00
|
|
|
for this service. Added in v1.6.0.
|
2019-07-09 02:25:25 +00:00
|
|
|
|
|
|
|
- `Mode` `(string: "")` - One of `none`, `local`, or `remote`.
|
|
|
|
|
2019-08-21 21:23:08 +00:00
|
|
|
- `ExternalSNI` `(string: "")` - This is an optional setting that allows for
|
|
|
|
the TLS [SNI](https://en.wikipedia.org/wiki/Server_Name_Indication) value to
|
|
|
|
be changed to a non-connect value when federating with an external system.
|
|
|
|
Added in v1.6.0.
|
2020-04-06 20:27:35 +00:00
|
|
|
|
2019-09-26 02:55:52 +00:00
|
|
|
- `Expose` `(ExposeConfig: <optional>)` - Controls the default
|
2020-04-09 23:46:54 +00:00
|
|
|
[expose path configuration](/docs/connect/registration/service-registration#expose-paths-configuration-reference)
|
2019-09-26 02:55:52 +00:00
|
|
|
for Envoy. Added in v1.6.2.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
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.
|
2020-03-09 20:51:21 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
- `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
|
2020-04-09 23:46:54 +00:00
|
|
|
[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).
|
2020-04-06 20:27:35 +00:00
|
|
|
This flag is useful when a Consul client cannot reach registered services over localhost. One example is when running
|
2020-03-09 20:51:21 +00:00
|
|
|
Consul on Kubernetes, and Consul agents run in their own pods.
|
2020-04-06 20:27:35 +00:00
|
|
|
- `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`.
|
2019-08-07 19:55:04 +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
|
|
|
|
2020-10-14 15:23:05 +00:00
|
|
|
Reading a `service-defaults` config entry requires `service:read` on the resource.
|
2019-07-09 02:11:19 +00:00
|
|
|
|
|
|
|
Creating, updating, or deleting a `service-defaults` config entry requires
|
2020-10-14 15:23:05 +00:00
|
|
|
`service:write` on the resource.
|