feat(clickhouse)!: render a CredentialTemplate per user

Tenant passwords move to platform-minted credentials. The chart no
longer generates, looks up or renders any tenant password and ignores
users.<name>.password: it renders one CredentialTemplate per user, and
cozystack-controller keeps the account Secret holding the SHA-256 of
the password the Cozystack API mints.

The operator watches no Secrets, and a hash inline in the
ClickHouseInstallation is the only path it applies without a restart,
so the template asks for a valuesPath: the HelmRelease pulls each
stored hash into _accounts.u<digest of the user name>, the chart
renders it as password_sha256_hex, and the Flux watch label upgrades
the release when a mint changes the Secret. A user with no verifier in
the values is left out of the installation, because the operator would
give a passwordless user the password "default".

backup stays a platform account in <release>-credentials, which now
holds only it, is labelled not tenant visible and is no longer selected
by the ApplicationDefinition. The names backup, default and
clickhouse_operator are refused for tenant users. A rotation of the
backup password restarts the pods once, since the backup sidecar reads
it from its environment at start.

A user whose account name is longer than 63 characters, does not start
and end with a letter or a digit, or is shared with another user is
refused at render, as credentials-migrate refuses it, so an install and
an upgrade accept the same names. A users.<name>.password left in
values draws an admission warning that points at a mint on the user's
Credential.

Existing clients lose readable passwords; an administrator mints a new
one.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Andrei Kvapil committed 2026-12-01 14:30:31 +01:00
1 parent 85243d43f1
commit 2f4f82a36c
14 files changed
+399 -53

No files matched your search

+1 -3
View File
@@ -45,7 +45,7 @@ type ConfigSpec struct {
// TTL (expiration time) for `query_log` and `query_thread_log`.
// +kubebuilder:default:=15
LogTTL int `json:"logTTL"`
// Users configuration map.
// Users configuration map. Passwords are issued through the Cozystack credentials API: a mint on the user's `Credential` (`core.cozystack.io`) returns a new password once and stores only its SHA-256, and a revoke retires the password without issuing one. A user can log in once a password has been minted, after the release has upgraded with it. The names `backup`, `default` and `clickhouse_operator` are reserved for platform accounts. A `password` key here is ignored.
// +kubebuilder:default:={}
Users map[string]User `json:"users,omitempty"`
// Backup configuration.
@@ -155,8 +155,6 @@ type S3CredentialsSecret struct {
}
type User struct {
// Password for the user.
Password string `json:"password,omitempty"`
// User is readonly (default: false).
Readonly bool `json:"readonly,omitempty"`
}