juju deploy vault
a tool for managing secrets Read more
Discuss this charm
Share your thoughts on this charm with the community on discourse.
While many Reactive Framework charms work on machines today, it’s recommended to create new charms with the Operator Framework. Learn more about the history of charms.
The vault charm deploys Vault, a tool for securely managing secrets used in modern computing (e.g. passwords, certificates, API keys). Charmed OpenStack employs Vault to handle TLS certificates, allowing for a centrally managed solution for the encryption of API services across the cloud. Vault is also commonly used to implement Encryption at Rest on Charmed OpenStack.
The charm installs Vault from a snap.
Important: Vault is a requirement for the OVN charms.
This section covers common and/or important configuration options. See file
config.yaml for the full list of options, along with their descriptions and
default values. See the Juju documentation for details
on configuring applications.
channel option sets the snap channel to use for deployment (e.g.
'latest/edge'). The default value is 'latest/stable'.
Important: Some steps must be performed after deployment. Section 'Post-deployment tasks' covers this.
Vault is often containerised. Here a single unit is deployed to a new container on machine '1':
juju deploy --to lxd:1 vault
Note: When Vault is deployed to metal or to a KVM guest the charm will enable mlock (memory locking) to prevent secrets from being saved to disk via page swapping. The mlock feature is not available to containers.
Now connect the vault application to an existing database. This can be the cloud's database or a separate, dedicated database.
juju add-relation vault:shared-db percona-cluster:shared-db
juju deploy mysql-router vault-mysql-router juju add-relation vault-mysql-router:db-router mysql-innodb-cluster:db-router juju add-relation vault-mysql-router:shared-db vault:shared-db
juju add-relation vault:db postgresql:db
Note: For PostgreSQL, its version and the underlying machine series must be compatible (e.g. 9.5/xenial or 10/bionic). The postgresql charm's configuration option
versionis used to select a version at deploy time.
Communication with the Vault REST API can be encrypted with TLS. This is configured with the following charm configuration options:
Note: The process of encrypting the Vault API is separate from that of using Vault to manage the encryption of OpenStack API services. See Managing TLS certificates in the OpenStack Charms Deployment Guide for details.
Once the application is deployed the following tasks must be performed:
- Vault initialisation
- Unsealing of Vault
- Charm authorisation
Vault itself will be needed as a client to perform these tasks.
Vault is needed as a client in order to manage the Vault deployment. Install it on the host where the Juju client resides:
sudo snap install vault
Identify the vault unit by setting the
VAULT_ADDR environment variable
based on the IP address of the unit. This can be discovered from
output (column 'Public address'). Here we'll use '10.0.0.126':
Initialise Vault by specifying the number of unseal keys that should get generated as well as the number of unseal keys that are needed in order to complete the unseal process. Below we will specify five and three, respectively:
vault operator init -key-shares=5 -key-threshold=3
Unseal Key 1: XONSc5Ku8HJu+ix/zbzWhMvDTiPpwWX0W1X/e/J1Xixv Unseal Key 2: J/fQCPvDeMFJT3WprfPy17gwvyPxcvf+GV751fTHUoN/ Unseal Key 3: +bRfX5HMISegsODqNZxvNcupQp/kYQuhsQ2XA+GamjY4 Unseal Key 4: FMRTPJwzykgXFQOl2XTupw2lfgLOXbbIep9wgi9jQ2ls Unseal Key 5: 7rrxiIVQQWbDTJPMsqrZDKftD6JxJi6vFOlyC0KSabDB Initial Root Token: s.ezlJjFw8ZDZO6KbkAkm605Qv Vault initialized with 5 key shares and a key threshold of 3. Please securely distribute the key shares printed above. When the Vault is re-sealed, restarted, or stopped, you must supply at least 3 of these keys to unseal it before it can start servicing requests. Vault does not store the generated master key. Without at least 3 key to reconstruct the master key, Vault will remain permanently sealed! It is possible to generate new unseal keys, provided you have a quorum of existing unseal keys shares. See "vault operator rekey" for more information.
Besides displaying the five unseal keys the output also includes an "initial root token". This token is used to access the Vault API.
Warning: It is not possible to unseal Vault without the unseal keys, nor is it possible to manage Vault without the initial root token. Store this information in a safe place immediately.
Unseal the vault unit using the requisite number of unique keys (three in this example):
vault operator unseal XONSc5Ku8HJu+ix/zbzWhMvDTiPpwWX0W1X/e/J1Xixv vault operator unseal FMRTPJwzykgXFQOl2XTupw2lfgLOXbbIep9wgi9jQ2ls vault operator unseal 7rrxiIVQQWbDTJPMsqrZDKftD6JxJi6vFOlyC0KSabDB
In an HA environment repeat the unseal process for each unit. Prior to
unsealing a unit change the value of the
VAULT_ADDR variable so that it
points to that unit.
Note: Maintenance work on the cloud may require vault units to be paused and later resumed. A resumed vault unit will be sealed and will therefore require unsealing. See Managing power events in the OpenStack Charms Deployment Guide for details.
Proceed to the next step once all units have been unsealed.
Authorise the vault charm
The vault charm must be authorised to access the Vault deployment in order to create storage backends (for secrets) and roles (to allow other applications to access Vault for encryption key storage).
Generate a root token with a limited lifetime (10 minutes here) using the initial root token:
export VAULT_TOKEN=s.ezlJjFw8ZDZO6KbkAkm605Qv vault token create -ttl=10m
Key Value --- ----- token s.QMhaOED3UGQ4MeH3fmGOpNED token_accessor nApB972Dp2lnTTIF5VXQqnnb token_duration 10m token_renewable true token_policies ["root"] identity_policies  policies ["root"]
This temporary token ('token') is then used to authorise the charm:
juju run-action --wait vault/leader authorize-charm token=s.QMhaOED3UGQ4MeH3fmGOpNED
After the action completes execution, the vault unit(s) will become active and any pending requests for secrets storage will be processed for consuming applications.
Here is sample status output for an unsealed three-unit Vault cluster:
vault/0* active idle 0/lxd/1 10.0.0.126 8200/tcp Unit is ready (active: false, mlock: disabled) vault-hacluster/0* active idle 10.0.0.126 Unit is ready and clustered vault-mysql-router/0* active idle 10.0.0.126 Unit is ready vault/1 active idle 1/lxd/1 10.0.0.130 8200/tcp Unit is ready (active: true, mlock: disabled) vault-hacluster/2 active idle 10.0.0.130 Unit is ready and clustered vault-mysql-router/2 active idle 10.0.0.130 Unit is ready vault/2 active idle 2/lxd/1 10.0.0.132 8200/tcp Unit is ready (active: false, mlock: disabled) vault-hacluster/1 active idle 10.0.0.132 Unit is ready and clustered vault-mysql-router/1 active idle 10.0.0.132 Unit is ready
This section lists Juju actions supported by the charm. Actions allow specific operations to be performed on a per-unit basis.
To display action descriptions run
juju actions --schema vault. If the charm
is not deployed then see file
When more than one unit is deployed with the hacluster application the charm will bring up an HA active/active cluster.
There are two mutually exclusive high availability options: using virtual IP(s) or DNS. In both cases the hacluster subordinate charm is used to provide the Corosync and Pacemaker backend HA functionality.
In addition, HA Vault will require the etcd and easyrsa applications.
The OpenStack Charms project maintains two documentation guides:
- OpenStack Charm Guide: for project information, including development and support notes
- OpenStack Charms Deployment Guide: for charm usage information
Please report bugs on Launchpad.