Skip to content

[proposal] Per-cluster etcd: give each Kubernetes control plane its own datastore - #25

Open
myasnikovdaniil wants to merge 2 commits into
mainfrom
proposal/etcd-per-cluster
Open

myasnikovdaniil wants to merge 2 commits into
mainfrom
proposal/etcd-per-cluster

Conversation

@myasnikovdaniil

@myasnikovdaniil myasnikovdaniil commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Design proposal for packages/apps/kubernetes to render its own EtcdCluster and its own Kamaji DataStore, one per cluster.

Since the control plane / node pool split (#8) apps/kubernetes is the control plane app. It renders kamaji, the certs, konnectivity, csi, kccm, the oidc wiring. The one component it does not render is the one that holds all of the control plane's state, etcd comes from outside instead, from an admin setting spec.etcd: true on an ancestor Tenant. This proposal closes that gap, so a cluster's datastore is as much part of the cluster as its api server.

Two things follow from it. A consumer who can create a Kubernetes app gets a working cluster with no admin pre step, no awaiting-etcd. And each cluster's control plane state is physically isolated, own raft group, own disk, own quota, own CA, instead of N control planes multiplexed onto one etcd by key prefix.

Relation to #39

Companion, not competitor. #39 answers where packages live and how a module declares itself. This one answers what the Kubernetes control plane app is made of, it adds one component to one chart. Disjoint files and neither blocks the other. etcd is the single tenant module whose sharing is the defect, which is why #39 leaves it out and this one picks it up.

Contents

design-proposals/etcd-per-cluster/README.md, filling the template.

Second draft. Every open question from the first round is answered rather than deferred, the values surface is cut to etcd.replicas per cozystack#3179, and the whole document is retargeted at etcd-operator.cozystack.io/v1alpha2 after cozystack#2859 and cozystack#3270 merged.

Status: Review

Fold etcd into the kubernetes app so each tenant Kubernetes cluster
provisions and owns its own etcd and Kamaji DataStore. End state is one
etcd per one Kubernetes cluster: consumers can start a cluster with no
admin pre-step, control-plane state is physically isolated per cluster,
and no etcd runs unless a cluster needs it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76d06e5d-ece6-4ea5-8ce7-1ebc44116d98
Walkthrough

A new design proposal document is added at design-proposals/etcd-per-cluster/README.md. It defines the architecture, migration path, security implications, testing plan, and phased rollout for shifting from shared-tenant etcd to per-Kubernetes-cluster dedicated etcd provisioning within the kubernetes app.

Changes

Per-cluster etcd design proposal

Layer / File(s) Summary
Metadata, goals, and background
design-proposals/etcd-per-cluster/README.md
Adds document metadata (title, authors, date, draft status), explains the current shared-tenant etcd wiring, states the per-cluster ownership model, and enumerates goals and non-goals.
Core design and architecture
design-proposals/etcd-per-cluster/README.md
Defines before/after architecture, how the kubernetes app provisions etcd, certs, and DataStore; introduces the new etcd values block; specifies datastore naming and helper alignment; removes the shared-etcd gate with a legacy compatibility window; and outlines etcd tenant module retirement.
Operations, security, testing, and rollout
design-proposals/etcd-per-cluster/README.md
Documents user-facing changes, upgrade/rollback compatibility, security implications (removal of cross-cluster trust boundary), failure edge cases, testing plan (unit/chart/e2e/migration), phased rollout steps, open questions, and alternatives considered.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5

✅ Passed checks (5 passed)

Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the proposal's main change: giving each Kubernetes control plane its own etcd-backed datastore.
Finishing Touches

🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Commit unit tests in branch proposal/etcd-per-cluster
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a design proposal to retire the shared tenant etcd module and bind a dedicated etcd cluster directly to each Kubernetes app, improving self-service, performance isolation, and security. The review feedback highlights two important considerations: first, the risk of DNS label length violations (exceeding 63 characters) if the release name is too long, and second, a potential race condition during deletion where the etcd datastore might be reaped before the KamajiControlPlane finishes finalization.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +128 to +130
endpoints:
- {{ .Release.Name }}-etcd.{{ .Release.Namespace }}.svc:2379
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If .Release.Name is long, the service endpoint {{ .Release.Name }}-etcd might exceed the 63-character limit for Kubernetes Service names and DNS labels. To prevent deployment failures or DNS resolution issues, consider using a helper function (such as a truncated/hashed name helper) to format the etcd service name and endpoint, ensuring it strictly adheres to the 63-character limit.


- **Two `Kubernetes` apps in one namespace** → each renders its own `<release>-etcd` and `<namespace>-<release>` DataStore; no name collision (the previous single shared `DataStore: <namespace>` could not represent two clusters distinctly).
- **DataStore name exceeds the cluster-scoped name length limit** → fall back to `<namespace>-<release>-<hash>`; the helper enforces the limit deterministically.
- **Cluster deletion** → the delete hook (`packages/apps/kubernetes/templates/delete.yaml`) must additionally delete the `EtcdCluster`, the cluster-scoped `DataStore`, and the per-cluster cert Secrets, *after* the existing `<release>-datastore-config` finalizer cleanup (delete.yaml already handles Kamaji's datastore-secret finalizer, issue #3062). Ordering: drain the control plane → strip the datastore-config finalizer → remove EtcdCluster + DataStore.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the EtcdCluster or DataStore is deleted at the same time as the KamajiControlPlane (which is the default behavior when they are part of the same Helm release), a race condition can occur. If the etcd pods terminate before the KamajiControlPlane finishes its finalization, the Kamaji controller may fail to reconcile the control plane due to datastore connection timeouts, potentially blocking the deletion process or causing error storms in the operator logs. Consider implementing a mechanism (such as a finalizer on the DataStore or EtcdCluster that waits for the KamajiControlPlane to be gone, or explicit ordering in the deletion hook) to ensure the datastore is only reaped after the control plane has been completely deleted.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
design-proposals/etcd-per-cluster/README.md (2)

5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Future date in a draft proposal.

The date 2026-06-30 is at the end of the current month. If this is intentional as a target date, no action needed; if it's a placeholder, consider using the draft creation date or removing it until finalized.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@design-proposals/etcd-per-cluster/README.md` at line 5, The README draft
currently uses a future placeholder date, so update the date field in the
proposal header to a non-future value if this is meant to be a draft, or remove
it until finalized. Locate the date entry in the proposal metadata section and
replace the hardcoded `Date` value with the draft creation date or omit it
entirely if the target date is not confirmed.

35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider rephrasing "exactly" per style guidance.

Static analysis flagged this as overused. Alternatives: "precisely", "in effect", or restructure the sentence.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@design-proposals/etcd-per-cluster/README.md` at line 35, The sentence in the
proposal body uses the overused word “exactly”; rephrase that line in the README
text to avoid the flagged wording while keeping the same meaning. Update the
prose near the per-cluster etcd description, using the existing surrounding
sentence structure and terms like “per-cluster etcd” and “tenant-sprawl
ceremony” to locate it, but replace “exactly” with a cleaner alternative such as
“precisely” or “in effect.”

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@design-proposals/etcd-per-cluster/README.md`:
- Line 190: The Phase 4 removal instructions use the wrong key name for the
legacy etcd namespace propagation, which can mislead implementers. Update the
wording in the README section describing removal of the shared-etcd plumbing to
refer to the exact propagated Secret key and helper name, using _namespace.etcd
and cozy-lib.ns-etcd consistently with the existing references in the document.
- Line 173: Clarify the delete hook behavior in the cluster deletion section:
the current delete flow in the delete hook should only remove the per-cluster
EtcdCluster, DataStore, and cert Secrets for new per-cluster etcd clusters, and
must skip those resources for legacy shared-etcd clusters. Update the guidance
around packages/apps/kubernetes/templates/delete.yaml to explain how the hook
determines the mode (for example, by checking for the per-cluster DataStore or a
dedicated annotation) so the legacy shared EtcdCluster/DataStore owned by the
tenant module is not deleted.

---

Nitpick comments:
In `@design-proposals/etcd-per-cluster/README.md`:
- Line 5: The README draft currently uses a future placeholder date, so update
the date field in the proposal header to a non-future value if this is meant to
be a draft, or remove it until finalized. Locate the date entry in the proposal
metadata section and replace the hardcoded `Date` value with the draft creation
date or omit it entirely if the target date is not confirmed.
- Line 35: The sentence in the proposal body uses the overused word “exactly”;
rephrase that line in the README text to avoid the flagged wording while keeping
the same meaning. Update the prose near the per-cluster etcd description, using
the existing surrounding sentence structure and terms like “per-cluster etcd”
and “tenant-sprawl ceremony” to locate it, but replace “exactly” with a cleaner
alternative such as “precisely” or “in effect.”
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d31dff8a-6a76-4ef4-9d32-ca60354f0c77

📥 Commits

Reviewing files that changed from the base of the PR and between 62ecd0b and 35ad494.

📒 Files selected for processing (1)
  • design-proposals/etcd-per-cluster/README.md


- **Two `Kubernetes` apps in one namespace** → each renders its own `<release>-etcd` and `<namespace>-<release>` DataStore; no name collision (the previous single shared `DataStore: <namespace>` could not represent two clusters distinctly).
- **DataStore name exceeds the cluster-scoped name length limit** → fall back to `<namespace>-<release>-<hash>`; the helper enforces the limit deterministically.
- **Cluster deletion** → the delete hook (`packages/apps/kubernetes/templates/delete.yaml`) must additionally delete the `EtcdCluster`, the cluster-scoped `DataStore`, and the per-cluster cert Secrets, *after* the existing `<release>-datastore-config` finalizer cleanup (delete.yaml already handles Kamaji's datastore-secret finalizer, issue #3062). Ordering: drain the control plane → strip the datastore-config finalizer → remove EtcdCluster + DataStore.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Explicitly address delete hook behavior for legacy vs. new clusters.

The delete hook must distinguish between:

  • Per-cluster etcd clusters: delete the EtcdCluster, DataStore, and cert Secrets.
  • Legacy shared-etcd clusters: do not delete the shared EtcdCluster or DataStore (owned by the tenant module/ancestor).

Without this distinction, deleting a legacy cluster could destroy the shared etcd and break all other clusters in the subtree. Add a sentence clarifying how the hook detects which mode applies (e.g., by the presence of the per-cluster DataStore or an annotation).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@design-proposals/etcd-per-cluster/README.md` at line 173, Clarify the delete
hook behavior in the cluster deletion section: the current delete flow in the
delete hook should only remove the per-cluster EtcdCluster, DataStore, and cert
Secrets for new per-cluster etcd clusters, and must skip those resources for
legacy shared-etcd clusters. Update the guidance around
packages/apps/kubernetes/templates/delete.yaml to explain how the hook
determines the mode (for example, by checking for the per-cluster DataStore or a
dedicated annotation) so the legacy shared EtcdCluster/DataStore owned by the
tenant module is not deleted.

1. **Phase 1 — self-provisioned etcd, opt-in.** Add the `etcd` values block and per-cluster etcd/DataStore rendering to the `kubernetes` app behind a default that self-provisions for new clusters while still honoring a legacy `_namespace.etcd` reference for existing ones. Extend `delete.yaml` to reap the per-cluster etcd/DataStore. Ship docs for the new sizing knobs.
2. **Phase 2 — migration path.** Land and prove the shared→dedicated data migration (Kamaji datastore migration or snapshot/restore), as a numbered-migration hook where idempotent or a gated runbook otherwise. Provide a dashboard/CLI signal of which clusters are still on the shared etcd.
3. **Phase 3 — deprecate the tenant module.** Mark `Tenant.spec.etcd` and the etcd tenant-module catalog entry deprecated; new tenants no longer offer it. Stop hardcoding `etcd: tenant-root`.
4. **Phase 4 — remove plumbing.** Once telemetry shows no cluster on the shared etcd, delete `apps/tenant/templates/etcd.yaml`, the `etcd` tenant value, the `_namespace.etcd` propagation and `cozy-lib.ns-etcd` helper, and the `namespace.cozystack.io/etcd` label. Keep the etcd-operator and the etcd chart.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Clarify the legacy reference key name.

Line 190 says "Stop hardcoding etcd: tenant-root" but the actual value propagated is _namespace.etcd: tenant-root (line 26). Dropping the _namespace. prefix could confuse implementers about which Secret key and helper to remove. Align with the exact key name used elsewhere.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@design-proposals/etcd-per-cluster/README.md` at line 190, The Phase 4 removal
instructions use the wrong key name for the legacy etcd namespace propagation,
which can mislead implementers. Update the wording in the README section
describing removal of the shared-etcd plumbing to refer to the exact propagated
Secret key and helper name, using _namespace.etcd and cozy-lib.ns-etcd
consistently with the existing references in the document.

@SerjioTT

SerjioTT commented Jul 1, 2026

Copy link
Copy Markdown

+1 on the core direction — folding etcd into the kubernetes app fixes
both the self-service and the isolation stories, and both are real user-facing
problems for platforms built on top of CozyStack.

Writing as an operator of a CozyStack-based managed platform, where we run per-tenant Kubernetes clusters at scale.

On the "per-cluster etcd multiplies overhead" concern

In practice, per-cluster etcd is a modest addition on top of what a Kubernetes
app already costs. Observed values on a real tenant cluster in our fleet:

Component (per Kubernetes app) Requests CPU Limits CPU Requests Mem Limits Mem
TCP pod (apiserver + cm + scheduler + konnectivity) 350m 3500m 2816Mi 2816Mi
kccm 125m 512m 128Mi 512Mi
cluster-autoscaler 125m 512m 128Mi 512Mi
kcsi-controller (6+ containers) 760m 3322m 788Mi 3200Mi
Sub-total (CP + satellites, no etcd) 1360m 7846m ~3.85Gi ~7.0Gi
etcd × 3 replicas 300m 3000m 1536Mi 1536Mi
Total per cluster (excl. worker VMs) 1660m 10846m ~5.4Gi ~8.5Gi

Per-cluster etcd adds ~18% to requests CPU and ~28% to CPU/memory limits on
top of what a Kubernetes app already carries. By the way, manageble number of replicas of etcd could reduce that costs.

Small aside: kcsi-controller alone (760m/3322m CPU, 3200Mi memory limits,
6+ sidecars) is heavier than three etcd replicas combined. If reducing
per-cluster overhead is a broader goal, that's a bigger lever than etcd
sizing — possibly worth a follow-up.

On the proposed etcd values block

I'd push back on exposing the full {replicas, size, storageClass, resources}
block, and here's why — this chart already has a strong precedent for
hardcoded infrastructure sizing.

Look at the three satellite Deployments the kubernetes app renders today:

These are exactly the "cluster infrastructure under the hood" components that
etcd would join in the per-cluster model. None of them expose resources
through values, and there are no field reports of anyone needing to tune
them. The chart already distinguishes cleanly between:

  • Control plane (TCP: apiserver / cm / scheduler / konnectivity) —
    visible knob, tunable via controlPlane.*.resourcesPreset
  • Infrastructure satellites (kccm, cluster-autoscaler, kcsi-controller) —
    invisible, hardcoded

Per-cluster etcd belongs firmly in the second bucket — it's a control-plane
implementation detail, not a control-plane user surface. Adding a full
values block for it would break the existing convention and introduce UX
complexity for a knob users don't need to turn.

Counter-proposal for the values block

# packages/apps/kubernetes/values.yaml
## @param {Etcd} etcd - Control-plane etcd datastore for this cluster.
etcd:
  ## @field {int} replicas=3 - etcd replicas. 3 = HA (Raft quorum, local storage).
  ## 1 = single-replica, non-HA; chart auto-selects a replicated StorageClass so
  ## the single member survives node loss via storage-layer replication.
  replicas: 3

Everything else (size, storageClass, resources) becomes chart-internal:

  • resources — hardcoded to the current extra/etcd default (cpu: 1000m, memory: 512Mi); VPA handles growth.
  • size — hardcoded to 4Gi (matches current behaviour, huge headroom for a Kamaji datastore).
  • storageClass — derived from replicas:
    • replicas: 3 → local-style StorageClass (etcd handles replication via Raft;
    • replicas: 1 → replicated/DRBD-style StorageClass (single etcd member gets storage-layer HA as safety net)
      The StorageClass mapping should be configurable at the platform level, not the app level — probably via cozystack-values (something like default-etcd-sc-replicated: replicated, default-etcd-sc-local: local) if technically possible. The Kubernetes app just picks between them based on etcd.replicas (or switch SC in addition).

If a real production case comes up later where a user needs to override resources, size, or a specific storageClass, it possible to wide the API then — it's a strict superset of what I'm proposing, so no breaking change is needed to grow into the fuller block later.

Small addendum on Open questions

  • Q3 (default replicas): keep 3. 1 as default silently ships non-HA clusters; users who want dev/throwaway can flip it explicitly. Matches the "safe by default" story.
  • Q5 (quota surfacing): yes, worth showing in NOTES.txt — but that's basically a documentation change once the block is minimal (just note "your cluster will also provision an etcd StatefulSet with ~1000m/512Mi × 3 replicas").
  • Q1 (Kamaji datastore migration mechanics): biggest unknown for us too. Happy to help test snapshot/restore based migration on our environment.

@scooby87

scooby87 commented Jul 2, 2026

Copy link
Copy Markdown

Filed a scoped tracking issue for SerjioTT's minimal-API point (expose only etcd.replicas, keep size/storageClass/resources chart-internal): cozystack/cozystack#3179.

It captures the reasoning from the review comment above — matching the existing satellite convention (hardcoded infra resources + VPA), keeping the Kubernetes CR simple, and staying forward-compatible (the minimal block is a strict subset, so the API can be widened later without a breaking change).

Note it's explicitly gated on this proposal: there's nothing to expose/hide until per-cluster etcd is folded into the kubernetes app. The New etcd values block section here (§2) should be updated to reflect the minimal surface once the direction is confirmed.

@IvanHunters IvanHunters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes — the topology change is well-motivated and the isolation win is real, but a few things should be reconciled before implementation.

  1. The proposal is written against etcd.aenix.io/v1alpha1, while in-flight #2859 migrates the platform to etcd-operator.cozystack.io/v1alpha2, renames the CRDs, and switches readiness from Ready to Available. The EtcdCluster apiVersion, the "wait for Ready" semantics, and the reused extra/etcd chart shape will all be stale once #2859 lands. Please declare an explicit dependency / rebase-onto-#2859 and target v1alpha2 + Available.
  2. Migration-number collision: the proposal targets migration 49, but 49 is already taken on main (ancestor-label backfill) and #2859 also adds its own migration 49. Any numbered migration here must claim 50+.
  3. Post-migration rollback is effectively one-way and paired with a stateful freeze-mode migration. Kamaji's live datastore migration puts the TenantControlPlane in read-only/freezing mode and requires restarting kubelet on every tenant worker node afterward — that worker-node kubelet restart is a real availability impact and isn't in the proposal; it belongs in the migration runbook and Testing.
  4. The live datastore switch is triggered by patching .spec.dataStore on the native TenantControlPlane, but cozystack uses the CAPI KamajiControlPlane, for which upstream docs don't cover a live switch. Open Question 1 is a genuine blocker, and #2859 choosing snapshot/restore is a strong signal the live CAPI path isn't available — please reconcile.

Minor: several code citations have drifted line numbers (the constructs still exist), and §2's full etcd values block should shrink to the minimal etcd.replicas surface per the direction agreed in #3179.

@IvanHunters
IvanHunters dismissed their stale review July 4, 2026 20:43

Dismissing the review verdict: converting this to non-blocking feedback since this is a design proposal, not code. The technical points in the review comment still stand as suggestions to reconcile before implementation.

…se all open questions

Second draft of the per-cluster etcd proposal. The framing changes and
every open question from the first review round is answered.

Reframing: the proposal is about completing packages/apps/kubernetes,
which since the control-plane / node-pool split (community#8) is the
control-plane app. Every control-plane component is rendered by that
chart except the one holding all of its state. Retiring the etcd
tenant-module wiring is a consequence of fixing that, not the goal.
This makes the relationship to community#39 explicit: #39 owns where
packages live and how modules declare themselves, this owns what the
control-plane app contains. Disjoint files, neither blocks the other.

Resolved questions, replacing the five open ones:

- Migration: the CAPI provider does re-project dataStoreName onto
  TenantControlPlane.spec.dataStore on every reconcile, so a live
  switch works, but it costs a read-only freeze window and a kubelet
  restart on every tenant worker node. Migration is therefore an
  operator-initiated maintenance runbook, never an unattended
  platform migration.
- Standalone etcd: survives. Only the Tenant.spec.etcd bool and the
  _namespace.etcd propagation retire; the chart and its
  ApplicationDefinition stay.
- Default replicas: 3.
- Reuse mechanism: shared named templates in cozy-lib, not a
  subchart. The etcd chart hard-fails unless the release is named
  etcd, a subchart inherits the parent release name, and the literal
  etcd-*-tls names are pinned by an immutable spec.tls on adopted
  clusters.
- Footprint: surfaced in NOTES.txt and the app README.

Also folded in: the minimal values surface from cozystack#3179 (only
etcd.replicas, with the StorageClass derived from it at platform
level), etcd-operator v1alpha2 and the Available condition throughout,
a name-length section with the real 53-character release cap and the
operator's derived names, a delete hook that reaps a per-cluster etcd
but never a shared one, corrected source citations, and a migration
slot of 56+ rather than the stale 49.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
@myasnikovdaniil myasnikovdaniil changed the title [proposal] Per-cluster etcd: retire the tenant etcd module and bind etcd to the Kubernetes app [proposal] Per-cluster etcd: give each Kubernetes control plane its own datastore Aug 21, 2026
@myasnikovdaniil

Copy link
Copy Markdown
Contributor Author

IvanHunters second draft pushed. Framing changed too, it is now about completing apps/kubernetes as the control plane app, so this is companion to #39 rather than competing with it. #39 owns where packages live, this one owns what the control plane contains.

  1. v1alpha2 landed while this sat (#2859, #3270), so the whole doc is retargeted to etcd-operator.cozystack.io/v1alpha2 and Available. Stale, not blocking.
  2. Slot is 56+ now, main ships through 55 with targetVersion: 56. Doc says re-check it against main and every release branch at implementation time instead of trusting the number written down.
  3. Confirmed and it is in the runbook now. Kamaji freezes the tcp read only while it copies, then kubelet.service has to be restarted on every tenant worker. That is why migration is operator run maintenance per cluster and not a numbered migration, platform has no business rolling a tenant's kubelets unannounced.
  4. Live switch does work actually. The capi provider does tcp.Spec.DataStore = kcp.Spec.DataStoreName inside a CreateOrUpdate mutate func, so it reprojects on every reconcile, and the field carries no immutability marker. #2859 picking snapshot/restore was about adopting operator api versions, different problem.

Citations fixed, values block cut down to etcd.replicas.

@myasnikovdaniil

Copy link
Copy Markdown
Contributor Author

SerjioTT took your minimal surface as is. Only etcd.replicas on the CR, size and resources hardcoded to the current etcd chart defaults, storageClass derived from replicas with the two class names resolved at platform level from _cluster values like you suggested. Default stays 3. Your satellite numbers are the argument in the doc now, kcsi-controller being heavier than three etcd replicas combined is the part that makes the case.

replicas is validated to 1 or 3. 2 tolerates zero failures at double the cost so it should not be reachable at all.

On Q1, taking you up on that. Mechanism is settled now (kamaji live switch works, costs a read only freeze plus the kubelet restart on every tenant worker), what nobody has measured is how it behaves on talos workers at fleet scale. Migration e2e gates phase 2, so that is exactly the run that would help.

@myasnikovdaniil

Copy link
Copy Markdown
Contributor Author

scooby87 #3179 adopted. The values block now exposes only etcd.replicas, size and resources are chart internal and the storageClass mapping sits at platform level, so it can close with this.

Framing changed as well, it is a companion to #39 now rather than a competing packaging change. #39 owns where packages live, this one owns what the control plane app contains.

@SerjioTT

SerjioTT commented Sep 3, 2026

Copy link
Copy Markdown

myasnikovdaniil

Following up on Q1 — ran the live datastore switch on a real cluster with Talos workers. Short version: the Kamaji migration mechanism itself works and is fast (~20 s data copy, ~43 s patch-to-Ready), but in a CozyStack tenant topology the dominant cost is everything around it, and the run surfaced three findings that I think belong in the Migration/Testing sections of this proposal.

Environment

Component Version
CozyStack v1.6.1 (cozystack-operator:v1.6.1)
Kamaji CozyStack build kamaji:v1.6.1-rc.1
Management Kubernetes v1.34.3, Talos v1.13.6 (bare-metal)
Tenant cluster Kubernetes app, CP replicas 2, guest v1.35.6
Workers 3 × Talos v1.13.6 VMs (KubeVirt, u1.large)
Source datastore tenant-namespace etcd (3 replicas, extra/etcd chart)

Reads and node heartbeats were never interrupted at any point: 0 read failures over the whole multi-hour session, and 0 write failures after the freeze webhook was removed (including all three worker reboots). Data integrity: every ConfigMap written before each freeze window survived the migrations, the canary's write log shows clean OK→FAIL→OK boundaries with no writes leaking through either freeze window, and the writer kept appending on the new datastore overnight without a single failure.

Finding 1 — migration direction is constrained by tenant network topology

The migrate job runs from the Kamaji namespace and can reach any tenant's etcd, so the data copy succeeds regardless of the target. But the tenant CP pods live in the cluster's namespace, and OVN isolation only permits reaching an ancestor's etcd, not a sibling's. Result of attempt 1: migration "completes", the new CP generation rolls out pointing at etcd.<sibling>.svc:2379, apiserver dies on dial tcp: i/o timeout → CrashLoopBackOff, the old CP generation keeps serving reads, and the cluster is write-frozen indefinitely. Nothing in the flow validates target reachability from the CP pods' network context before committing.

For this proposal that's mostly good news — per-cluster etcd lives in the same namespace as the CP, which is trivially reachable, and the ancestor path needed for rollback is open as well — but the migration runbook (shared root etcd → per-cluster etcd, and any rollback) must state the reachability rule explicitly, and ideally the flow should pre-flight it. A nc -zv <target-etcd> 2379 from a pod in the cluster namespace is a sufficient check. Findings 2 and 3 below are topology-independent and apply unchanged to the same-namespace (per-cluster) migration direction.

Finding 2 — the freeze webhook can outlive a successful migration, leaving a Ready-but-write-locked cluster

Mechanics first, since they weren't obvious to me from the docs: Kamaji freezes the cluster by installing a ValidatingWebhookConfiguration (kamaji-freeze) inside the guest, with clientConfig.url pointing at kamaji-webhook-service.<kamaji-ns>.svc, failurePolicy: Fail, timeoutSeconds: 10. In a tenant topology the guest apiserver cannot reach that URL at all, so the freeze works "by brute force": every mutating call burns the 10 s timeout and fails. Two design details worth knowing:

  • lease UPDATEs in kube-node-lease are exempt (the catchall skips that namespace; a second webhook there only catches CREATE/DELETE), so kubelet heartbeats keep flowing and all nodes stay Ready during the freeze — kubectl get nodes is blind to a write-locked cluster;
  • reads are untouched, so casual inspection shows a perfectly healthy cluster.

In attempt 2 the migration finished, the TCP went Ready on the new datastore, the CP pods rolled out cleanly — and the webhook was never removed. Kamaji logged no attempt to remove it in the following ~15 minutes (likely related to a leftover migrate Job from attempt 1: the reconcile hit migration job must be cretaed back due to immutable fields, recreated the Job, and apparently lost the unfreeze step on that path). Deleting the webhook by hand unblocked writes on the next tick.

Runbook implication: after any datastore switch, verify validatingwebhookconfiguration kamaji-freeze is gone from the guest and delete it if not — a Ready TCP is not sufficient evidence the cluster is functional. This is also a strong argument for the proposal's e2e migration test asserting write availability, not object status.

Finding 3 — kubelets go deaf to new pod assignments until restarted; the restart itself is cheap

On the new datastore with untouched kubelets: existing pods keep running, nodes stay Ready, and the scheduler works — a new pod got bound to a node (nodeName assigned). But the node's kubelet never picked it up: the pod sat Pending with a node assigned for 16 minutes on a Ready node. So the failure mode of skipping the kubelet restart is not visible degradation — it's a cluster that looks healthy and silently stops starting new workloads.

Restarting the worker (VM reboot in our case) fixed it instantly: the pending pod started within seconds of the node coming back.

The reboots themselves were cheaper than expected: Talos does a graceful cordon (Ready,SchedulingDisabled), two of three nodes never showed NotReady at all (the third blinked NotReady for a few seconds), and the node's pods restarted in place (RESTARTS +1, no rescheduling, no eviction) — the outage window stays under the eviction timeouts. Zero canary write failures during all three reboots. So "restart kubelet on every worker" at fleet scale is a rolling, low-impact operation.

One operational gap worth closing as part of this work — there is currently no operator path to the tenant workers' Talos API at all. The chart provisions a per-cluster talos-ca (cert-manager Issuer) but never issues client credentials from it — the Talos secrets hold only join tokens and the CA. So talosctl -n <worker> service kubelet restart — or any machine-level operation — first requires hand-crafting a client cert from that Issuer. We fell back to virtctl restart per VM, which works but is a full reboot. On the pre-1.6 Ubuntu/kubeadm workers the equivalent was trivial (kubelet as a systemd unit, privileged pod + nsenter) — that's the operational parity the Talos path should reach, not a reason to go back. (Finding-3 caveat applies to any pod-based restarter, old or new: it must be deployed before the migration, since a deaf kubelet won't start newly scheduled pods, including the one meant to fix it; exec into pre-existing pods keeps working.) Both halves look cheap and belong in this proposal's Phase 2 scope: (a) the chart issuing an operator talosconfig from the existing per-cluster CA alongside the admin kubeconfig, and (b) the migration runbook spelling out the rolling kubelet restart for tenant Talos workers — a mandatory step of every datastore switch.

Suggested runbook/e2e additions

  1. Pre-flight: verify target datastore reachability from the cluster's namespace (not from Kamaji's).
  2. Post-migration: assert kamaji-freeze is removed from the guest; delete manually if present.
  3. Success criterion: canary write to the guest API, not TCP Ready.
  4. Kubelet restarts: rolling, one node at a time; expect ~0 s NotReady with graceful reboots; new-pod scheduling on a node is the per-node verification that it's done.
  5. Repeat migrations in one TCP lifetime hit the immutable migrate-Job quirk (migration job must be cretaed back due to immutable fields); Kamaji recovers by recreating the Job, but expect the error in logs.

mattia-eleuteri added a commit to mattia-eleuteri/community that referenced this pull request Oct 5, 2026
… storage

Etcd, ingress and seaweedfs modules are exempt as platform overhead, and
etcd stays exempt once per-cluster etcd (cozystack#25) moves it into the
Kubernetes app. Monitoring reserves its declared storage only, which is
the one module figure that still needs a gate when the flag is enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mattia-eleuteri added a commit to mattia-eleuteri/community that referenced this pull request Oct 7, 2026
… storage

Etcd, ingress and seaweedfs modules are exempt as platform overhead, and
etcd stays exempt once per-cluster etcd (cozystack#25) moves it into the
Kubernetes app. Monitoring reserves its declared storage only, which is
the one module figure that still needs a gate when the flag is enabled.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
mattia-eleuteri added a commit to mattia-eleuteri/community that referenced this pull request Oct 8, 2026
… storage

Etcd, ingress and seaweedfs modules are exempt as platform overhead, and
etcd stays exempt once per-cluster etcd (cozystack#25) moves it into the
Kubernetes app. Monitoring reserves its declared storage only, which is
the one module figure that still needs a gate when the flag is enabled.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

myasnikovdaniil the direction is right, and cozystack/cozystack#4817 already implements phases 1 and 2. Its description has a section of deviations from this document, and each one matches a gap I found here independently against cozystack main (785cbc391b7c). The proposal should carry those decisions back, otherwise the accepted design and the code disagree from day one.

  1. _namespace.etcd can't tell an existing cluster from a new one. packages/system/cozystack-basics/templates/cozystack-values-secret.yaml:17 hardcodes etcd: tenant-root, and packages/apps/tenant/templates/namespace.yaml:28-31 passes the parent's value down unchanged unless a tenant sets etcd: true. So every tenant namespace resolves it to at least tenant-root, whether or not an etcd runs there. Section 4 says the chart honours an explicitly set _namespace.etcd and also that new clusters under a shared etcd get their own, and both can't hold when the value is always present. The delete hook in section 5 reuses the same undefined condition. The live KamajiControlPlane's spec.dataStoreName works as the discriminator: it exists only for running clusters and records the datastore they really use. The same fact makes the Context bullet and the first problem story inaccurate, because in a default install a new cluster doesn't wait in awaiting-etcd, it points at a tenant-root DataStore that may not exist.

  2. A DataStore named <namespace>-<release> isn't unique, because both parts contain dashes (child namespaces are <parent>-<name>, packages/apps/tenant/templates/_helpers.tpl:11). Kubernetes foo in tenant-a gets tenant-a-kubernetes-foo, which is also the namespace of tenant foo under tenant kubernetes under tenant-a. DataStore is cluster-scoped, so the second install fails on ownership. A namespace can't contain ., so <namespace>.<release> fixes it.

  3. Per-cluster etcd has no platform backup. The Etcd strategy is keyed on the Etcd application kind and the fixed EtcdCluster name etcd (internal/backupcontroller/etcdstrategy_controller.go:36-44), and nothing routes Kubernetes to it. The document doesn't say this, yet it cites the backup integration as a reason to reject inlining. Please state it as an accepted gap or design backup and restore.

  4. The network-policy claim doesn't hold. policy.cozystack.io/allow-to-etcd is read only by <tenant>-ingress-etcd (packages/apps/tenant/templates/networkpolicy.yaml:129-144), which renders only when the tenant's etcd is set, and section 5 removes that. allow-internal-communication in the same file admits every pod in the namespace to every other pod, and Cilium allow rules only add. A per-cluster etcd in the tenant namespace is therefore reachable from every pod there, including other clusters' control planes. Keeping it tight needs a deny rule or something equivalent, and the document should say which.

  5. Phase 4 would switch off every addon. Besides the beacon consumers section 4 lists, 26 templates in packages/apps/kubernetes/templates read _namespace.etcd, and the addon HelmReleases, CSI, KCCM and the autoscaler gate on it. Removing the propagation before those gates stops cilium, coredns, CSI and the rest from rendering.

  6. SerjioTT's live-switch run from 3 September isn't reflected in the runbook yet: reachability of the target has to be checked from the cluster namespace, the freeze can outlive a Ready control plane so step 5 should verify a write rather than a read, and step 4 needs a way to reach Talos workers. Please fold these in or reject each with a reason.

Smaller points:

  • The Kubernetes name is capped at 32 now (packages/apps/kubernetes/values.yaml:2), so truncate-and-hash isn't needed. The operator also creates <cluster>-client, which sets the real ceiling, and the table omits the CA Secret the DataStore needs.
  • cozystack.kubernetes-application doesn't depend on cozystack.etcd-operator today (packages/core/platform/sources/kubernetes-application.yaml). Phase 2 needs that edge.
  • The document should stay state-free: the revision note on line 8, "a review round raised it" on line 160, and "main currently ships through 55" (main is at targetVersion: 60) describe history, not design.

Both commits land in main as written, since community merges with rebase. 35ad494 has Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> and a [proposal] subject, and 6e1ceef has Assisted-By: Claude <noreply@anthropic.com> and opens with "Second draft ... every open question from the first review round is answered". Please squash into one docs(etcd-per-cluster): commit with Assisted-by: LLM and a body that says why.

IvanHunters' review is dismissed, and his points (v1alpha2 and Available, the kubelet restart, the live-switch evidence) are in this revision.

- **etcd is a tenant module.** `packages/apps/tenant/values.yaml:8-9` exposes `etcd: false`. When a `Tenant` sets it true, `packages/apps/tenant/templates/etcd.yaml` renders a `HelmRelease` for the etcd chart in that tenant's namespace, labelled `internal.cozystack.io/tenantmodule: "true"`.
- **The etcd chart owns the datastore.** `packages/extra/etcd` renders an `EtcdCluster` (`etcd-operator.cozystack.io/v1alpha2`, `templates/etcd-cluster.yaml:11`), its cert-manager CA/issuers/certificates, and a Kamaji `DataStore` named after the **namespace** pointing at `etcd.<namespace>.svc:2379` (`templates/datastore.yaml:5-8`). `DataStore` is **cluster-scoped** (`packages/system/kamaji/charts/kamaji/crds/kamaji.clastix.io_datastores.yaml:16`).
- **Every name in that chart is the literal string `etcd`.** `EtcdCluster/etcd`; the Secrets `etcd-ca-tls`, `etcd-client-tls`, `etcd-server-tls`, `etcd-peer-tls`; the operator-owned Service `etcd`. The chart enforces this: `templates/check-release-name.yaml` calls `fail` unless `.Release.Name == .Chart.Name`. These names are load-bearing rather than cosmetic — `spec.tls` is immutable in v1alpha2 (CRD CEL `self.tls == oldSelf.tls`) and `etcd-migrate` adopts legacy clusters into exactly this `secretRef` shape, so renaming them would make every post-adoption reconcile fail. Design §1 works with this constraint instead of against it.
- **The reference propagates down the tenant tree.** `tenant-root` ships a hardcoded `_namespace.etcd: tenant-root` in its `cozystack-values` Secret (`packages/system/cozystack-basics/templates/cozystack-values-secret.yaml:17`). For nested tenants, `packages/apps/tenant/templates/namespace.yaml:28-30` inherits `_namespace.etcd` from the parent and overrides it with the current tenant only when *this* tenant sets `spec.etcd: true`; the resolved value is written to the namespace label `namespace.cozystack.io/etcd` (`namespace.yaml:86`) and into descendants' `_namespace.etcd` (`namespace.yaml:120`). Consumers read it through `cozy-lib.ns-etcd` (`packages/library/cozy-lib/templates/_cozyconfig.tpl:116-118`). So every tenant in a subtree resolves `_namespace.etcd` to the nearest ancestor that owns an etcd.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every tenant resolves _namespace.etcd to at least tenant-root (cozystack-values-secret.yaml:17, inherited by namespace.yaml:28), even when no etcd runs there. See point 1.

| Native Service (client + peer endpoint) | `<release>-etcd` | etcd-operator |
| Member pods | `<release>-etcd-<suffix>` | etcd-operator |
| TLS Secrets | `<release>-etcd-{server,operator-client,peer}-tls` | etcd-operator / cert-manager |
| `DataStore` (cluster-scoped) | `<namespace>-<release>` | this chart |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<namespace>-<release> collides because both parts contain dashes: Kubernetes foo in tenant-a and tenant foo under tenant-a-kubernetes both give tenant-a-kubernetes-foo. A . separator can't collide.


`$etcd` and the `awaiting-etcd` beacon leave the normal path. The chart no longer waits for an external reference, because it renders the datastore itself.

The beacon and the `_namespace.etcd` read are not deleted immediately. Through the compatibility window (Rollout Phase 1-2) the chart honours an explicitly-set `_namespace.etcd` and keeps using the shared `DataStore` when it finds one, so a cluster that exists today continues exactly as it is, indefinitely, until an operator migrates it. New clusters — including any created in a namespace whose ancestors do provide a shared etcd — provision their own. Three other consumers key off the beacon and are updated with it: `packages/apps/kubernetes/templates/ingress.yaml`, `hack/admin-kubeconfig-invariant.bats`, and the ComputePlane README's description of the wait state.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What counts as "explicitly set"? _namespace.etcd is non-empty in every tenant. The delete hook at line 215 depends on the same answer.


## Security

- **Removes a shared trust boundary.** Each cluster gets its own etcd CA, Service, certificates, and PVCs. Today every control plane in a subtree dials the same `etcd.<ns>.svc` — frequently cross-namespace, because the `DataStore` is cluster-scoped and its owner is an ancestor tenant. Afterwards, a control plane dials only its own in-namespace etcd, and the `policy.cozystack.io/allow-to-etcd` pod label (`cluster.yaml:464`) retargets to it so the NetworkPolicy stays tight rather than subtree-wide.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow-to-etcd is read only by <tenant>-ingress-etcd, which section 5 removes, and allow-internal-communication already admits the whole namespace.

2. Take a snapshot of the source etcd. This is the rollback path and is not optional.
3. Flip the cluster's `dataStoreName` to its own `DataStore`. Kamaji puts the `TenantControlPlane` into **read-only / freezing mode** while it copies, rejecting writes through an admission controller with an explicit "in freezing mode due to a maintenance mode" message. The default budget is five minutes, adjustable via the `kamaji.clastix.io/migration-timeout` annotation.
4. **Restart `kubelet.service` on every worker node of that tenant cluster.** Kamaji's own guide requires this to complete the procedure. It is the single largest cost in the runbook and the reason this is a maintenance operation rather than a platform migration: rolling a tenant's kubelets is a tenant-visible availability event that the platform must not perform unannounced. Plan it as a rolling restart within a maintenance window.
5. Verify a canary object written before the switch is readable after it, then retain the source prefix and the snapshot for a defined cool-off period before reclaiming.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per SerjioTT's run: verify a write, not a read, since the freeze can stay behind after the control plane is Ready.

1. **Phase 1 — extract, no behaviour change.** Move the `EtcdCluster`, certificate, and `DataStore` shapes into `cozy-lib` named templates; `packages/extra/etcd` calls them and renders byte-identical output, proven by its existing test suite. Nothing user-visible ships.
2. **Phase 2 — per-cluster etcd for new clusters.** `apps/kubernetes` renders its own etcd, certificates, and `DataStore`, adds `etcd.replicas` and the platform-level StorageClass keys, extends the delete hook with both branches, and keeps honouring an explicit `_namespace.etcd` for clusters that already have one. Ship the sizing and quota notes. Land and prove the migration runbook, including the kubelet-restart step, before documenting it as supported.
3. **Phase 3 — deprecate.** Mark `Tenant.spec.etcd` and the etcd tenant-module catalog entry deprecated; new tenants stop offering it. Stop shipping the hardcoded `_namespace.etcd: tenant-root`. Update the ComputePlane docs and anything else describing `awaiting-etcd`. Optionally add the advisory migration that reports clusters still on a shared etcd.
4. **Phase 4 — remove plumbing.** Once that signal shows no cluster on a shared etcd, delete `apps/tenant/templates/etcd.yaml`, the `etcd` tenant value, the `_namespace.etcd` propagation, the `cozy-lib.ns-etcd` helper, and the `namespace.cozystack.io/etcd` label. Keep the etcd-operator, the etcd chart, and the standalone etcd app.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

26 templates in packages/apps/kubernetes/templates read _namespace.etcd, including the addon HelmReleases, CSI, KCCM and the autoscaler gates. Those gates have to go before the propagation does.

Andrei Kvapil (kvaps) pushed a commit that referenced this pull request Nov 2, 2026
… storage

Etcd, ingress and seaweedfs modules are exempt as platform overhead, and
etcd stays exempt once per-cluster etcd (#25) moves it into the
Kubernetes app. Monitoring reserves its declared storage only, which is
the one module figure that still needs a gate when the flag is enabled.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
Aleksei Sviridkin (lexfrei) added a commit to cozystack/cozystack that referenced this pull request Nov 24, 2026
…4817)

## What this PR does

A tenant Kubernetes cluster could not start until an ancestor `Tenant`
had `spec.etcd: true`. The chart read the datastore name from
`_namespace.etcd` and, with none, rendered only a
`<release>-awaiting-etcd` ConfigMap. Every cluster below that tenant
then shared one etcd, one CA and one disk, separated by key prefix only.
Whoever creates a cluster usually may not edit the `Tenant`, so anything
ordering clusters on a tenant's behalf (the portal's controller, for
one) had to flip `etcd: true` first.

This PR makes the `Kubernetes` application carry its own etcd. It
implements phases 1 and 2 of the per-cluster etcd design proposal,
[cozystack/community#25](cozystack/community#25),
as three commits that can be split later:

1. `refactor(etcd)`: the etcd chart's `EtcdCluster`, cert-manager PKI,
`DataStore`, `WorkloadMonitor`, defrag `CronJob`, VPA and `VMPodScrape`
move into named templates in `cozy-lib`
(`packages/library/cozy-lib/templates/_etcd.tpl`), parameterised by the
cluster name. `packages/extra/etcd` calls them with `"etcd"`, and its
rendered output is byte-identical before and after (see Verification).
2. `feat(kubernetes)`: a new cluster renders its own `EtcdCluster` and
`DataStore` from those templates, and a cluster that already runs on a
shared tenant etcd keeps it.
3. `feat(platform)`: migration 63 → 64 reports which clusters stay on a
shared etcd and changes nothing.

Phases 3 and 4 (deprecating, then removing `Tenant.spec.etcd`,
`_namespace.etcd` and `cozy-lib.ns-etcd`) are left for later.

### Design

**Names.** For release `kubernetes-<name>` in namespace `<ns>`:

| Object | Name |
|---|---|
| `EtcdCluster`, its headless Service, members `<…>-xxxxx`, `<…>-client`
Service | `kubernetes-<name>-etcd` |
| Secrets | `kubernetes-<name>-etcd-{ca,client,server,peer,peer-ca}-tls`
|
| `DataStore` (cluster-scoped) | `<ns>.kubernetes-<name>` |
| DataStore endpoint | `kubernetes-<name>-etcd.<ns>.svc:2379` |

**Shared templates.** `cozy-lib.etcd.cluster` takes optional `labels`
and `annotations` and renders them into the `EtcdCluster`'s
`spec.additionalMetadata`, which etcd-operator copies onto every member
Pod and PVC. With neither set, it renders no `additionalMetadata` at
all.

**Values.** One new field, `etcd.replicas`: `3` (default) or `1`. The
schema bounds it to 1..3 and the chart refuses 2 at render time. Size
(4Gi), resources (1000m / 512Mi limits to start with) and the etcd
version (3.6.11, the etcd chart's default) are chart-internal. Where a
VerticalPodAutoscaler runs, it sizes each member's requests as it is
recreated, up to 5000m CPU / 8Gi memory divided by the platform's CPU
and memory allocation ratios (500m / 8Gi at the default ratios of 10 and
1), with the limits scaled in proportion; NOTES.txt and the README say
so.

**StorageClass.** Two new platform values,
`kubernetesEtcd.storageClassLocal` and
`kubernetesEtcd.storageClassReplicated`, reach the chart as
`_cluster.etcd-storage-class-local` (used with 3 members) and
`_cluster.etcd-storage-class-replicated` (used with 1 member). Empty
keys fall back to the namespace default StorageClass.
`spec.storage.storageClassName` is immutable on an `EtcdCluster`, so the
chart reads the live object's class on every render after the first and
never re-derives it; scaling 1 → 3 keeps the class the cluster started
with. Dropping from 3 members to 1 is refused at render time when the
etcd is on the class the platform names for 3 members, or off the class
it names for 1, because a single member would then hold the only copy of
the control-plane state on storage that does not replicate it. An etcd
that was created with one member keeps rendering whatever its class.

**New clusters vs existing ones.** The chart decides from the live
`KamajiControlPlane`, looked up by release name:

- no `KamajiControlPlane`, or one whose `spec.dataStoreName` is the
cluster's own name: own etcd;
- one that names any other `DataStore`: that `DataStore` is kept, and
the chart renders no etcd of its own.

Clusters stuck in the old awaiting-etcd state have no
`KamajiControlPlane`, so they get their own etcd on their next
reconcile. `_namespace.etcd` is deliberately not the signal.
`packages/system/cozystack-basics/templates/cozystack-values-secret.yaml`
hardcodes `etcd: tenant-root`, and
`packages/apps/tenant/templates/namespace.yaml` passes it down, so every
tenant publishes a value whether or not an etcd runs behind it.
Honouring it for new clusters would change nothing for anyone. Following
it for existing clusters is also wrong: today, switching on `spec.etcd`
for a mid-level tenant silently moves every cluster below it to a new
datastore, which is a Kamaji datastore migration. With this PR, the live
binding sticks.

An existing cluster renders exactly what it rendered before, pre-delete
hook included, apart from randomly generated Talos tokens, so the
upgrade rolls no control-plane pods. New clusters carry
`policy.cozystack.io/allow-to-etcd-cluster` instead of
`policy.cozystack.io/allow-to-etcd`, which only admits a cluster to its
tenant's shared etcd.

Both lookups the decision rests on read the chart's own live objects:
the binding its `KamajiControlPlane` already records, and the immutable
`storageClassName` of its `EtcdCluster`. Each gives the same output on
every render, and their empty branch is the new-cluster render offline
`helm template` sees, which is the kind of `lookup` the chart guidelines
allow.

**What goes away.** The `awaiting-etcd` beacon goes, along with the
`_namespace.etcd` gate on the ~25 addon and satellite templates
(`helmreleases/*`, `csi/deploy.yaml`, `kccm/manager.yaml`,
`cluster-autoscaler/deployment.yaml`, `ingress.yaml`, the Proxmox CCM
and CSI). A datastore now always exists, so these gates were always
true.

**Deletion.** The pre-delete hook deletes the `TenantControlPlane` and
waits up to 120s, and it exits 0 whatever is left, because a failing
pre-delete hook keeps the release and retries the same teardown; the one
exception is below. Kamaji's `finalizer.kamaji.clastix.io` drops the
tenant's etcd role, prefix and user and the datastore-config Secret's
finalizer, and it runs only while the `DataStore` is Ready and answers,
so a `TenantControlPlane` whose own etcd never came up or has lost
quorum would never finish deleting. On a cluster that owns its etcd,
those three objects live in the etcd this uninstall deletes next. So
when such a `TenantControlPlane` outlives the wait, the hook (Step 4a)
removes that one finalizer with a JSON patch that tests it at the index
it was read at, waits another 60s, and lets Step 4b clear the Secret's
finalizer as before. A `TenantControlPlane` on a shared `DataStore` is
left to Kamaji, since that etcd outlives the cluster. The hook also
deletes the etcd's five Certificates and then their Secrets (Step 8),
which cert-manager issues without an owner, in the same order and for
the same reason as Step 7 deletes the Talos PKI. Then:

- Helm removes the `EtcdCluster`, `DataStore` and the remaining objects;
- the member PVCs go by garbage collection, because the operator owns
them through the `EtcdMember`s.

If Step 4a's patch is rejected, or the `TenantControlPlane` cannot be
read, the hook prints its residue summary and fails before Step 8: Helm
would otherwise delete the etcd while Kamaji's finalizer still waits on
it, so the uninstall is retried with the etcd and its PKI in place.
Steps 4a and 8, that check and their RBAC (a `patch` on this release's
`TenantControlPlane`, and `delete` on the etcd Certificates and Secrets
by name) render only for a cluster that owns its etcd.

### Deviations from cozystack/community#25

- **DataStore name** is `<namespace>.<release>`, not
`<namespace>-<release>`. Tenant names are alphanumeric and nest with
dashes, so the dashed form collides: Kubernetes `foo` in `tenant-a`
gives `tenant-a-kubernetes-foo`, which is also the namespace, and
therefore the shared `DataStore` name, of tenant `foo` under tenant
`kubernetes` under `tenant-a`. A namespace cannot contain a dot. Kamaji
copies the `DataStore` name into the pod label
`component.kamaji.clastix.io/datastore`, so the name is capped at 63
characters, truncated with an 8-character hash past that.
- **No truncate-and-hash for `kubernetes.etcdName`.** The app name is
now capped at 32 characters (`@maxLength 32`, added with the nodes
split), so `kubernetes-<name>-etcd` is at most 48 characters. That is
inside the 56 the operator needs: the `<name>-client` Service and the
generated member names must fit in 63. The helper fails the render past
56 rather than rename anything.
- **"Honour an explicit `_namespace.etcd`"** means keeping a cluster on
the `DataStore` its live control plane names, for the reason above. It
does not mean following `_namespace.etcd` for new clusters.
- **`etcd.replicas` validation** is a schema range of 1..3 plus a
render-time refusal of 2, rather than a schema enum. `cozyvalues-gen`
v1.7.0, the version CI pins and the latest release, emits string members
for an integer enum, which would reject the default `3`. The aggregated
API does not validate an application's spec against its schema at all,
so neither an enum nor a CEL rule would refuse 2 at admission; Helm's
`values.schema.json` check and the render are where it is refused.
- **The delete-hook branch** keys on the same live-`KamajiControlPlane`
condition as the render, as #25 asks, and additionally checks at run
time that the `TenantControlPlane` names this cluster's own `DataStore`
before touching Kamaji's finalizer. Helm deletes release resources only
after the pre-delete hook, so the etcd outlives Kamaji's normal
finalization without any ordering inside the hook.
- **TLS** reuses the etcd chart's `secretRef` shape (chart-issued
certificates) rather than the operator's `certManager` mode. Kamaji's
`DataStore` needs the CA private key to sign each tenant's client
certificate, and `secretRef` keeps that key in a Secret the chart
controls. The server certificate also carries the operator's
`<name>-client` Service names, which the etcd chart's does not.
- **Satellites.** The `PrometheusRule` stays in the etcd chart only, so
a cluster's own etcd has no alert rules. `VMPodScrape`, VPA and the
`CiliumNetworkPolicy` render only where their APIs are served. The etcd
chart's `VMPodScrape` now selects `app.kubernetes.io/instance: etcd`
instead of `app.kubernetes.io/name: etcd`: etcd-operator stamps the
latter on every member it runs, so a tenant etcd would otherwise also
scrape the cluster etcds in its namespace and count their members as its
own.
- **Name budget.** The defrag `CronJob` is `<etcd name>-defrag`, which
reaches 55 characters for a 32-character app name while the apiserver
caps CronJob names at 52; past 52 the template truncates it and appends
an 8-character hash. The etcd chart's `etcd-defrag` is unaffected.
- **Defrag image.** The defrag container pulls
`ghcr.io/ahrtr/etcd-defrag:v0.13.0` through `cozy-lib.image`, pinned to
the multi-architecture index digest, so a configured registry mirror
applies; `_etcd.tpl` is tracked by Renovate and listed in
`IMAGE_REF_EXTRA_FILES`. This changes the etcd chart's CronJob too,
after the extraction commit. Contributed by @yankawai in #5387 and
folded in.
- **Migration.** The opt-in migration runbook is not implemented here
(see below), and no `talosconfig` is issued. The numbered migration only
reports, as #25 suggests.

### Gaps #25 did not cover

- **Backups.** Covered through the `Kubernetes` backup strategy (#4931),
which `cozy-default` routes `apps.cozystack.io/Kubernetes` to. It
resolves the datastore from the `TenantControlPlane`, so it dumps the
cluster's key prefix from its own etcd or a shared one alike. Its dump
Job runs in the application namespace, and the deny policy below would
refuse it, so the strategy's pod template now carries
`policy.cozystack.io/allow-to-etcd-cluster: {{ .Release.Prefix }}{{
.Release.Name }}-etcd`, which is inert for a cluster on a shared etcd.
The strategy's Velero half does not select the etcd's PVCs or TLS
Secrets and does not need to: the dump restores into whatever etcd the
control plane runs on.
- **Per-cluster network policy.** A `CiliumNetworkPolicy` named after
the etcd selects its member pods with `ingressDeny` on 2379/2380 against
two sets of pods and one entity. The first is pods in the tenant
namespace that are neither members nor carry
`policy.cozystack.io/allow-to-etcd-cluster: <etcd name>`, a label set on
the control-plane pods, the defrag Job and the backup dump Job. The
second is pods in any other namespace except `kube-system` and
namespaces labelled `cozystack.io/system: "true"`, which is where
Kamaji, its migrate Job and etcd-operator run. The entity is `world`,
which the tenant's `allow-external-communication` admits to every
endpoint, so sources off the cluster, such as Proxmox workers, are
denied too. The node's own `host` and `remote-node` traffic is not. Deny
rules are needed because the tenant's own policies allow all traffic
within a namespace and from ancestor tenants, and allow rules only add.
Metrics on 2381 stay open. The pods also carry `cozystack.io/service:
kubernetes-etcd` rather than `cozystack.io/service: etcd`, so the
tenant-wide `<tenant>-ingress-etcd` policy does not admit child tenants'
control planes to them. The policy renders only where Cilium serves
`cilium.io/v2/CiliumNetworkPolicy`.
- **Platform ordering.** `cozystack.kubernetes-application` now
`dependsOn` `cozystack.etcd-operator`. Both come with the isp-full
variants, the only ones the iaas bundle allows. The selective-install
fixture is unchanged (`hack/select-install.sh --disabled postgres`
produces the same set). The same edge makes an etcd-operator change
select the `kubernetes-latest`, `kubernetes-previous` and `computeplane`
e2e suites besides `etcd`, and `hack/select-e2e_test.bats` now expects
that.
- **e2e.**
- `hack/e2e-install-cozystack.bats` no longer turns on tenant-root's
etcd, which only Kubernetes clusters used, and no longer waits for it. A
cluster that fell back on a shared etcd would therefore not come up.
- `run_kubernetes_test` asserts the control plane names
`tenant-test.kubernetes-<name>` and that `kubernetes-<name>-etcd`
reaches `Available`.
- `kubernetes-latest` runs the shipped defrag CronJob once and asserts
the Job completes (from #5387), then probes the etcd client port with
`nc -z`: an unlabelled Pod in `tenant-test` and a labelled Pod in
`tenant-root` must be refused, and a labelled Pod in `tenant-test` must
connect as the control. Each Pod ends `Succeeded` only when its verdict
matches, so a probe that cannot run fails the step.
- `cozy_cleanup` waits up to 3m until the `EtcdCluster`, `DataStore`,
member PVCs and Secrets are gone, each read bounded by that deadline;
both Kubernetes suites' teardown op grows from 22m to 25m to cover it.
- The Proxmox suite's tenant drops `etcd: true` and the comment calling
it mandatory.
  - The ComputePlane suite's comment no longer cites #4726.
- `hack/admin-kubeconfig-invariant.bats` drops its two awaiting-etcd
cases, and the now-unused `tests/values-ci-no-etcd.yaml` goes with them.
- **Generated artifacts** come from the tooling. `make -C
packages/apps/kubernetes generate` produced `values.schema.json`, the
README table, `api/apps/v1alpha1/kubernetes/types.go` and
`packages/system/kubernetes-rd/cozyrds/kubernetes.yaml`. Root `make
generate` regenerated `zz_generated.deepcopy.go`, and
`pkg/generated/openapi` did not change. `make generate` in every touched
package leaves the tree clean.
- **Existing clusters.** Migration 63 → 64 lists every
`KamajiControlPlane` whose `DataStore` its own release did not render,
judged by Helm's release annotations on the `DataStore`, with that
`DataStore`'s endpoints. It writes nothing but the version stamp. Slot
check on 2026-11-23:
  - `main` ships through 62 (#5239) with `targetVersion: 63`;
- `release-1.7` ships through 60 (target 61), and `release-1.6` through
53 (target 54);
  - so this PR takes 63 and sets `targetVersion: 64`.
- **README.** `packages/apps/kubernetes/README.md` now describes the
cluster's own etcd, the case of a cluster that keeps its tenant's shared
one, the VPA sizing and the backup path. The ComputePlane README no
longer lists a tenant etcd as a prerequisite.

### Migrating an existing cluster (designed, not implemented)

Nothing here moves a cluster, and nothing should until the runbook below
has an e2e. It combines #25's runbook with SerjioTT's Talos measurements
of 2026-09-03 (about 20s copy, 43s from patch to Ready, reads
uninterrupted) and with what Kamaji 26.9.4-edge's code does.

1. **Opt-in.** The opt-in has to make the chart render the cluster's own
etcd beside the shared one, without switching `dataStoreName`. The
likely shape is a chart-internal value, or an annotation the chart
reads, that the operator sets. Wait for `Available=True`.
2. **Snapshot the source etcd.** This is the rollback path.
3. **Pre-flight reachability from the cluster's namespace, not
Kamaji's** (SerjioTT finding 1). Kamaji's migrate Job runs in Kamaji's
namespace and can reach any etcd, so the copy "succeeds" toward a target
the control-plane pods cannot dial; the new apiserver generation then
crash-loops and the cluster stays write-frozen. Run `nc -zv <target>
2379` from a pod carrying the control plane's labels in the cluster
namespace. For the per-cluster target this holds by construction (same
namespace, and the deny policy admits the control plane), but the check
stays because rollback goes the other way.
4. **Switch.** Point `KamajiControlPlane.spec.dataStoreName` at
`<ns>.<release>`, with the CAPI provider re-projecting it onto the
`TenantControlPlane`. `kamaji.clastix.io/migration-timeout` can go on
the `KamajiControlPlane`, because the provider copies annotations to the
`TenantControlPlane`. Before switching, delete any leftover
`migrate-<TCP UID>` Job in Kamaji's namespace:
- a leftover with identical arguments is taken as success and switches
the datastore without copying;
- one with different arguments is deleted and recreated, with the freeze
already installed.
5. **Verify writes, not status** (SerjioTT finding 2). Kamaji installs a
`kamaji-freeze` ValidatingWebhookConfiguration in the guest, and only
its soot controller removes it, only when the `TenantControlPlane`
status is exactly `Ready`. A paused `TenantControlPlane`, or one sitting
in `WriteLimited`, `Sleeping` or `Upgrading`, keeps the freeze. Node
leases are exempt and reads are untouched, so nodes and `kubectl get`
look healthy. The success criterion is a canary write through the guest
API; if `kamaji-freeze` is still in the guest after the
`TenantControlPlane` is `Ready`, delete it.
6. **Restart every worker kubelet, one node at a time** (SerjioTT
finding 3). Until it restarts, a kubelet keeps running existing pods but
never starts a newly bound one, so the cluster looks healthy and
silently stops starting workloads. The per-node check is a new pod
starting on that node.
- On Talos there is no operator path to the workers' API today: the
chart has a per-cluster `talos-ca` Issuer but issues no client
credentials from it, so the fallback is `virtctl restart` per VM.
- Issuing an operator `talosconfig` from that CA alongside the admin
kubeconfig is the follow-up that makes this step cheap. It is not in
this PR: it is a separate credential with its own exposure question.
- Any pod-based restarter must be deployed before the switch, because a
deaf kubelet will not start it.
7. Retain the source prefix and the snapshot for a cool-off period, then
reclaim. Kamaji does not clean the old prefix after a migration.
Rollback is the same procedure in reverse, against the retained
snapshot.

### Test plan

Done here, on today's `main`, no cluster involved:

- [x] `helm template` of `packages/extra/etcd` before and after the
extraction (commit 1) is byte-identical: 14 renders (default; 1 member +
local SC + 10Gi; resources with CPU and memory allocation ratios +
another version; a global topology spread; a hard affinity with 5
members and 512Mi; leftover `backup.*` values with 0 members; 1 member
at 8Gi with a CPU allocation ratio, for the defrag quota flag), each in
`tenant-root` and `tenant-abc`, all identical by sha256. After commit 2
the one difference in each is the `VMPodScrape` selector.
- [x] `helm template` of `packages/apps/kubernetes` with Cilium served.
With `_namespace.etcd` set to `tenant-root`, or empty, both with 3
members: `EtcdCluster/kubernetes-demo-etcd` replicas=3 on the namespace
default StorageClass, and `DataStore/tenant-demo.kubernetes-demo`
pointing at `kubernetes-demo-etcd.tenant-demo.svc:2379`. The
`KamajiControlPlane` names that `DataStore`, and the policy renders.
- [x] With the platform StorageClass keys set: 1 member uses
`replicated` and 3 members use `local`. 2 members is refused at render
time; 5 is refused by the schema.
- [x] An existing cluster (live-`KamajiControlPlane` lookup stubbed to
return `tenant-root`) renders identically to `main` with
`values-ci.yaml`, pre-delete hook included, apart from random Talos
tokens. A new cluster's render differs from `main` only by the old
shared `dataStoreName`, the shared-etcd pod label and the added etcd
objects.
- [x] helm-unittest:
- `packages/apps/kubernetes`: 392 tests. The 28-case
`tests/etcd_test.yaml` covers names, the second cluster in one
namespace, the 63-character `DataStore` cap, the 52-character defrag
`CronJob` cap at the longest app name, the defrag quota for a 4Gi etcd,
StorageClass choice and stickiness, the refused and the allowed drops to
one member, refusal of 2, the policy with its `world` deny, and the
hook's Step 4a/8 RBAC. For an existing cluster it covers staying on the
shared `DataStore`, ignoring a changed `_namespace.etcd`, keeping the
shared-etcd label, no own etcd and no Step 4a/8.
- `packages/extra/etcd`: 29, including the new scrape-selector case.
`packages/core/platform`: 335. `cozy-lib-tests`: 90.
`packages/system/backupstrategy-controller`: 67, now asserting the dump
Job's label. `packages/apps/tenant`: 89. `packages/extra/computeplane`:
18.
- [x] bats, 867 cases, all passing (`helmrelease-readiness` and
`bats-runner-coverage` included): every `hack/run-kubernetes*_test.bats`
(including two new cases pinning the teardown reads to their deadline),
`kubernetes-pre-delete-hook` (13, split into the shared and the own-etcd
branch, including the fail-closed exit before Step 8),
`check-render-matrix`, `chainsaw-op-budgets`,
`migration-62-shared-etcd-report` (new, 4),
`admin-kubeconfig-invariant`, `check-hook-request-timeout`,
`app-cleanup-hooks_test`, `bats-no-negated-assert`, `bats-no-exit-trap`,
`select-install_test`, `select-e2e_test`, `linstor-storage-mode_test`,
`cozystack-version-stamp` and `md-no-hardwrap`.
- [x] `go build ./...` and `go vet` on the `api/apps/v1alpha1`
Kubernetes package.
- [x] `make generate` in every touched package and at the root leaves no
diff; `hack/check-commit-trailers.sh origin/main..HEAD` passes.

Needs a live cluster:

- [ ] The e2e lanes: `kubernetes-latest`, `kubernetes-previous` and
`computeplane`, now without tenant-root's etcd. The Proxmox lane on its
self-hosted runner.
- [ ] Upgrade from `main` with an existing cluster on tenant-root's
etcd. It must stay on `tenant-root` with no control-plane rollout, and
migration 63 must list it. No CI lane runs a cluster on a shared etcd,
because the chart no longer creates one; an upgrade lane that installs
the previous release first is a follow-up.
- [ ] The deny policy beyond what `kubernetes-latest` now probes: from a
guest worker VM and from outside the cluster, `nc -zv
kubernetes-<name>-etcd.<ns>.svc 2379` must be refused. The control
plane, the defrag Job, a `Kubernetes` backup dump Job, an `EtcdSnapshot`
Job, Kamaji and etcd-operator must still connect, including a freshly
started control-plane pod (Cilium can briefly classify a new pod IP as
`world`).
- [ ] Delete a cluster whose own etcd never became Available (for
example, the quota case below). Step 4a must release the
`TenantControlPlane` and the uninstall must finish without manual work.
- [ ] A tenant whose `ResourceQuota` cannot fit 3 × 1000m/512Mi limits
and 3 × 4Gi requests must surface the quota error on the etcd member
pods.
- [ ] A backup and a restore through the `Kubernetes` strategy of a
cluster that owns its etcd, including the rebuild of a deleted cluster.

### Follow-ups, not opened

These are listed here at the maintainer's request rather than filed:

- **cozystack/website**:
- `content/en/docs/next/operations/configuration/platform-package.md`
gains `kubernetesEtcd.storageClassLocal` and
`kubernetesEtcd.storageClassReplicated`;
- `content/en/docs/next/kubernetes/relocate-etcd.md` describes the
shared tenant etcd as what a cluster uses;
- tenant and Kubernetes docs telling users to set `etcd: true` for a
cluster, which is now an obsolete workaround;
- the Kubernetes app reference is regenerated from the README on the
next stable tag.
- **cozystack/terraform-provider-cozystack**:
`internal/provider/kubernetes_schema.go` and `kubernetes_model.go` need
`etcd.replicas`, with the default of 3, a 1..3 range and the
expand/flatten pair.
- **cozystack/cozystack**, after this lands:
- an upgrade e2e lane that keeps a cluster on a shared etcd across the
upgrade;
  - alert rules for a cluster's own etcd;
  - the opt-in migration path and its e2e;
  - an operator `talosconfig`;
  - phases 3 and 4.

### Screenshots

Not a UI change.

### Downstream repositories

Follow-ups are listed above under "Follow-ups, not opened". By the
maintainer's decision they are not filed from this draft, so no box is
ticked.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: listed above, not yet filed
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: listed above, not yet filed
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
feat(kubernetes): each new tenant Kubernetes cluster now gets its own etcd (EtcdCluster `kubernetes-<name>-etcd` and Kamaji DataStore `<namespace>.kubernetes-<name>`), created and deleted with the cluster, so no ancestor Tenant needs `etcd: true` and the `awaiting-etcd` state is gone. The new `etcd.replicas` field chooses 3 members (default) or 1. Each member starts at 1000m CPU and 512Mi memory limits with a 4Gi volume, counted against the tenant's quota, and a VerticalPodAutoscaler may resize it as it is recreated. The platform values `kubernetesEtcd.storageClassLocal` and `kubernetesEtcd.storageClassReplicated` choose the StorageClass for 3 members and 1 member respectively. Existing clusters keep the shared tenant etcd they run on, unchanged; the upgrade lists them in the migration log. The `Kubernetes` backup strategy covers a cluster's own etcd as it covers a shared one. The tenant etcd's metrics scrape now selects only its own members.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* New Kubernetes clusters now use dedicated etcd by default, with one-
or three-replica configurations and platform-selected storage.
* Clusters already using shared etcd continue to use it. Installation
notes show where control-plane state is stored and summarize resource
limits.
* Kubernetes add-ons can render independently of tenant-shared etcd
settings.
* **Bug Fixes**
* Cluster removal now waits for dedicated etcd resources to be
reclaimed.
* Platform upgrades report clusters still using shared etcd without
modifying them.
* **Documentation**
* Updated Kubernetes and ComputePlane guidance on dedicated etcd,
storage options, and migration considerations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants