Overview
In configuring Consul, there are multiple methods to manage config entries
- Create a config entry file and use the command
consul config write
to apply it.- This method is straightforward and suitable for individual configurations.
- Another approach involves incorporating
config_entries.bootstrap
directly within the Consul agent configuration file.- This method allows you to preload config entries when the Consul server agent starts and it ensures all configuration entries are loaded upfront.
This article focuses on using the config_entries.bootstrap
option.
Config Entries: Bootstrap
- To create a config entry from the Consul agent configuration file, the following is an example of agent configuration in HCL format:
datacenter = "dc1"
data_dir = "/opt/consul"
server = true
config_entries {
bootstrap = [
{
Kind = "mesh"
}
]
}
-
- It's important to enclose the
bootstrap
entries within square brackets[ ]
to define them as a list. Each config entry should be enclosed in curly braces{ }
, separated by commas,
if multiple entries exist.
- It's important to enclose the
- Below is a detailed example:
datacenter = "dc1"
data_dir = "/opt/consul"
node_name = "server1"
server = true
bootstrap_expect = 1
log_level = "DEBUG"
config_entries {
bootstrap = [
{
Kind = "mesh"
TLS {
Incoming {
TLSMinVersion = "TLSv1_2"
}
}
HTTP {
SanitizeXForwardedClientCert = true
}
},
{
Kind = "ingress-gateway"
Name = "ingress-gateway"
}
]
}
- When Consul agent starts up, it will load all config entries from the agent configuration file (e.g. consul.hcl)
$ consul agent -config-file="/etc/consul.d/consul.hcl"
- Once the agent is up and running, verify the config entries using commands like:
$ consul config list -kind=mesh
$ consul config list -kind=ingress-gateway
- To inspect the details of a specific config entry, such as a mesh:
$ consul config read -kind=mesh -name=mesh
- Moreover, you can also hit the config entries endpoint to verify detailed configuration:
$ curl 0:8500/v1/config/mesh?pretty
Conclusion
This method ensures all necessary config entries are in place when Consul agent starts up.
In Consul Enterprise, it is important to ensure that config entries are applied only to namespaces and partitions that already exist. Please refer to our documentation linked below: