Files
cozystack/hack/e2e-chainsaw/computeplane
Timofei LarkinandYan Bondarenko 16da53637e feat(kubernetes): give each new cluster an etcd of its own
A tenant Kubernetes cluster could only start once an ancestor Tenant had
an etcd module turned on, which nobody creating a cluster may do, and
every cluster below that tenant then shared one etcd, one CA and one
disk. Anything that orders clusters on a tenant's behalf had to flip the
tenant's etcd on first.

A new cluster now renders its own EtcdCluster and DataStore, from the
cozy-lib shapes the etcd chart uses, and is created and deleted with
them. The awaiting-etcd state goes, since a datastore always exists.

An existing cluster stays on the DataStore its live KamajiControlPlane
names, and renders what it rendered before. Changing that name starts a
Kamaji datastore migration, which freezes the tenant's writes and leaves
every worker kubelet needing a restart, so no upgrade may do it.
_namespace.etcd cannot decide this: tenant-root publishes one to every
tenant whether or not an etcd runs behind it.

On uninstall, Kamaji's datastore finalizer drops the tenant's role,
prefix and user from an etcd this release deletes next, and it never
completes while that etcd is down. The pre-delete hook therefore removes
it from a TenantControlPlane on the cluster's own DataStore that
outlives the wait, and deletes the etcd's PKI, which cert-manager issues
without an owner. If the finalizer stays on, or the TenantControlPlane
cannot be read, the hook fails before the PKI goes, so the uninstall is
retried with the etcd still in place. A TenantControlPlane on a shared
DataStore is left to Kamaji as before.

A Cilium deny policy keeps the rest of the tenant namespace, ancestor
tenants and off-cluster sources off the etcd ports; the Kubernetes
backup strategy's dump Job carries the label it admits. The tenant
etcd's scrape now selects its own members by instance, because every
member etcd-operator runs carries app.kubernetes.io/name: etcd. The
platform waits for etcd-operator before offering the application.

The defrag job both charts share pulls its image through the configured
registry, pinned by digest to the multi-architecture index, so a
mirrored installation does not depend on ghcr.io for it.

Tested with helm-unittest on both the own and the shared branch, the
pre-delete hook's bats suite run against a stub kubectl for both, and a
render of an existing cluster that matches main byte for byte.
The guest e2e runs the defrag CronJob once, and probes the etcd client
port from a labelled Pod, an unlabelled one and one in tenant-root.

Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-24 09:04:49 +01:00
..