Configuration Entries
Outside of Kubernetes, configuration entries can be specified in HCL or JSON using either or CamelCase
for key names. On Kubernetes, configuration entries can be managed by custom resources in YAML.
Outside of Kubernetes, every configuration entry specified in HCL or JSON has at least two fields: Kind
and Name
. Those two fields are used to uniquely identify a configuration entry. Configuration entries specified as HCL or JSON objects use either snake_case
or CamelCase
for key names.
Example:
On Kubernetes, Kind
is set as the custom resource kind
and Name
is set as metadata.name
:
kind: <supported kind>
metadata:
See Service Mesh - Config Entries for the list of supported config entries.
See .
Configuration entries outside of Kubernetes should be managed with the Consul CLI or . Additionally, as a convenience for initial cluster bootstrapping, configuration entries can be specified in all of the Consul servers’s configuration files
Creating or Updating a Configuration Entry
Example HCL Configuration File:
Kind = "proxy-defaults"
Name = "global"
Config {
local_connect_timeout_ms = 1000
handshake_timeout_ms = 10000
}
proxy-defaults.hcl
Then to apply this configuration, run:
If you need to make changes to a configuration entry, simple edit that file and then rerun the command. This command will not output anything unless there is an error in applying the configuration entry. The write
command also supports a -cas
option to enable performing a compare-and-swap operation to prevent overwriting other unknown modifications.
Reading a Configuration Entry
The command is used to read the current value of a configuration entry. The configuration entry will be displayed in JSON form which is how its transmitted between the CLI client and Consul’s HTTP API.
Example:
$ consul config read -kind service-defaults -name web
"Kind": "service-defaults",
"Name": "web",
}
Listing Configuration Entries
Example:
$ consul config list -kind service-defaults
web
api
db
Deleting Configuration Entries
The consul config delete command is used to delete an entry by specifying both its kind
and name
.
Example:
This command will not output anything when the deletion is successful.
Configuration Entry Management with Namespaces
Enterprise
Configuration entry operations support passing a namespace in order to isolate the entry to affect only operations within that namespace. This was added in Consul 1.7.0.
Example:
$ consul config write service-defaults.hcl -namespace foo
$ consul config list -kind service-defaults -namespace foo
api