Skip to content

Commit c0552b4

Browse files
committed
feat(platform): migrate to etcd-operator v1alpha2
Signed-off-by: Andrey Kolkov <[email protected]>
1 parent 374cac1 commit c0552b4

78 files changed

Lines changed: 6608 additions & 3966 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎api/backups/strategy/v1alpha1/etcd_types.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ const (
2929
// +kubebuilder:resource:scope=Cluster
3030

3131
// Etcd defines a backup strategy that delegates execution to the
32-
// etcd-operator (etcd.aenix.io). The strategy carries a templated backup
33-
// destination configuration; the driver materialises one
34-
// etcd.aenix.io/v1alpha1 EtcdBackup per Cozystack BackupJob and surfaces
32+
// etcd-operator (etcd-operator.cozystack.io). The strategy carries a templated
33+
// backup destination configuration; the driver materialises one
34+
// etcd-operator.cozystack.io/v1alpha2 EtcdSnapshot per Cozystack BackupJob and surfaces
3535
// it as a Cozystack Backup artefact.
3636
//
3737
// Restore is in-place only: the driver suspends the source Etcd
3838
// HelmRelease, snapshots the live EtcdCluster spec, deletes it, and
3939
// re-creates the EtcdCluster with spec.bootstrap.restore.source
4040
// pointing at the Backup's S3 coordinates, then resumes the HR after
41-
// the cluster reaches Ready.
41+
// the cluster becomes Available.
4242
//
4343
// To-copy restore is NOT supported: RestoreJob.spec.targetApplicationRef
4444
// is a TypedLocalObjectReference (no namespace field), so there is no
@@ -68,7 +68,7 @@ type EtcdList struct {
6868

6969
// EtcdSpec specifies the desired etcd-operator-driven backup strategy.
7070
type EtcdSpec struct {
71-
// Template carries the templated EtcdBackup destination configuration
71+
// Template carries the templated EtcdSnapshot destination configuration
7272
// applied per BackupJob (and re-rendered against the same
7373
// .Application / .Parameters at restore time). String fields support
7474
// Helm-style Go templating with two top-level values:
@@ -80,19 +80,19 @@ type EtcdSpec struct {
8080
Template EtcdTemplate `json:"template"`
8181
}
8282

83-
// EtcdTemplate describes the templated EtcdBackup-shaped configuration the
83+
// EtcdTemplate describes the templated EtcdSnapshot-shaped configuration the
8484
// driver renders per BackupJob (and on the restore path stamps onto
8585
// EtcdCluster.spec.bootstrap.restore.source).
8686
type EtcdTemplate struct {
8787
// Destination defines where the etcd snapshot will be stored. Field
88-
// semantics mirror etcd.aenix.io/v1alpha1 EtcdBackup.spec.destination.
88+
// semantics mirror etcd-operator.cozystack.io/v1alpha2 EtcdSnapshot.spec.destination.
8989
Destination EtcdDestinationTemplate `json:"destination"`
9090
}
9191

92-
// EtcdDestinationTemplate mirrors etcd.aenix.io/v1alpha1
93-
// EtcdBackup.spec.destination, RESTRICTED to S3.
92+
// EtcdDestinationTemplate mirrors etcd-operator.cozystack.io/v1alpha2
93+
// EtcdSnapshot.spec.destination, RESTRICTED to S3.
9494
//
95-
// The upstream etcd-operator EtcdBackup.spec.destination accepts either
95+
// The upstream etcd-operator EtcdSnapshot.spec.destination accepts either
9696
// S3 or PVC, but the operator's filename convention is asymmetric
9797
// between backup and restore on the PVC path:
9898
//
@@ -118,7 +118,7 @@ type EtcdDestinationTemplate struct {
118118
}
119119

120120
// EtcdS3Template is a typed, kubebuilder-validated mirror of
121-
// etcd.aenix.io/v1alpha1 EtcdBackup.spec.destination.s3. Restores reuse
121+
// etcd-operator.cozystack.io/v1alpha2 EtcdSnapshot.spec.destination.s3. Restores reuse
122122
// the same shape: the driver re-renders the strategy and stamps the
123123
// resulting block onto EtcdCluster.spec.bootstrap.restore.source.s3 of the
124124
// target Etcd application.

‎examples/backups/etcd/00-helpers.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export BOLD='\033[1m'
1515
# Default settings (override via environment).
1616
export NAMESPACE="${NAMESPACE:-tenant-root}"
1717
# The chart pins the Helm release name (and the operator-side
18-
# etcd.aenix.io/EtcdCluster name) to "etcd" via
18+
# etcd-operator.cozystack.io/EtcdCluster name) to "etcd" via
1919
# templates/check-release-name.yaml, so the apps.cozystack.io/Etcd CR
2020
# MUST be named "etcd" per namespace. To-copy in the same namespace is
2121
# unsupported by design (chart constraint).
@@ -109,7 +109,7 @@ spec:
109109
restartPolicy: Never
110110
containers:
111111
- name: etcdctl
112-
image: quay.io/coreos/etcd:v3.5.12
112+
image: quay.io/coreos/etcd:v3.6.11
113113
command:
114114
- etcdctl
115115
- "--cacert=/etc/etcd/pki/client/ca.crt"

‎examples/backups/etcd/01-create-strategy.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# Step 01: Apply the cluster-scoped Etcd strategy. Admin operation -
33
# tenants do not author the strategy CR directly. The strategy carries
4-
# the templated EtcdBackup destination shape; the BackupClass created in
4+
# the templated EtcdSnapshot destination shape; the BackupClass created in
55
# step 02 supplies bucket/endpoint/credentials per tenant via parameters.
66
set -euo pipefail
77

‎examples/backups/etcd/02-create-bucket.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ for v in ETCD_ACCESS_KEY ETCD_SECRET_KEY ETCD_ENDPOINT ETCD_REGION ETCD_BUCKET;
4545
[[ -n "${!v}" && "${!v}" != "null" ]] || { log_error "BucketInfo missing required field: ${v}"; exit 1; }
4646
done
4747

48-
log_substep "Materialising the per-app credentials Secret consumed by the rendered EtcdBackup..."
48+
log_substep "Materialising the per-app credentials Secret consumed by the rendered EtcdSnapshot..."
4949
# The strategy template references this Secret by name:
5050
# "{{ .Application.metadata.name }}-etcd-backup-creds"
5151
# The etcd-operator's snapshot Job mounts the Secret and exposes

‎examples/backups/etcd/03-create-etcd-src.sh‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# Step 03: Apply the source Etcd application, wait for the operator-side
3-
# EtcdCluster to reach Ready, then write a sentinel key that the backup
3+
# EtcdCluster to become Available, then write a sentinel key that the backup
44
# captures and the restore round-trips. The sentinel is the in-cluster
55
# witness that the snapshot actually round-tripped through S3.
66
set -euo pipefail
@@ -27,13 +27,13 @@ EOF
2727

2828
log_substep "Waiting for HelmRelease 'etcd' to be Ready..."
2929
kubectl -n "$NAMESPACE" wait hr "${ETCD_NAME}" --for=condition=ready --timeout=300s
30-
log_substep "Waiting for etcd.aenix.io/EtcdCluster 'etcd' to be Ready..."
31-
kubectl -n "$NAMESPACE" wait etcdcluster.etcd.aenix.io etcd \
32-
--for=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'=True \
30+
log_substep "Waiting for etcd-operator.cozystack.io/EtcdCluster 'etcd' to be Available..."
31+
kubectl -n "$NAMESPACE" wait etcdcluster.etcd-operator.cozystack.io etcd \
32+
--for=jsonpath='{.status.conditions[?(@.type=="Available")].status}'=True \
3333
--timeout=300s
3434

35-
log_substep "Waiting for etcd-0 pod to be Ready..."
36-
kubectl -n "$NAMESPACE" wait pod etcd-0 --for=condition=ready --timeout=300s
35+
log_substep "Waiting for etcd member pods to be Ready..."
36+
kubectl -n "$NAMESPACE" wait pod -l app.kubernetes.io/instance=etcd --for=condition=ready --timeout=300s
3737

3838
SENTINEL_KEY="__cozystack_e2e_sentinel"
3939
SENTINEL_VAL="pristine-$(date -u +%Y%m%dT%H%M%SZ)"

‎examples/backups/etcd/05-restore-in-place.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ EOF
4545
wait_for_field restorejobs.backups.cozystack.io "$RESTOREJOB_INPLACE_NAME" \
4646
'{.status.phase}' Succeeded "$NAMESPACE" 1800
4747

48-
log_substep "Waiting for etcd-0 to be Ready again after restore..."
49-
kubectl -n "$NAMESPACE" wait pod etcd-0 --for=condition=ready --timeout=300s
48+
log_substep "Waiting for etcd member pods to be Ready again after restore..."
49+
kubectl -n "$NAMESPACE" wait pod -l app.kubernetes.io/instance=etcd --for=condition=ready --timeout=300s
5050

5151
# Helm's next apply re-renders the chart's bootstrap-less EtcdCluster
5252
# spec, which evicts the bootstrap.restore block the driver stamped on
@@ -58,7 +58,7 @@ kubectl -n "$NAMESPACE" wait pod etcd-0 --for=condition=ready --timeout=300s
5858
log_substep "Waiting for Helm to evict bootstrap.restore from the live EtcdCluster..."
5959
elapsed=0
6060
while true; do
61-
BOOTSTRAP=$(kubectl -n "$NAMESPACE" get etcdcluster.etcd.aenix.io etcd \
61+
BOOTSTRAP=$(kubectl -n "$NAMESPACE" get etcdcluster.etcd-operator.cozystack.io etcd \
6262
-o jsonpath='{.spec.bootstrap}' 2>/dev/null || true)
6363
if [[ -z "$BOOTSTRAP" || "$BOOTSTRAP" == "{}" || "$BOOTSTRAP" == "null" ]]; then
6464
log_success "bootstrap.restore evicted by Helm reconcile"

‎examples/backups/etcd/90-scenario-admin-prepare.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ prerequisite hand-off ends at "tenants can author `BackupJob` /
88
## 1. Install the operator + driver
99

1010
- `packages/system/etcd-operator` ships the upstream `etcd-operator`
11-
(CRDs: `EtcdCluster`, `EtcdBackup`, `EtcdBackupSchedule`).
11+
(CRDs: `EtcdCluster`, `EtcdMember`, `EtcdSnapshot`).
1212
- `packages/system/backupstrategy-controller` ships the
1313
`strategy.backups.cozystack.io/v1alpha1` API and the controllers that
1414
dispatch `BackupJob` / `RestoreJob` to the per-app driver. The

‎examples/backups/etcd/91-scenario-user-backup.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ coordinates baked into `parameters`.
1818
## 2. Deploy the source Etcd (`03-create-etcd-src.sh`)
1919

2020
The tenant applies an `apps.cozystack.io/Etcd` named `etcd`. The
21-
HelmRelease materialises an `etcd.aenix.io/EtcdCluster` and three
21+
HelmRelease materialises an `etcd-operator.cozystack.io/EtcdCluster` and three
2222
members. The script writes a sentinel key under `etcdctl` so step 05
2323
can witness the round-trip.
2424

@@ -27,7 +27,7 @@ can witness the round-trip.
2727
A `BackupJob` references the `BackupClass` and the source `Etcd`. The
2828
driver resolves the strategy, renders its template against the live
2929
application and class parameters, then materialises one
30-
`etcd.aenix.io/EtcdBackup` CR per `BackupJob`. The etcd-operator's
30+
`etcd-operator.cozystack.io/EtcdSnapshot` CR per `BackupJob`. The etcd-operator's
3131
controller runs a one-shot Job that snapshots etcd and uploads the
3232
file to S3. On `phase=Complete`, the driver creates a Cozystack
3333
`Backup` artefact with the S3 coordinates baked into
@@ -36,7 +36,7 @@ file to S3. On `phase=Complete`, the driver creates a Cozystack
3636

3737
## What the tenant does NOT do
3838

39-
- Author `EtcdBackup` CRs by hand. The driver owns the lifecycle.
39+
- Author `EtcdSnapshot` CRs by hand. The driver owns the lifecycle.
4040
- Manage the underlying S3 credentials. The driver consumes them from
4141
the per-app Secret the bucket flow already produced.
4242
- Track snapshot retention via cron. A `Plan` resource (not part of

‎examples/backups/etcd/92-scenario-user-restore.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace) and `targetApplicationRef` is a same-namespace reference.
2121
`helm.toolkit.fluxcd.io/v2 HelmRelease "etcd"` stops Flux from
2222
re-rendering the chart while the driver mutates the live cluster.
2323
2. **Snapshot the chart-rendered EtcdCluster spec.** The driver reads
24-
the live `etcd.aenix.io/EtcdCluster "etcd"` spec and stashes it on
24+
the live `etcd-operator.cozystack.io/EtcdCluster "etcd"` spec and stashes it on
2525
`RestoreJob.status.conditions[EtcdClusterSpecCaptured].message`.
2626
This makes the destructive flow controller-crash-safe: a restart
2727
between "snapshot taken" and "cluster recreated" still has the spec
@@ -36,7 +36,7 @@ namespace) and `targetApplicationRef` is a same-namespace reference.
3636
destination from the `Backup` artefact, then `Create`s the new CR.
3737
The etcd-operator picks it up and bootstraps from the S3 snapshot.
3838
6. **Wait for `Ready=True`.** The driver polls the new
39-
`EtcdCluster.status.conditions[Ready]`.
39+
`EtcdCluster.status.conditions[Available]`.
4040
7. **Resume the HelmRelease.** With the cluster Ready, Flux can
4141
reconcile chart drift safely. Helm's next apply will remove the
4242
`bootstrap` block on the live CR; the operator only consults

‎examples/backups/etcd/README.md‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
This directory shows how to back up and restore a Cozystack-managed `Etcd`
1414
application using the cluster's `Etcd` backup strategy driver. The driver
1515
delegates to the [etcd-operator][etcd-operator]: each Cozystack `BackupJob`
16-
materialises an `etcd.aenix.io/v1alpha1 EtcdBackup` CR (a one-shot Job that
16+
materialises an `etcd-operator.cozystack.io/v1alpha2 EtcdSnapshot` CR (a one-shot Job that
1717
streams `etcdctl snapshot save` output to S3), and each `RestoreJob`
1818
performs an in-place restore by suspending the Etcd HelmRelease,
1919
deleting the chart-rendered `EtcdCluster`, and recreating it with
@@ -68,7 +68,7 @@ chart change alone is not sufficient.
6868
| `00-helpers.sh` | Shared bash helpers and env defaults; sourced by every `01..05` step and by `cleanup.sh`. | n/a |
6969
| `01-create-strategy.sh` | Creates the cluster-scoped `Etcd` strategy. | admin |
7070
| `02-create-bucket.sh` | Provisions a `Bucket`, mints an `<app>-etcd-backup-creds` Secret in the source namespace, and creates the `BackupClass` bound to the Etcd strategy with resolved S3 coordinates. Caches raw creds in `.bucket-info.env` (chmod 600); `cleanup.sh` removes it. | tenant |
71-
| `03-create-etcd-src.sh` | Provisions the source `Etcd` application, waits for `EtcdCluster.status.conditions[Ready]=True`, and writes a sentinel key under `etcdctl`. | tenant |
71+
| `03-create-etcd-src.sh` | Provisions the source `Etcd` application, waits for `EtcdCluster.status.conditions[Available]=True`, and writes a sentinel key under `etcdctl`. | tenant |
7272
| `04-create-backupjob.sh` | Submits a `BackupJob` and waits for `phase=Succeeded`. | tenant |
7373
| `05-restore-in-place.sh` | Mutates the sentinel, submits a `RestoreJob` (no `targetApplicationRef`), and verifies the sentinel is round-tripped back to its pre-mutation value. | tenant |
7474
| `cleanup.sh` | Best-effort teardown. | admin or tenant |
@@ -94,13 +94,12 @@ All variables come from `00-helpers.sh`:
9494
running, with the Etcd dispatch wired (see
9595
`internal/backupcontroller/etcdstrategy_controller.go`).
9696
- `kubectl`, `jq`.
97-
- The `etcd.aenix.io` CRDs installed by `packages/system/etcd-operator`
98-
v0.4.5+. The Cozystack flow specifically depends on `EtcdCluster`
99-
(the driver re-creates it with `spec.bootstrap.restore.source.s3`
100-
during in-place restore) and `EtcdBackup` (one materialised per
101-
`BackupJob`). `EtcdBackupSchedule` is only consumed by the legacy
102-
`backup.enabled=true` chart path. There is no separate `EtcdRestore`
103-
CRD — restore goes through `EtcdCluster.spec.bootstrap`.
97+
- The `etcd-operator.cozystack.io` CRDs installed by
98+
`packages/system/etcd-operator-crds`. The Cozystack flow specifically depends
99+
on `EtcdCluster` (the driver re-creates it with
100+
`spec.bootstrap.restore.source.s3` during in-place restore) and `EtcdSnapshot`
101+
(one materialised per `BackupJob`). There is no separate `EtcdRestore` CRD —
102+
restore goes through `EtcdCluster.spec.bootstrap`.
104103
- The Cozystack `etcd-rd` ApplicationDefinition installed so
105104
`apps.cozystack.io/Etcd` renders a HelmRelease.
106105

@@ -125,4 +124,4 @@ All variables come from `00-helpers.sh`:
125124
operator drops the member PVCs alongside it). All client traffic to
126125
etcd is unavailable for the duration of the restore. Plan a window.
127126

128-
[etcd-operator]: https://github.com/aenix-io/etcd-operator
127+
[etcd-operator]: https://github.com/cozystack/etcd-operator

0 commit comments

Comments
 (0)