Consul
Service mesh parameters for Consul agent configuration files
The page provides reference information for service mesh parameters in a Consul agent configuration file.
Service Mesh Parameters
The noun connect is used throughout this documentation to refer to the connect subsystem that provides Consul's service mesh capabilities.
connectThis object allows setting options for the Connect feature.The following sub-keys are available:
enabled(Defaults totrue) Controls whether Connect features are enabled on this agent. Should be enabled on all servers in the cluster in order for service mesh to function properly. Will be set totrueautomatically ifauto_config.enabledorauto_encrypt.allow_tlsistrue.enable_mesh_gateway_wan_federation(Defaults tofalse) Controls whether cross-datacenter federation traffic between servers is funneled through mesh gateways. This was added in Consul 1.8.0.ca_providerControls which CA provider to use for the service mesh's CA. Currently only theaws-pca,consul, andvaultproviders are supported. This is only used when initially bootstrapping the cluster. For an existing cluster, use the Update CA Configuration Endpoint.ca_configAn object which allows setting different config options based on the CA provider chosen. This is only used when initially bootstrapping the cluster. For an existing cluster, use the Update CA Configuration Endpoint.The following providers are supported:
AWS ACM Private CA Provider (
ca_provider = "aws-pca")existing_arnThe Amazon Resource Name (ARN) of an existing private CA in your ACM account. If specified, Consul will attempt to use the existing CA to issue certificates.
Consul CA Provider (
ca_provider = "consul")private_keyThe PEM contents of the private key to use for the CA.root_certThe PEM contents of the root certificate to use for the CA.
Vault CA Provider (
ca_provider = "vault")addressThe address of the Vault server to connect to.tokenThe Vault token to use. In Consul 1.8.5 and later, if the token has the renewable flag set, Consul will attempt to renew its lease periodically after half the duration has expired.root_pki_pathThe path to use for the root CA pki backend in Vault. This can be an existing backend with a CA already configured, or a blank/unmounted backend in which case Consul will automatically mount/generate the CA. The Vault token given above must havesudoaccess to this backend, as well as permission to mount the backend at this path if it is not already mounted.intermediate_pki_pathThe path to use for the temporary intermediate CA pki backend in Vault. Consul will overwrite any data at this path in order to generate a temporary intermediate CA. The Vault token given above must havewriteaccess to this backend, as well as permission to mount the backend at this path if it is not already mounted.auth_methodVault auth method to use for logging in to Vault. Please see Vault Auth Methods for more information on how to configure individual auth methods. If auth method is provided, Consul will obtain a new token from Vault when the token can no longer be renewed.typeThe type of Vault auth method.mount_pathThe mount path of the auth method. If not provided the auth method type will be used as the mount path.paramsThe parameters to configure the auth method. Please see Vault Auth Methods for information on how to configure the auth method you wish to use. If using the Kubernetes auth method, Consul will read the service account token from the default mount path/var/run/secrets/kubernetes.io/serviceaccount/tokenif thejwtparameter is not provided.
Common CA Config Options
There are also a number of common configuration options supported by all providers:
csr_max_concurrentSets a limit on the number of Certificate Signing Requests that can be processed concurrently. Defaults to 0 (disabled). This is useful when you want to limit the number of CPU cores available to the server for certificate signing operations. For example, on an 8 core server, setting this to 1 will ensure that no more than one CPU core will be consumed when generating or rotating certificates. Setting this is recommended instead ofcsr_max_per_secondwhen you want to limit the number of cores consumed since it is simpler to reason about limiting CSR resources this way without artificially slowing down rotations. Added in 1.4.1.csr_max_per_secondSets a rate limit on the maximum number of Certificate Signing Requests (CSRs) the servers will accept. This is used to prevent CA rotation from causing unbounded CPU usage on servers. It defaults to 50 which is conservative – a 2017 Macbook can process about 100 per second using only ~40% of one CPU core – but sufficient for deployments up to ~1500 service instances before the time it takes to rotate is impacted. For larger deployments we recommend increasing this based on the expected number of server instances and server resources, or usecsr_max_concurrentinstead if servers have more than one CPU core. Setting this to zero disables rate limiting. Added in 1.4.1.leaf_cert_ttlSpecifies the upper bound on the expiry of a leaf certificate issued for a service. In most cases a new leaf certificate will be requested by a proxy before this limit is reached. This is also the effective limit on how long a server outage can last (with no leader) before network connections will start being rejected. Defaults to72h.You can specify a range from one hour (minimum) up to one year (maximum) using the following units:
h,m,s,ms,us(orµs),ns, or a combination of those units, e.g.1h5m.This value is also used when rotating out old root certificates from the cluster. When a root certificate has been inactive (rotated out) for more than twice the current
leaf_cert_ttl, it will be removed from the trusted list.intermediate_cert_ttlSpecifies the expiry for the intermediate certificates. Defaults to8760h(1 year). Must be at least 3 timesleaf_cert_ttl.root_cert_ttlSpecifies the expiry for a root certificate. Defaults to 10 years as87600h. This value, if provided, needs to be higher than the intermediate certificate TTL.This setting applies to all Consul CA providers.
For the Vault provider, this value is only used if the backend is not initialized at first.
This value is also applied on the
ca set-configcommand.private_key_typeThe type of key to generate for this CA. This is only used when the provider is generating a new key. Ifprivate_keyis set for the Consul provider, or existing root or intermediate PKI paths given for Vault then this will be ignored. Currently supported options areecorrsa. Default isec.It is required that all servers in a datacenter have the same config for the CA. It is recommended that servers in different datacenters use the same key type and size, although the built-in CA and Vault provider will both allow mixed CA key types.
Some CA providers (currently Vault) will not allow cross-signing a new CA certificate with a different key type. This means that if you migrate from an RSA-keyed Vault CA to an EC-keyed CA from any provider, you may have to proceed without cross-signing which risks temporary connection issues for workloads during the new certificate rollout. We highly recommend testing this outside of production to understand the impact and suggest sticking to same key type where possible.
Note that this only affects CA keys generated by the provider. Leaf certificate keys are always EC 256 regardless of the CA configuration.
private_key_bitsThe length of key to generate for this CA. This is only used when the provider is generating a new key. Ifprivate_keyis set for the Consul provider, or existing root or intermediate PKI paths given for Vault then this will be ignored.Currently supported values are:
private_key_type = ec(default):224, 256, 384, 521corresponding to the NIST P-* curves of the same name.private_key_type = rsa:2048, 4096
localityEnterprise: Specifies a map of configurations that set the region and zone of the Consul agent. When specified on server agents,localityapplies to all partitions on the server. When specified on clients,localityapplies to all services registered to the client. Configure this field to enable Consul to route traffic to the nearest physical service instance. This field is intended for use primarily with VM and Nomad workloads. Refer to Route traffic to local upstreams for additional information.region: String value that specifies the region where the Consul agent is running. Consul assigns this value to services registered to that agent. When service proxy regions match, Consul is able to prioritize routes between service instances in the same region over instances in other regions. You must specify values that are consistent with how regions are defined in your network, for exampleus-west-1for networks in AWS.zone: String value that specifies the availability zone where the Consul agent is running. Consul assigns this value to services registered to that agent. When service proxy regions match, Consul is able to prioritize routes between service instances in the same region and zone over instances in other regions and zones. When healthy service instances are available in multiple zones within the most-local region, Consul prioritizes instances that also match the downstream proxy'szone. You must specify values that are consistent with how zones are defined in your network, for exampleus-west-1afor networks in AWS.