mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->
## What this PR does
With `external: true` the chart renders a Strimzi listener `external` on
port 9094, `type: loadbalancer`, with TLS on by default but **no
`authentication` block**. Anyone who can reach the public LoadBalancer
address can produce and consume on every topic; TLS only encrypts the
session. The entity operator's User Operator is already deployed, but
nothing declares a KafkaUser.
This PR:
- adds `authentication: {type: scram-sha-512}` to the `external`
listener. The internal listeners (9092 plain, 9093 TLS) are unchanged;
- adds a `users` map. Each key renders a `KafkaUser`
(`kafka.strimzi.io/v1`, `strimzi.io/cluster: <release>`,
`authentication.type: scram-sha-512`) named `<release>.<user>`; the dot
keeps it from spelling any Secret Strimzi derives from a cluster name,
this release's or another's. That name is also the SCRAM username and
the name of the Secret into which the User Operator writes the generated
password (`password`, `sasl.jaas.config`). The release prefix keeps two
Kafka instances in one tenant namespace from colliding;
- refuses user names that are not valid object names;
- lets the tenant read each user's Secret via the existing
`<release>-dashboard-resources` Role, and shows it in the tenant-secret
API: the Kafka ApplicationDefinition selects Secrets labelled
`strimzi.io/kind: KafkaUser`. The instance scope comes from the Secret's
ownership; a templated label value would never match, since only
`resourceNames` are rendered
(`internal/lineagecontrollerwebhook/kafka_rd_secrets_test.go` runs the
Strimzi Secrets through the matcher);
- rewrites the `tls.enabled` description, which said Strimzi provides no
authentication on this listener. Without TLS the data and the SCRAM
exchange are exposed, not the password itself;
- documents the client settings (SASL, truststore from
`<release>-cluster-ca-cert`) and two upgrade sequences in the README.
Passwords are always generated by Strimzi. I did not add a `password`
field like RabbitMQ's; that can come later.
**Known limit:** no ACLs. The cluster has no `authorization`, so every
authenticated user can read and write every topic. Per-user ACLs are a
follow-up.
**Breaking:** an instance with external access refuses unauthenticated
clients after the upgrade. The previous chart cannot create the users
from `users`, so the README gives two sequences: a maintenance window
(declare `users`, upgrade, then configure clients), or credentials
staged ahead by a cluster administrator through `KafkaUser` objects
carrying Helm's ownership metadata, which the upgrade adopts with their
passwords unchanged. Neither has been run on a live cluster.
**Tests**
- New `tests/external_authentication_test.yaml` (11 cases).
- The listener assertions in `kafka_test.yaml` and `kafka_tls_test.yaml`
now include the `authentication` block.
- `helm unittest packages/apps/kafka`: 114 passed.
- Not deployed on a live cluster.
**Backport:** none. Refusing existing clients after an upgrade does not
belong in a patch release, so this stays on `main` and lands in the next
minor (`backport/skip`).
### Screenshots
<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->
### Downstream repositories
<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.
Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.
IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:
1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->
- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#86 (issue: model the
`users` map on the Kafka resource and data source)
- [ ]
[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
<!-- Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->
```release-note
fix(kafka)!: the external listener (port 9094, enabled by external: true) now requires SCRAM-SHA-512 authentication instead of accepting anonymous clients. Declare clients in the new users map; each gets a KafkaUser named <release>.<user> whose generated password is in the Secret of the same name. External clients of an instance with external access are refused after the upgrade until they authenticate; see "Upgrading an instance that has external access" in the Kafka README for a maintenance-window sequence and one that stages the credentials ahead.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Configure SCRAM-SHA-512 users for external Kafka access. Each user
receives generated credentials and read/write access to all topics;
credential Secrets are available to tenant resources.
* Invalid, reserved, or overlong user names are rejected.
* **Documentation**
* Clarified that external access requires SCRAM-SHA-512 authentication,
even when TLS is disabled. Without TLS, data is unencrypted and the
authentication exchange is exposed, but the password is not.
* Added external-client connection guidance, certificate trust
information, and upgrade instructions for configuring credentials.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd