Aleksei Sviridkin 15126f27ca feat(clickhouse)!: mint tenant passwords through the credentials API (#5378)
## What this PR does

ClickHouse passwords are no longer readable from `<release>-credentials`
and can't be set through `users.<name>.password`. Today every `use`
member reads them there, and a leaked one can't be taken back. Now an
administrator mints a password on the user's `Credential`, sees it once,
and the next mint or a revoke kills it. This is the ClickHouse part of
the user secrets API design (cozystack/community#137).

Stacked on #4922. Review only the top four commits:

- `credentials-migrate` gets `--reserved-user`, `--values-path` and
`--rotate-key`.
- `credentials-migrate` can hold a kind's releases until given
Deployments run their new images.
- The chart renders a `sha256` CredentialTemplate per user and reads the
stored hash through `valuesFrom`, since the ClickHouse operator reads no
Secrets. `backup`, `default` and `clickhouse_operator` are refused as
user names.
- Migration 65 seeds the account Secrets from `<release>-credentials`
and suspends the ClickHouse releases before the chart switches. Its
finish Job, under its own `cozystack-credentials-migration-65` identity,
resumes them only after the new cozystack-controller and cozystack-api
run, then removes the tenant keys and rotates `backup` once, because
tenants could read it. The hold exists because the old controller strips
the `valuesFrom` entries the migration adds: without it the new chart
rendered no users, and clients were locked out for 10 minutes on the
first upgrade run.

Tested on a three-node cluster, fresh install: a minted password logs in
after about 60 s (the Helm re-render), the old one dies 2 s after the
next mint, revoke works, and removing a user removes everything. Mints
restart nothing. Full upgrade from 1.7.1 on the same cluster, all
engines at once with a client loop each: migrations 64-71 ran in order
and every account was adopted with its old password. The ClickHouse
releases were held for 19 minutes and the client loop saw no
authentication error.

Breaking for users: passwords can't be read any more, and each mint
costs a Helm upgrade of about a minute. Pods restart once during the
conversion for the `backup` rotation. While the hold lasts (19 minutes
on the test cluster) the ClickHouse apps can't be changed or deleted. A
release with a user named `backup`, `default` or `clickhouse_operator`
is not converted and raises `CredentialsMigrationIncomplete`.

Open questions:

1. `users.default` is refused, as the design says. Tenants may be using
it today, so should it be a mintable account instead?
2. A Helm upgrade already running during the `backup` rotation can write
the old value back. Should finish wait for the release to be idle?

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: needed, a ClickHouse note for the credentials API docs
(cozystack/website#753) and an upgrade note that clients must mint
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `cozystack_clickhouse` still sends
`users.<name>.password`
- [ ]
[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(clickhouse)!: ClickHouse passwords are issued through the credentials API and are no longer readable from `<release>-credentials`; `users.<name>.password` is ignored. An administrator mints a password on the user's Credential; it is shown once and applies after the next Helm upgrade of the release, about a minute. Existing passwords keep working through the upgrade, and migration 65 rotates the platform `backup` password, which restarts each ClickHouse instance once. A release with a user named `backup`, `default` or `clickhouse_operator`, or with a name that does not map to a valid account name, is not converted until the user is renamed; renaming a ClickHouse user means changing the apps that log in as it. Switch clients to minted passwords after the upgrade.
```


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

## Summary by CodeRabbit

* **New Features**
* ClickHouse account passwords can now be issued and revoked through the
credentials API. Newly issued passwords are available once and can be
used to log in after the release is upgraded.
* Platform-managed accounts are reserved, and account names are
validated for conflicts and supported formats.
* Platform upgrades now migrate existing ClickHouse credentials and
support backup-password rotation.
* **Bug Fixes**
* Tenant account passwords are no longer stored in the ClickHouse
credentials Secret; only the platform backup password remains there.
  * The credentials Secret is no longer exposed as a tenant resource.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-01 22:05:13 +03:00
2026-11-04 00:56:56 +01:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

GitHub Release Apache-2.0 License Commit activity OpenSSF Best Practices OpenSSF Scorecard CLOMonitor Support

Cozystack

Cozystack is a free and open-source platform and framework for building clouds.

Cozystack is a CNCF Sandbox project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You are welcome to take on the fix yourself. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join us in #cozystack, on either CNCF Slack (get an invite) or Kubernetes Slack (get an invite), in our Telegram group, and at our community meetings. Add them to your Google Calendar or iCal for convenience.

Project documents

Document What it covers
Governance How decisions are made and who makes them
Contributor Ladder How to grow from contributor to maintainer
Maintainers Who maintains the project
Code of Conduct What we expect of each other
Security Policy Reporting a vulnerability, and which releases get fixes
Adopters Who runs Cozystack in production
Roadmap Where the project is going

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 53.3%
Shell 33.1%
TypeScript 6.6%
Go Template 4.7%
Makefile 1.2%
Other 1%