Skip to content

Kind · os.platform-kit.org/v1alpha1

EtcdBackupPolicy

An EtcdBackupPolicy takes snapshots of the etcd of one TalosCluster on a schedule. It says where to store them, for whom to encrypt them, and how many to keep. Each snapshot is an EtcdSnapshot.

Group and version
os.platform-kit.org/v1alpha1
Scope
Cluster.
Written by
You write the spec. The operator writes the status.
Reconciled by
EtcdBackupPolicy controller (schedule and retention) and EtcdSnapshot controller (each snapshot).
Approval
None. A snapshot reads etcd and changes no machine. A restore needs approval.
Who may write it
Only a member of the admin group creates a policy or changes spec.encryption or spec.sink. These fields decide who can read the snapshots and where they go. See RBAC › Get into the admin group.
Conditions
Ready, BackedUp.
Sample
etcdbackup.yaml
The etcd backup pipeline. A policy creates a snapshot record. The operator streams the snapshot from a healthy etcd member, verifies it, encrypts it with age, writes it to the sink, reads it back and prunes old snapshots.operator (manager process)EtcdBackupPolicyevery spec.intervalEtcdSnapshotone recordControl planea healthy follower firstcreatespicks membertalos etcd snapshotSnapshotstream from etcdVerifybbolt + sha256Encryptage recipientsSinks3 or pvcRead backhash ciphertextRetentioncount, maxAgeVerified=True
One snapshot. The operator holds only public keys: it can write a backup, but it cannot read one.
  1. Schedule. When spec.interval has passed, the policy makes an EtcdSnapshot named <policy>-<UTC time>. Only one snapshot of a policy runs at a time.
  2. Snapshot. The operator picks a healthy member that votes, a follower before the leader, and streams the snapshot from it.
  3. Verify. On the way in, it checks the bytes: a valid bbolt database, and the sha256 trailer of etcd when there is one.
  4. Encrypt. It encrypts the stream with age to the public keys in spec.encryption.ageRecipients.
  5. Sink. It writes the ciphertext to the S3 bucket or to the backup volume.
  6. Read back. It reads the object again and compares size and hash. Only then is the snapshot Verified=True.
  7. Retention. The policy deletes old snapshots: it deletes the stored object before the record.
retention.count
Keeps this many verified snapshots, the newest. The default is 14.
retention.maxAge
Deletes verified snapshots older than this. Not set: no age limit.
Newest verified
Never deleted, at any age. If all snapshots fail for a time, the last good one stays.
Failed snapshots
The policy keeps the 3 newest failures, so you can read why. It deletes older ones.
Sink Where Use it for
s3 A bucket of an S3-compatible store, off the cluster Production. Always for the cluster that the operator runs on.
pvc The backup volume of the operator (component config/etcd-backup) Clusters that the operator manages from outside

The s3 endpoint must use https://. allowPlainHTTP: true lets a store in a lab use http://. Do not set it in production: the store credentials then go over the network as plain text.

FieldTypeDescription
clusterRefrequiredobjectClusterRef names the TalosCluster whose etcd is backed up.
  • Rule: clusterRef is frozen: create another policy for another cluster
namerequiredstringThe name of the object.
encryptionrequiredobjectEncryption names who can read the snapshots.
ageRecipientsrequired[]stringAgeRecipients are age public keys (age1..., from age-keygen -y). Any one of their identities decrypts a snapshot; the operator holds none, so it cannot. Name at least two people or a person and a key kept offline, so that a restore does not hang on one key. Post-quantum keys (age1pq1...) cannot be mixed with classic ones.Bounds: 1 to 16 itemsPattern: ^age1[0-9a-z]+$
intervalrequiredstringInterval is the time between scheduled snapshots (6h, 30m). At least 5m: a snapshot reads the whole database from one member.
  • Rule: interval must be at least 5m
retentionobjectRetention bounds how many snapshots are kept, and for how long.
countinteger (int32)Count is how many verified snapshots to keep, the newest.Default: 14Bounds: 1 to 1000
maxAgestringMaxAge deletes verified snapshots older than this (168h for a week). Unset keeps any age, up to Count.
  • Rule: maxAge must be at least 1h
