Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

SVID rotation, federation and running SPIRE

After this lesson: I can work out when SPIRE will rotate an SVID from its time to live.

70 min lesson7 commandsWorkload identity lab: SPIFFE and SPIRE on k3s, with mTLS between services, on a private Ubuntu VM

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

WordWhat it meansExample
TTLtime to live, how long an SVID is valid3600 seconds
Rotationreplacing an SVID before it expires
Federationtrusting another trust domain's bundle
Bundle endpointwhere a trust domain publishes its bundle
Health checka 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

Command
sudo spire-server entry create -parentID spiffe://lab.test/spire/agent/x509pop/spire-lab -spiffeID spiffe://lab.test/clock -selector unix:user:clock -x509SVIDTTL 60

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Fetch clock's SVID

Command
sudo -u clock spire-agent api fetch x509

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Wait forty seconds

Command
sleep 40

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Fetch clock's SVID again

Command
sudo -u clock spire-agent api fetch x509

Shown 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

SVIDIssuedRotatedExpires
109:0009:3010:00
209:3010:0010:30
310:0010:3011:00
A day48 SVIDsevery 30 minutesnone 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

Command
sudo spire-server bundle show -format spiffe

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

List the federation relationships

Command
sudo spire-server federation list

Shown 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

Command
sudo spire-server healthcheck

Shown 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.

About this lab and its source: Workload identity lab: SPIFFE and SPIRE on k3s, with mTLS between services, on a private Ubuntu VM

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.