mirror of https://github.com/status-im/consul.git
120 lines
3.3 KiB
Plaintext
120 lines
3.3 KiB
Plaintext
---
|
|
layout: commands
|
|
page_title: 'Commands: Config Write'
|
|
---
|
|
|
|
# Consul Config Write
|
|
|
|
Command: `consul config write`
|
|
|
|
Corresponding HTTP API Endpoint: [\[PUT\] /v1/config](/api-docs/config#apply-configuration)
|
|
|
|
The `config write` command creates or updates a centralized config entry.
|
|
See the [configuration entries docs](/docs/agent/config-entries) for more
|
|
details about configuration entries.
|
|
|
|
The table below shows this command's [required ACLs](/api#authentication). Configuration of
|
|
[blocking queries](/api-docs/features/blocking) and [agent caching](/api-docs/features/caching)
|
|
are not supported from commands, but may be from the corresponding HTTP endpoint.
|
|
|
|
| ACL Required<sup>1</sup> |
|
|
| ------------------------------------------------------------- |
|
|
| `service:write`<br />`operator:write`<br />`intentions:write` |
|
|
|
|
<p>
|
|
<sup>1</sup> The actual ACL required depends on the config entry kind being
|
|
updated:
|
|
</p>
|
|
|
|
| Config Entry Kind | Required ACL |
|
|
| ------------------- | ------------------ |
|
|
| ingress-gateway | `operator:write` |
|
|
| proxy-defaults | `operator:write` |
|
|
| service-defaults | `service:write` |
|
|
| service-intentions | `intentions:write` |
|
|
| service-resolver | `service:write` |
|
|
| service-router | `service:write` |
|
|
| service-splitter | `service:write` |
|
|
| terminating-gateway | `operator:write` |
|
|
|
|
## Usage
|
|
|
|
Usage: `consul config write [options] FILE`
|
|
|
|
#### API Options
|
|
|
|
@include 'http_api_options_client.mdx'
|
|
|
|
#### Enterprise Options
|
|
|
|
@include 'http_api_namespace_options.mdx'
|
|
|
|
@include 'http_api_partition_options.mdx'
|
|
|
|
#### Config Write Options
|
|
|
|
- `-cas` - Specifies to use a Check-And-Set operation. If the index is
|
|
0, Consul will only store the entry if it does not already exist. If the index is
|
|
non-zero, the entry is only set if the current index matches the `ModifyIndex`
|
|
of that entry.
|
|
|
|
## Examples
|
|
|
|
From file:
|
|
|
|
$ consul config write web-defaults.json
|
|
|
|
From stdin:
|
|
|
|
$ consul config write -
|
|
|
|
### Config Entry examples
|
|
|
|
All config entries must have a `Kind` when registered. See
|
|
[Service Mesh - Config Entries](/docs/connect/config-entries) for the list of
|
|
supported config entries.
|
|
|
|
#### Service defaults
|
|
|
|
Service defaults control default global values for a service, such as the
|
|
protocol and Connect fields.
|
|
|
|
```json
|
|
{
|
|
"Kind": "service-defaults",
|
|
"Name": "web",
|
|
"Protocol": "http"
|
|
}
|
|
```
|
|
|
|
- `Name` - Sets the name of the config entry. For service defaults, this must be
|
|
the name of the service being configured.
|
|
|
|
- `Protocol` - Sets the protocol of the service. This is used by Connect proxies
|
|
for things like observability features.
|
|
|
|
- `Connect` - This block contains Connect-related fields for the service.
|
|
|
|
- `SidecarProxy` - Sets whether or not instances of this service should get a
|
|
sidecar proxy by default.
|
|
|
|
#### Proxy defaults
|
|
|
|
Proxy defaults allow for configuring global config defaults across all services
|
|
for Connect proxy config. Currently, only one global entry is supported.
|
|
|
|
```json
|
|
{
|
|
"Kind": "proxy-defaults",
|
|
"Name": "global",
|
|
"Config": {
|
|
"foo": 1
|
|
}
|
|
}
|
|
```
|
|
|
|
- `Name` - Sets the name of the config entry. Currently, only a single `proxy-defaults`
|
|
entry with the name `global` is supported.
|
|
|
|
* `Config` - An arbitrary map of configuration values used by Connect proxies.
|