sinkrequiredobjectSink is where the encrypted snapshots are stored.
  • Rule: set exactly one of s3 or pvc
pvcobjectPVC stores snapshots on the operator's backup volume (the config/etcd-backup component mounts a PersistentVolumeClaim into the manager). Refused for the cluster the operator itself runs on: that volume lives on the etcd it would back up, and is lost with it.
s3objectS3 stores snapshots in a bucket of an S3-compatible object store, off the cluster: the sink for production.
  • Rule: endpoint must be https://; set allowPlainHTTP: true only for a lab store, because http:// sends the store's credentials in the clear
allowPlainHTTPbooleanAllowPlainHTTP lets endpoint be http://, for a store in a lab. The snapshots are encrypted either way, but the store's credentials and the snapshot keys are not, and anyone on the path can delete or replace the ciphertext. Never set it in production.
bucketrequiredstringBucket must exist; the operator does not create it.Bounds: 3 to 63 characters
caSecretRefobjectCASecretRef names a Secret in the operator's namespace whose key ca.crt (PEM) replaces the system roots for the endpoint.
namerequiredstringThe name of the object.
credentialsSecretRefrequiredobjectCredentialsSecretRef names a Secret in the operator's namespace with keys accessKeyID and secretAccessKey. Give the key write, read, list and delete on the bucket (or the prefix) and nothing else.
namerequiredstringThe name of the object.
endpointrequiredstringEndpoint is the store's URL, https://host[:port] (https://s3.eu-central-1.amazonaws.com, https://minio.example:9000). http:// needs allowPlainHTTP.Pattern: ^https?://[^/]+/?$
pathStylebooleanPathStyle sends requests as https://host/bucket/key, which most stores other than AWS need.
prefixstringPrefix goes in front of every key; the key is <prefix><cluster>/<snapshot>.db.age.Pattern: ^([^/].*/)?$
regionstringRegion of the bucket; empty lets the client ask the store.
suspendbooleanSuspend stops scheduled snapshots; pk-metal backup now still takes one, and retention still prunes.
FieldTypeDescription
conditions[]objectConditions: Ready (the sink and recipients can be used) and BackedUp (a verified snapshot newer than twice the interval exists).
consecutiveFailuresinteger (int32)ConsecutiveFailures counts the snapshots that failed since the newest verified one.
lastScheduleTimestring (date-time)LastScheduleTime is when the last scheduled snapshot was started.
lastSuccessfulSnapshotobjectLastSuccessfulSnapshot is the newest verified snapshot.
namerequiredstring
takenAtrequiredstring (date-time)
verifiedSnapshotsinteger (int32)VerifiedSnapshots counts the verified snapshots kept.

Columns of kubectl get etcdbackuppolicies (the columns marked wide show only with -o wide):

ColumnValue
NAME.metadata.name
CLUSTER.spec.clusterRef.name
INTERVAL.spec.interval
LAST.status.lastSuccessfulSnapshot.takenAt
FAILURES.status.consecutiveFailures
BACKEDUP.status.conditions[?(@.type=="BackedUp")].status
Condition Reason Meaning
Ready SinkReady The cluster exists, and the sink and the recipients work.
Ready SinkRefused, SinkUnavailable, RecipientsInvalid, ClusterNotFound The policy cannot take snapshots.
BackedUp SnapshotRecent A verified snapshot is newer than two intervals.
BackedUp NoSnapshot, BackupTooOld No verified snapshot, or the newest is older than two intervals.

Watch status.consecutiveFailures. Send an alert when it is above zero for longer than one interval.

apiVersion: os.platform-kit.org/v1alpha1
kind: EtcdBackupPolicy
metadata:
name: lab-offsite
spec:
clusterRef:
name: lab
interval: 6h
retention:
count: 28
maxAge: 336h
sink:
s3:
endpoint: https://s3.example.org
bucket: etcd-backups
prefix: metal/
credentialsSecretRef:
name: etcd-backup-s3
encryption:
ageRecipients:
- age1examplepersononexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- age1exampleofflinekeyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Set spec.suspend: true to stop the schedule. pk-metal backup now still takes a snapshot, and retention still runs.