Day 2
Back up etcd
Keep verified, encrypted etcd snapshots of a cluster away from its machines.
Before you start
Section titled “Before you start”- You have
age-keygen. - You are a member of the admin group. Only an admin creates a backup policy or changes its recipients or sink. See RBAC › Get into the admin group.
- For an S3 sink: a bucket and a key that can write, read, list and delete there. The endpoint must use
https://. - A snapshot reads etcd only. It needs no approval.
-
Each person who may restore makes an age key pair. Keep
keys.txtlike an SSH private key.Terminal window age-keygen -o ~/.config/age/keys.txt -
Show the public key. It starts with
age1.Terminal window age-keygen -y ~/.config/age/keys.txt -
Put the S3 key into a Secret in
pk-metal.Terminal window kubectl -n pk-metal create secret generic etcd-backup-s3 \--from-literal=accessKeyID=AKEXAMPLE --from-literal=secretAccessKey="$S3_SECRET" -
Write an EtcdBackupPolicy. Name at least two recipients.
prod-offsite.yaml apiVersion: os.platform-kit.org/v1alpha1kind: EtcdBackupPolicymetadata:name: prod-offsitespec:clusterRef:name: prodinterval: 6hretention:count: 28sink:s3:endpoint: https://s3.example.orgbucket: etcd-backupsprefix: metal/pathStyle: truecredentialsSecretRef:name: etcd-backup-s3encryption:ageRecipients:- age1qexampleperson0000000000000000000000000000000000000000000- age1qexampleoffline000000000000000000000000000000000000000000 -
Apply it as a member of the admin group.
Terminal window kubectl apply -f prod-offsite.yaml -
Take the first snapshot now. The command waits until the operator verifies the snapshot.
Terminal window pk-metal backup now prod-offsite -
Decrypt it on your workstation, as a test. Without
-o, the command writes no plain file.Terminal window pk-metal backup decrypt prod-offsite-20261124-060000 --identity ~/.config/age/keys.txt
Verify
Section titled “Verify”pk-metal backup list prodkubectl get etcdbackuppolicy prod-offsiteThe policy shows BackedUp=True and 0 failures.
If it fails
Section titled “If it fails”| What you see | Go to |
|---|---|
Ready=False, SinkRefused, SinkUnavailable or RecipientsInvalid |
Backup failing |
BackedUp=False, BackupTooOld |
Backup failing |