A certificate nobody has to renew
SVID rotation means the SPIRE agent replaces a workload's certificate before it expires, with nobody involved. A short lifetime limits what a stolen key is worth.
Short lifetimes only work if renewal never fails quietly. So running SPIRE is about watching the server and the agents, and planning what happens when one is away.
By the end of this lesson
Note
I can work out when SPIRE will rotate an SVID from its time to live.
Key words
| Word | What it means | Example |
|---|---|---|
| TTL | time to live, how long an SVID is valid | 3600 seconds |
| Rotation | replacing an SVID before it expires | |
| Federation | trusting another trust domain's bundle | |
| Bundle endpoint | where a trust domain publishes its bundle | |
| Health check | a quick test that a service is working |
The cells students fill in are left blank in this preview.
The agent rotates at half the lifetime
Each entry can set its own TTL; otherwise the server's default is used, an hour in this lab. The agent asks for a new SVID once about half the lifetime has passed.
A workload that keeps asking the Workload API simply receives the new one. The next Runs give the user clock a 60-second SVID and fetch it twice, 40 seconds apart.
Register clock with a 60-second TTL
sudo spire-server entry create -parentID spiffe://lab.test/spire/agent/x509pop/spire-lab -spiffeID spiffe://lab.test/clock -selector unix:user:clock -x509SVIDTTL 60Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Fetch clock's SVID
sudo -u clock spire-agent api fetch x509Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Wait forty seconds
sleep 40Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Fetch clock's SVID again
sudo -u clock spire-agent api fetch x509Shown here, not run. Press Start lab to type it into your own lab’s terminal.
What changed between the two fetches
The entry shows X509-SVID TTL : 60. Each fetch shows SVID Valid After and SVID Valid Until 70 seconds apart: 60, plus the ten seconds SPIRE starts early.
The second fetch shows later times than the first. The agent replaced the SVID about halfway through its life, and clock changed nothing. The exact times differ in every copy.
Worked example: an hour-long SVID
| SVID | Issued | Rotated | Expires |
|---|---|---|---|
| 1 | 09:00 | 09:30 | 10:00 |
| 2 | 09:30 | 10:00 | 10:30 |
| 3 | 10:00 | 10:30 | 11:00 |
| A day | 48 SVIDs | every 30 minutes | none of them by hand |
The cells students fill in are left blank in this preview.
Federation trusts another trust domain
Two companies, or two clusters with separate servers, each have their own trust domain. Federation lets a workload in one check SVIDs from the other.
Each server publishes its trust bundle at a bundle endpoint. The other server fetches it on a schedule and hands it to its agents. Entries then say which workloads may trust the other domain.
Show the bundle as SPIFFE publishes it
sudo spire-server bundle show -format spiffeShown here, not run. Press Start lab to type it into your own lab’s terminal.
List the federation relationships
sudo spire-server federation listShown here, not run. Press Start lab to type it into your own lab’s terminal.
A bundle is a set of public keys
The bundle prints a JSON document with a list called keys. One key has "use": "x509-svid" and the CA certificate in x5c; another has "use": "jwt-svid". It ends with spiffe_sequence.
It holds public keys only, so publishing it is safe. The federation list prints Found 0 federation relationships: this lab has one trust domain.
Check the server's health
sudo spire-server healthcheckShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think a short TTL alone makes a system safe. If the server is down longer than half the TTL, SVIDs expire and calls fail. Pick a TTL your monitoring can protect, and alert on the health checks.