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.
At a glance
Section titled “At a glance”- 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.encryptionorspec.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
Pipeline
Section titled “Pipeline”- Schedule. When
spec.intervalhas passed, the policy makes an EtcdSnapshot named<policy>-<UTC time>. Only one snapshot of a policy runs at a time. - Snapshot. The operator picks a healthy member that votes, a follower before the leader, and streams the snapshot from it.
- Verify. On the way in, it checks the bytes: a valid bbolt database, and the sha256 trailer of etcd when there is one.
- Encrypt. It encrypts the stream with age to the public keys in
spec.encryption.ageRecipients. - Sink. It writes the ciphertext to the S3 bucket or to the backup volume.
- Read back. It reads the object again and compares size and hash. Only then is the snapshot
Verified=True. - Retention. The policy deletes old snapshots: it deletes the stored object before the record.
Retention
Section titled “Retention”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.
| Field | Type | Description |
|---|---|---|
clusterRefrequired | object | ClusterRef names the TalosCluster whose etcd is backed up.
|
namerequired | string | The name of the object. |
encryptionrequired | object | Encryption names who can read the snapshots. |
ageRecipientsrequired | []string | AgeRecipients 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. |
intervalrequired | string | Interval is the time between scheduled snapshots (6h, 30m). At least 5m: a snapshot reads the whole database from one member.
|
retention | object | Retention bounds how many snapshots are kept, and for how long. |
count | integer (int32) | Count is how many verified snapshots to keep, the newest. |
maxAge | string | MaxAge deletes verified snapshots older than this (168h for a week). Unset keeps any age, up to Count.
|
sinkrequired | object | Sink is where the encrypted snapshots are stored.
|
pvc | object | PVC 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. |
s3 | object | S3 stores snapshots in a bucket of an S3-compatible object store, off the cluster: the sink for production.
|
allowPlainHTTP | boolean | AllowPlainHTTP 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. |
bucketrequired | string | Bucket must exist; the operator does not create it. |
caSecretRef | object | CASecretRef names a Secret in the operator's namespace whose key ca.crt (PEM) replaces the system roots for the endpoint. |
namerequired | string | The name of the object. |
credentialsSecretRefrequired | object | CredentialsSecretRef 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. |
namerequired | string | The name of the object. |
endpointrequired | string | Endpoint is the store's URL, https://host[:port] (https://s3.eu-central-1.amazonaws.com, https://minio.example:9000). http:// needs allowPlainHTTP. |
pathStyle | boolean | PathStyle sends requests as https://host/bucket/key, which most stores other than AWS need. |
prefix | string | Prefix goes in front of every key; the key is <prefix><cluster>/<snapshot>.db.age. |
region | string | Region of the bucket; empty lets the client ask the store. |
suspend | boolean | Suspend stops scheduled snapshots; pk-metal backup now still takes one, and retention still prunes. |
Status
Section titled “Status”| Field | Type | Description |
|---|---|---|
conditions | []object | Conditions: Ready (the sink and recipients can be used) and BackedUp (a verified snapshot newer than twice the interval exists). |
consecutiveFailures | integer (int32) | ConsecutiveFailures counts the snapshots that failed since the newest verified one. |
lastScheduleTime | string (date-time) | LastScheduleTime is when the last scheduled snapshot was started. |
lastSuccessfulSnapshot | object | LastSuccessfulSnapshot is the newest verified snapshot. |
namerequired | string | |
takenAtrequired | string (date-time) | |
verifiedSnapshots | integer (int32) | VerifiedSnapshots counts the verified snapshots kept. |
Columns of kubectl get etcdbackuppolicies (the columns marked wide show only with -o wide):
| Column | Value |
|---|---|
NAME | .metadata.name |
CLUSTER | .spec.clusterRef.name |
INTERVAL | .spec.interval |
LAST | .status.lastSuccessfulSnapshot.takenAt |
FAILURES | .status.consecutiveFailures |
BACKEDUP | .status.conditions[?(@.type=="BackedUp")].status |
Conditions
Section titled “Conditions”| 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.
Example
Section titled “Example”apiVersion: os.platform-kit.org/v1alpha1kind: EtcdBackupPolicymetadata: name: lab-offsitespec: 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 - age1exampleofflinekeyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSet spec.suspend: true to stop the schedule. pk-metal backup now still takes a snapshot, and retention still runs.