Consul
Vault as the Secrets Backend - Data Integration
Overview
This topic describes an overview of how to configure Vault and Consul in order to share secrets for use within Consul.
General Integration Steps
You must complete two general procedures for each secret you wish to store in Vault.
Complete the following steps once:
- Store the secret in Vault.
- Create a Vault policy that authorizes the desired level of access to the secret.
Repeat the following steps for each datacenter in the cluster:
- Create Vault Kubernetes auth roles that link the policy to each Consul on Kubernetes service account that requires access.
- Update the Consul on Kubernetes helm chart.
Prerequisites
Prior to setting up the data integration between Vault and Consul on Kubernetes, you will need to have read and completed the steps in the Systems Integration section of Vault as a Secrets Backend.
Example - Gossip Encryption Key Integration
Following the general integration steps, a more detailed workflow for integration of the Gossip encryption key with the Vault Secrets backend would like the following:
Complete the following steps once:
- Store the secret in Vault.
- Save the gossip encryption key in Vault at the path
secret/consul/gossip
.
- Save the gossip encryption key in Vault at the path
- Create a Vault policy that authorizes the desired level of access to the secret.
- Create a Vault policy that you name
gossip-policy
which allowsread
access to the pathsecret/consul/gossip
.
- Create a Vault policy that you name
Repeat the following steps for each datacenter in the cluster:
- Create Vault Kubernetes auth roles that link the policy to each Consul on Kubernetes service account that requires access.
- Both Consul servers and Consul clients need access to the gossip encryption key, so you create two Vault Kubernetes:
- A role called
consul-server
that maps the Kubernetes namespace and service account name for your consul servers to thegossip-policy
created in step 2 of One time setup in Vault. - A role called
consul-client
that maps the Kubernetes namespace and service account name for your consul clients to thegossip-policy
created in step 2 of One time setup in Vault..
- A role called
- Both Consul servers and Consul clients need access to the gossip encryption key, so you create two Vault Kubernetes:
- Update the Consul on Kubernetes helm chart.
- Configure the Vault Kubernetes auth roles created for the gossip encryption key:
global.secretsBackend.vault.consulServerRole
is set to theconsul-server
Vault Kubernetes auth role created previously.global.secretsBackend.vault.consulClientRole
is set to theconsul-client
Vault Kubernetes auth role created previously.
- Configure the Vault Kubernetes auth roles created for the gossip encryption key:
Secrets to Service Account Mapping
At the most basic level, the goal of this configuration is to authorize a Consul on Kubernetes service account to access a secret in Vault.
Below is a mapping of Vault secrets and the Consul on Kubernetes service accounts that need to access them.
(NOTE: Consul components
refers to all other services and jobs that are not Consul servers or clients.
It includes things like terminating gateways, ingress gateways, etc.)
Primary Datacenter
Secondary Datacenters
The mapping for secondary data centers is similar with the following differences:
- There is no use of bootstrap token because ACLs would have been bootstrapped in the primary datacenter.
- ACL Partition token is mapped to both the
server-acl-init
job and thepartition-init
job service accounts. - ACL Replication token is mapped to both the
server-acl-init
job and Consul service accounts.
Combining policies within roles
As you can see in the table above, depending upon your needs, a Consul on Kubernetes service account could have the need to request more than one secret. In these cases, you will want to create one role for the Consul on Kubernetes service account that is mapped to multiple policies, each of which allows it access to a given secret.
For example, if your Consul on Kubernetes servers need access to Gossip encryption key, Consul Server TLS credentials, and Enterprise license, assuming you have already saved the secrets in vault, you would:
Create a policy for each secret.
Gossip encryption key
gossip-policy.hcl
path "secret/data/consul/gossip" { capabilities = ["read"] }
$ vault policy write gossip-policy gossip-policy.hcl
Consul Server TLS credentials
ca-policy.hcl
path "pki/cert/ca" { capabilities = ["read"] }
$ vault policy write ca-policy ca-policy.hcl
Enterprise License
license-policy.hcl
path "secret/data/consul/license" { capabilities = ["read"] }
$ vault policy write license-policy license-policy.hcl
Create one role that maps the Consul on Kubernetes service account to the 3 policies.
$ vault write auth/kubernetes/role/consul-server \ bound_service_account_names=<Consul server service account> \ bound_service_account_namespaces=<Consul installation namespace> \ policies=gossip-policy,ca-policy,license-policy \ ttl=1h
Detailed data integration guides
The following secrets can be stored in Vault KV secrets engine, which is meant to handle arbitrary secrets:
- ACL Bootstrap token
- ACL Partition token
- ACL Replication token
- Enterprise license
- Gossip encryption key
- Snapshot Agent config
The following TLS certificates and keys can generated and managed by Vault the Vault PKI Engine, which is meant to handle things like certificate expiration and rotation:
- Server TLS credentials
- Service Mesh and Consul client TLS credentials
- Vault as the Webhook Certificate Provider for Consul Controller and Connect Inject on Kubernetes
Secrets to Service Account Mapping
Read through the detailed data integration guides that are pertinent to your environment.