One vault for every secret, with its key kept in another location

Every site we host needs a database password. Every mailbox needs one. The pipelines that build the sites need tokens to push what they built. All of these live in one place on our cluster in Tyrol: a HashiCorp Vault, a piece of software that stores secrets and hands them out only to someone who can prove who they are.

I run the platform alone, so the handling of secrets has to be done by machines, with me stepping in only where I decided to step in.

The key is kept in another location

The vault runs three times on the cluster, one active and two standing by, each with a full copy of the data. When one of the machines fails, another copy takes over.

A vault starts sealed. In the normal setup several people hold parts of the key and have to come together to open it. Ours unseals itself, but the key for that is not in the data center. A second, small vault on a machine in another location holds it.

That second vault seals itself on every restart, on purpose. Until I unseal it with one command, a vault node in the cluster that restarts cannot start. The running sites keep working during that time, and monitoring pages me when the second vault is sealed.

How a site or a pipeline gets its secrets

The applications on the cluster never talk to the vault themselves. A small operator copies the secrets a workload needs into the cluster and refreshes them when they change. The site controller from an earlier post, One entry in a file becomes a live, monitored website, writes the database credentials of a new site into the vault when it creates the site, and removes them when the site is removed.

The build pipelines have no stored passwords. When a job runs, GitLab gives it a signed identity token that says which project and which branch it belongs to. The job shows that token to the vault, the vault checks the signature and the origin, and hands out a token that is valid for ten minutes. Each project has its own role and its own policy, and only jobs on protected branches get in. I wrote these roles and policies as code and apply them with Terraform.

What happens when the vault is gone

Once a night a job takes a snapshot of the vault, writes a checksum next to it and stores both outside the cluster. Thirty snapshots are kept. The job runs with an identity that can take snapshots and nothing else. Once a week another job verifies the latest snapshot against its checksum and tells me if the two do not match.

For the worst case there is a written procedure: export all secrets, set up both vaults new, import everything. I have done that once for real.

Author: René Zingerle, CISSP, SSCP
Last Update: 25.11.2026