Repository navigation
Add a chart for nightly etcd backups of a hub - #217
Conversation
A hub has no etcd backups unless someone takes them (800-53 CP-9). This chart runs the cluster's own cluster-backup.sh on a control plane node each night, as oc debug node does, and keeps the newest 14 on a volume with checksums. It has run jetty nightly since 2026-10-08, where a restore from it has been rehearsed, and nist-dev-infra from a fork. OpenShift's own backup API still needs a Tech Preview feature gate on 4.22. - image: the release's cli image by digest, so CRI-O verifies its signature. Required; it changes with every release. - schedule, retain: 02:30 UTC, clear of the compliance scans, and 14. - storage: the default class unless one is set, 10Gi. A backup holds the etcd encryption key, so it can decrypt every Secret in it: the namespace holds nothing else, files are 0600 root. After the volume binds, patch its PV to Retain. It does not back up hosted clusters, whose etcd runs in the hub's HCP namespaces. Clusters affected: none. No ApplicationSet uses the chart yet. Unit tests cover the objects, privileges, placement, storage, schedule and file modes.
larsks
left a comment
There was a problem hiding this comment.
Left some minor comments, but otherwise this looks fine.
| image: "" | ||
|
|
There was a problem hiding this comment.
Can we default to the in-cluster cli imagestream?
| image: "" | |
| image: "image-registry.openshift-image-registry.svc:5000/openshift/cli" |
This will always point at the correct upstream image. E.g., on dev-workload0 this points to:
$ oc -n openshift get is cli -o jsonpath='{.status.tags[*].items[*].dockerImageReference}'
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:b4e48cec3040a0f18fe5697e128d8deb1c9409c28b6b3249c789f7beaba10fea
There was a problem hiding this comment.
I kept the pinned image for now, sorry. On bare metal the image registry starts Removed (it is on oac-dev-infra), and a pull through it isn't signature-verified. The values comment now names the imagestream for clusters whose registry is Managed. Happy to change it if you'd rather.
| - | | ||
| set -euo pipefail | ||
| chmod 700 /backup # NFS root arrives 0777; backups are Secret-grade | ||
| ts=$(date -u +%Y-%m-%dT%H%M%SZ) |
There was a problem hiding this comment.
I kept it without colons, since tar and scp read a colon in a path as host:path. Happy to switch if you prefer.
The schedule's reason moves from the template to values.yaml, where the value is set, so it cannot go stale when someone changes it. The image comment now says why the default is a pinned cli image and not the in-cluster openshift/cli imagestream: on bare metal the image registry starts Removed (oac-dev-infra's is), and a pull through the registry is not signature-verified. A cluster whose registry is Managed can set the imagestream. An older release's image keeps working after an upgrade, since the job only uses its bash and coreutils.
| {{- end }} | ||
| resources: | ||
| requests: | ||
| storage: {{ .Values.storage.size }} |
There was a problem hiding this comment.
I am worried about backing up the etcd to a dynamically created PVC because if the cluster were to go down then we would have no way of knowing which volume on the flashblade actually has the etcd backup. We could mount all the drives and then search through to find the one with the backup - but that doesn't sound fun in a disaster recovery scenario.
I think we should create a volume out-of-band on the flashblade, and reference that here. Though, before we do that we should test how our portworx setup works. This brings up another security concern if we were to do this same thing on a hosted cluster - can a random user put the name of this out-of-band volume and claim as their own and look at all the etcd contents? I don't know but something to think about.
There was a problem hiding this comment.
can a random user put the name of this out-of-band volume
I'm interested in seeing how portworx actually implements their cosi driver -- ideally, credentials should be namespaced so that a random user could only ever interact with buckets that were created from within namespaces to which they have access.
But I think this is less of a concern, because...
I think we should create a volume out-of-band on the flashblade, and reference that here.
...if we do that, there's no requirement that we use the same realm as the cosi driver. By using a separate realm for admin backups, we keep them entirely separate from the cosi system.
There was a problem hiding this comment.
@larsks I am confused. We are talking about NFS volumes created by the CSI driver, not buckets so COSI isn't in the picture.
We could create a bucket out of band, stick the credentials in secretsmanager and then this chart could be updated to dump the backups in that bucket instead of this dynamic PVC - that was another idea @EldritchJS had.
There was a problem hiding this comment.
Ah, I was assuming S3 for backups because that doesn't tie us to a local provider (we could decide to back up to an offsite bucket instead, which is what we did in the NERC environment for a number of backups).
There was a problem hiding this comment.
@EldritchJS let's put it in an offsite S3 (we have backblaze for that, and a bucket and keys could be provisioned by submitting a PR to moc-aws). But we could do it in a different PR so I am going to approve this.
The backup volume is provisioned dynamically, so its name on the FlashBlade is generated (px_<cluster id>-pvc-<claim uid>) and only the cluster knows it. If the hub is lost, nobody can tell which filesystem holds etcd. values.yaml now gives the steps to run once after the first sync: patch the PV to Retain, look up the FlashBlade name from its PureVolume, and record it in AWS Secrets Manager as cluster/<hub>/etcd-backup-volume. The Retain note moves there from the template, with the size reasoning.
A hosted cluster's etcd runs as pods on the hub (etcd-0..2 in clusters-<name>), and nothing backed it up: the hub's job copies only the hub's own etcd. hostedClusters lists them. For each, a CronJob in the etcd-backup namespace runs etcdctl snapshot save in a ready etcd pod, streams the file to its own volume, checks the copy's hash and keeps the newest $retain. It needs no privileges: a Role allows only pod reads and exec in clusters-<name>. The namespace's egress policy must allow the API server. A restore also needs the cluster's Secret encryption key, which the hub's own backup holds. Empty by default, so nothing changes until a cluster is listed. Run on compliant-dev-infra for compliant-dev-workload0 (136 MB, 2026-11-20).
A hub has no etcd backups unless someone takes them (800-53 CP-9).
This chart runs the cluster's own cluster-backup.sh on a control
plane node each night, as oc debug node does, and keeps the newest 14
on a volume with checksums. It ran nightly on jetty from 2026-10-08
until jetty was reinstalled on 2026-10-28, and a restore from it was
rehearsed there; it also ran on nist-dev-infra from a fork.
OpenShift's own backup API still needs a Tech Preview feature gate on
4.22.
signature. Required; it changes with every release.
A backup holds the etcd encryption key, so it can decrypt every
Secret in it: the namespace holds nothing else, files are 0600 root.
It does not back up hosted clusters, whose etcd runs in the hub's HCP
namespaces.
The volume's name on the FlashBlade is generated, so only the cluster
knows which filesystem holds the backups. values.yaml gives the steps
to run once after the first sync: patch the PV to Retain, look up the
FlashBlade name from its PureVolume, and record it in AWS Secrets
Manager as cluster//etcd-backup-volume.
Clusters affected: none. No ApplicationSet uses the chart yet. Unit
tests cover the objects, privileges, placement, storage, schedule and
file modes.
Added 2026-11-20: hosted clusters
hostedClustersbacks up the etcd of hosted clusters the hub runs, one unprivileged CronJob and volume each (exec inclusters-<name>only). Empty by default. Tested on compliant-dev-infra for compliant-dev-workload0.