Integrated storage autopilot
Vault 1.2 first introduced an internal storage backend, Integrated Storage as a technical preview, and the feature became generally available in Vault 1.4. Using the Integrated Storage, data gets replicated to all the nodes in the cluster using the raft consensus protocol. The management of the nodes in the cluster was a manual process.
Vault 1.7 introduced autopilot to simplify and automate the cluster management for Integrated Storage. The autopilot includes:
- Cluster node health check
- Server stabilization: prevent disruption to raft quorum due to an unstable new node
- Monitor newly added node health for a period and decide promotion to voter status
- Dead server cleanup - periodic, automatic clean-up of failed servers
Vault enables Autopilot by default upon upgrading to Vault 1.7. Server stabilization works by default, but you must explicitly enable dead server cleanup. You will learn more about dead server cleanup the autopilot configuration section.
Prerequisites
This tutorial requires Vault, sudo access, and additional configuration to create the cluster.
Scenario setup
To try the autopilot feature, you will use a terminal session and a shell script to start 6 Vault servers. Each server listens to a different port as shown in the diagram below.
- Initialize and unseal vault_1 (
http://127.0.0.1:8100
). The root token creates a transit key that enables the other Vaults auto-unseal. This Vault server is not a part of the cluster. - Initialize and unseal vault_2 (
http://127.0.0.1:8200
). This Vault starts as the cluster leader. The script creates an example K/V-V2 secret. - Start vault_3 (
http://127.0.0.1:8300
). It automatically joins the cluster viaretry_join
. - Start vault_4 (
http://127.0.0.1:8400
). It automatically joins the cluster viaretry_join
. - Start vault_5 (
http://127.0.0.1:8500
). It automatically joins the cluster viaretry_join
. - Start vault_6 (
http://127.0.0.1:8600
). It automatically joins the cluster viaretry_join
.
Tip
If this is your first time setting up a Vault cluster with integrated storage, you're encouraged to complete the Vault HA Cluster with Integrated Storage tutorial first, and then return to this tutorial.
Retrieve the configuration by cloning the
hashicorp-education/learn-vault-raft
repository from GitHub.Change the working directory to
learn-vault-raft/raft-autopilot/local
.Set the
run-all.sh
file to executable.Execute the
run_all.sh
script to spin up a Vault cluster with 5 nodes.You can find the server configuration files and the log files in the working directory.
Export the
VAULT_ADDR
environment variable to address thevault_2
server:Verify the cluster.
The
vault_2
is the leader.
Understand the autopilot behavior
Print the help message for the
vault operator raft autopilot
command.Display the current cluster autopilot state.
This displays the cluster health, and its failure tolerance.
The current leader node is vault_2
. The Failure Tolerance is 2
.
This means you can lose up to 2 nodes and still keep quorum.
Note that the healthy parameter value is true
for all nodes
in the cluster.
Refer to the deployment table for the quorum size and failure tolerance for various cluster sizes.
Stop one of the nodes
Set the
cluster.sh
file to executable.Stop
vault_6
.Optional: You can verify that
vault_6
is not running.Check the cluster health.
Notice that the Healthy state of the cluster is
false
, and the Failure Tolerance is now1
.Now, the Healthy parameter value is
false
on the cluster, and the Failure Tolerance is1
. The Healthy state of thevault_6
isfalse
, so you know it has failed.Although
vault_6
is no longer running, it's still a cluster member at this point.
Autopilot configuration
Check the autopilot settings to learn the default behavior.
Parameter | Description |
---|---|
Cleanup Dead Servers (bool ) | Specifies automatic removal of dead server nodes periodically. |
Last Contact Threshold (string ) | Limit the amount of time a server can go without leader contact before it's considered unhealthy. |
Dead Server Last Contact Threshold (string ) | Limit the amount of time a server can go without leader contact before it's considered failed. This should be typically a high duration, such as a day, else it being too low may result in removal of nodes that aren't actually dead. |
Server Stabilization Time | Minimum amount of time a server must be stable in the 'healthy' state before it's added to the cluster. |
Min Quorum (int ) | Minimum number of servers allowed in a cluster before autopilot can prune dead servers. |
Max Trailing Logs (int ) | Maximum number of log entries in the Raft log that a server can be behind its leader before it's considered unhealthy. |
Disable Upgrade Migration (bool ) | Specifies whether to perform automatic upgrade migration |
Check the current autopilot configuration.
The Cleanup Dead Servers parameter is
false
.Update the autopilot configuration to enable the dead server cleanup. For demonstration in this tutorial, set Dead Server Last Contact Threshold to 1 minute, and the Server Stabilization Time to 30 seconds. Note that Dead Server Last Contact Threshold especially should be set to a much larger value in production, and should generally be in the time-scale of days or hours, not minutes. The consequences of this being too low could have the drastic consequences of removing a node that wasn't actually dead.
Warning
These example values are for use just in this tutorial. These values should not be used in a production environment.
Verify the updated configuration.
Check the cluster health.
The cluster's Healthy parameter value is back to
true
. Notice thatvault_6
is no longer listed. The Voters parameter listsvault_2
throughvault_5
.List cluster peers to learn about the cluster's health, and leader status.
Add a new node to the cluster
Explore how the autopilot configuration settings influence the cluster when you add a new node.
Add a new node (
vault_7
) to the cluster.List the cluster members.
Notice that the
vault_7
server is a non-voter. (The Voter parameter value isfalse
.)Check the cluster health.
The
vault_7
server joins the cluster as a non-voter until the Server Stabilization Time of 30 seconds elapses.Wait for 30 seconds and check the cluster peers.
Now, the
vault_7
server should be a voter. This is a part of the server stabilization mechanism of the autopilot.
Vault Enterprise
The explicit non-voter nodes behave the same way as before and remain non-voters as designed. If you enable dead server cleanup, it prunes failed non-voters.
Configure the state change interval
By default, the autopilot picks up any state change an interval of 10 seconds.
To change the default, set the autopilot_reconcile_interval
parameter inside
the storage
stanza in the server configuration file.
Example: The following server configuration file sets the autopilot to picks up state change an interval of 15 seconds.
Clean up
The cluster.sh
script provides a clean
operation that removes all services,
configuration, and modifications to your local system.
Clean up your local workstation.
Help and reference
- Integrated Storage Internal documentation
- Integrated Storage Concepts documentation
- Automate Upgrades with Vault Enterprise
- Commands (CLI) - operator raft autopilot
- API docs - sys/storage/raft/autopilot
- Vault HA Cluster with Integrated Storage tutorial
- Preflight Checklist - Migrating to Integrated Storage
Vault Enterprise Replication
If you are running Vault Enterprise with replication enabled, read the Replication section in the Autopilot documentation for additional information.
The following tutorials walk through the Enterprise Replication setup: