Day 2
Restore etcd
Bring back the etcd of a cluster with the minimum data loss.
Before you start
Section titled “Before you start”- A person with
pk-metal-approvercan approve. That is you, if your site allows self-approval. If not, it is a second person. See Set up approval permissions. - For a lost majority: you have an age identity that can decrypt the snapshot, and a verified snapshot exists.
- The operator never restores and never bootstraps again by itself.
Find the case
Section titled “Find the case”pk-metal restore plan prodThe command asks each control plane about its etcd. It changes nothing.
| What the plan sees | Case |
|---|---|
| Each member healthy | Nothing to do |
| One member stopped or has errors; the others keep a majority | One member lost |
| No control plane lists members, or most do not answer | Majority lost |
| The operator's own cluster has no etcd | Management cluster lost |
One member lost
Section titled “One member lost”No snapshot is necessary. The broken member leaves, its data is wiped, and it joins again.
-
Propose the repair.
Terminal window pk-metal restore plan prod --proposeThe command makes
prod-etcd-replace-<node>with EtcdRemoveMember, TalosReset and WaitEtcdHealthy. -
Approve it. If your site forbids self-approval, ask a second person to approve it.
Terminal window pk-metal approve pk-metal/prod-etcd-replace-cp-2 -
Monitor it until it is
Succeeded.Terminal window kubectl -n pk-metal get hostoperation prod-etcd-replace-cp-2 -w
Repair one member at a time. With three control planes, a second lost member is a lost majority.
Majority lost
Section titled “Majority lost”Restore from a snapshot
1 / 5
Plan
The plan picks the newest verified snapshot and one control plane. It shows when the snapshot was taken.
pk-metal restore plan prod --proposePlan. The plan picks the newest verified snapshot and one control plane. It shows when the snapshot was taken.
pk-metal restore plan prod --proposeReset. An approved reset wipes the etcd data on each control plane that runs a stuck etcd.
prod-etcd-reset-cp-2, prod-etcd-reset-cp-3Upload. After the approval, you decrypt the snapshot on your workstation and stream it to cp-1. The plain data never touches a disk.
pk-metal restore upload pk-metal/prod-etcd-recover-cp-1 --identity ~/.config/age/keys.txtRecover. etcdRecover starts etcd on cp-1 from the snapshot, one time.
Join. The other control planes join the restored member. Bootstrapped is True again.
-
List the snapshots.
Terminal window pk-metal backup list prod -
Propose the plan. Name the snapshot and the control plane, or take the defaults.
Terminal window pk-metal restore plan prod --snapshot prod-offsite-20261124-060000 --node cp-1 --propose -
Approve each reset operation, or ask a second person if your site forbids self-approval.
Terminal window pk-metal approve pk-metal/prod-etcd-reset-cp-2 -
Approve the recover operation, or ask a second person if your site forbids self-approval.
Terminal window pk-metal approve pk-metal/prod-etcd-recover-cp-1 -
Upload the snapshot. For a
pvcsink, copy the snapshot first. Then add--from-file <file.age>.Terminal window pk-metal restore upload pk-metal/prod-etcd-recover-cp-1 --identity ~/.config/age/keys.txt -
Monitor the operations.
Terminal window kubectl -n pk-metal get hostoperation -l os.platform-kit.org/etcd-restore=prod
Copy a snapshot from a pvc sink
Section titled “Copy a snapshot from a pvc sink”The manager image has no shell. Use a small pod that mounts the backup volume.
The pod runs as the user of the manager, which owns the files.
It meets the restricted Pod Security level of the namespace.
-
Find the node of the manager. A volume that attaches to one node only needs the pod on that node.
Terminal window node=$(kubectl -n pk-metal get pod -l app.kubernetes.io/name=pk-metal,app.kubernetes.io/component=manager \-o jsonpath='{.items[0].spec.nodeName}') -
Start the reader pod on that node.
Terminal window kubectl apply -f - <<YAMLapiVersion: v1kind: Podmetadata:name: etcd-backup-readernamespace: pk-metalspec:nodeName: $noderestartPolicy: NeversecurityContext:runAsNonRoot: truerunAsUser: 65532runAsGroup: 65532seccompProfile: { type: RuntimeDefault }containers:- name: readerimage: busybox:1.37command: ["sleep", "3600"]securityContext:allowPrivilegeEscalation: falsecapabilities: { drop: ["ALL"] }volumeMounts:- { name: backups, mountPath: /backups, readOnly: true }volumes:- name: backupspersistentVolumeClaim: { claimName: pk-metal-etcd-backups, readOnly: true }YAMLkubectl -n pk-metal wait --for=condition=Ready pod/etcd-backup-reader -
Copy the snapshot. Its path is
<cluster>/<snapshot>.db.age, asstatus.keyof the EtcdSnapshot shows.Terminal window kubectl -n pk-metal exec etcd-backup-reader -- ls -l /backups/prodkubectl -n pk-metal exec etcd-backup-reader -- cat /backups/prod/prod-daily-20261124-060000.db.age > prod.db.age -
Delete the pod.
Terminal window kubectl -n pk-metal delete pod etcd-backup-reader
Give the file to pk-metal restore upload --from-file, or decrypt it with pk-metal backup decrypt --in prod.db.age.
Verify
Section titled “Verify”kubectl get taloscluster prodshowsBootstrapped=TrueandAvailable=True.pk-metal restore plan prodreports that each member is healthy.
If it fails
Section titled “If it fails”| What you see | Go to |
|---|---|
etcdRecover waits for a control plane that never answers |
Remove its TalosNode, or replace the machine. Then plan again. |
restore upload stops on a hash mismatch |
The file is not the approved snapshot. Use the approved one. |
Bootstrapped=False with another reason |
Bootstrap refused |
Related
Section titled “Related”- pk-metal restore, EtcdRecover, EtcdSnapshot
- etcd unhealthy or quorum lost
- mise run lab:backup-restore runs the majority-lost case in the lab.