fix(kafka): link the node pools the hook creates to their HelmRelease

The broker and controller pools are applied by the pre-upgrade hook,
outside Flux, so they carry neither an ownerReference nor the
HelmRelease labels Flux puts on what it renders. The lineage walk from
a broker or controller pod therefore stopped at its pool: those pods
were never marked as managed by Cozystack, and the Kafka application's
schedulingClass never reached them.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
This commit is contained in:
Mattia Eleuteri committed 2026-11-23 08:05:10 +01:00
1 parent addf7d1258
commit fd885206e4
5 files changed
+34 -5

No files matched your search

+3 -3
View File
@@ -62,9 +62,9 @@ Neither lowering the `version` field on a running cluster nor rolling the app ba
### Scheduling parameters
| Name | Description | Type | Value |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----- |
| `schedulingClass` | Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`; any other value is refused. If the class is later removed from that list, new pods get the tenant's class. Empty means inherit from the tenant. | `string` | `""` |
| Name | Description | Type | Value |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----- |
| `schedulingClass` | Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant. | `string` | `""` |
## Parameter examples and reference
@@ -99,6 +99,12 @@ spec:
labels:
strimzi.io/cluster: ${name}
app.kubernetes.io/managed-by: Helm
# Flux puts these on everything it renders, and the lineage
# walk follows them to the application. A pool created here
# has neither them nor an ownerReference, so without them its
# broker and controller pods resolve to no application at all.
helm.toolkit.fluxcd.io/name: ${name}
helm.toolkit.fluxcd.io/namespace: ${ns}
annotations:
meta.helm.sh/release-name: ${name}
meta.helm.sh/release-namespace: ${ns}
@@ -134,6 +140,8 @@ spec:
labels:
strimzi.io/cluster: ${name}
app.kubernetes.io/managed-by: Helm
helm.toolkit.fluxcd.io/name: ${name}
helm.toolkit.fluxcd.io/namespace: ${ns}
annotations:
meta.helm.sh/release-name: ${name}
meta.helm.sh/release-namespace: ${ns}
@@ -279,3 +279,24 @@ tests:
- matchRegex:
path: spec.template.spec.containers[0].args[0]
pattern: 'brokerPool="b-[0-9a-f]{8}"'
# The pools are created by the hook, outside Flux, so they carry the
# HelmRelease labels themselves: the lineage walk needs them to resolve
# broker and controller pods to the Kafka application.
- it: labels both node pools with their HelmRelease
release:
name: test-kafka
namespace: tenant-test
asserts:
- matchRegex:
path: spec.template.spec.containers[0].args[0]
pattern: 'name: \$\{brokerPool\}\s+namespace: \$\{ns\}\s+labels:\s+strimzi\.io/cluster: \$\{name\}\s+app\.kubernetes\.io/managed-by: Helm\s+(#[^\n]*\s+)*helm\.toolkit\.fluxcd\.io/name: \$\{name\}\s+helm\.toolkit\.fluxcd\.io/namespace: \$\{ns\}\s+annotations:'
documentSelector:
path: kind
value: Job
- matchRegex:
path: spec.template.spec.containers[0].args[0]
pattern: 'name: [-a-z0-9]+\s+namespace: \$\{ns\}\s+labels:\s+strimzi\.io/cluster: \$\{name\}\s+app\.kubernetes\.io/managed-by: Helm\s+helm\.toolkit\.fluxcd\.io/name: \$\{name\}\s+helm\.toolkit\.fluxcd\.io/namespace: \$\{ns\}\s+annotations:\s+meta\.helm\.sh/release-name: \$\{name\}\s+meta\.helm\.sh/release-namespace: \$\{ns\}\s+# Controller node IDs'
documentSelector:
path: kind
value: Job
+1 -1
View File
@@ -212,7 +212,7 @@
}
},
"schedulingClass": {
"description": "Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`; any other value is refused. If the class is later removed from that list, new pods get the tenant's class. Empty means inherit from the tenant.",
"description": "Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant.",
"type": "string",
"default": "",
"maxLength": 63
+1 -1
View File
@@ -127,6 +127,6 @@ kafka:
## @section Scheduling parameters
## @param {string} schedulingClass - Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`; any other value is refused. If the class is later removed from that list, new pods get the tenant's class. Empty means inherit from the tenant.
## @param {string} schedulingClass - Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant.
## @maxLength 63
schedulingClass: ""