feat(chart): allow the platform namespaces to be created out-of-band - #3468
feat(chart): allow the platform namespaces to be created out-of-band#3468aweingarten wants to merge 5 commits into
Conversation
The chart renders apl-operator, otomi and apl-secrets from a bare
00-namespace.yaml. When one of them already exists, helm refuses the
install outright:
Error: rendered manifests contain a resource that already exists.
Unable to continue with install: Namespace "..." exists and cannot
be imported into the current release: invalid ownership metadata
This is common: bootstrap tooling frequently has to create a namespace
before the operator installs, to land CRDs, StorageClasses or
NetworkPolicies first. Today the only way through is to manage the
collision downstream.
Add `installation.createNamespaces` (default true, so existing installs
are unchanged) to skip rendering the namespaces when an integrator
creates them out-of-band.
Note this is deliberately not "add helm ownership metadata to the
manifest": helm validates ownership against the *live* object, so
annotating the template cannot make an already-existing namespace
adoptable. Gating creation is what actually unblocks the integrator.
Refs linode#3418
CasLubbers
left a comment
There was a problem hiding this comment.
The flag is good, if you could only change the comment.
| mode: standard | ||
| # Skip deployment of the operator | ||
| skipOperatorDeployment: false | ||
| ## Create the namespaces the platform needs (apl-operator, otomi, apl-secrets). |
There was a problem hiding this comment.
This comment is way to verbose. This is more clear and concise:
## Create namespaces (apl-operator, otomi, apl-secrets). Disable if creating them yourself.
There was a problem hiding this comment.
Pull request overview
This PR makes the apl Helm chart tolerant of platform namespaces that are created out-of-band (e.g., by bootstrap tooling), by allowing chart-driven Namespace creation to be disabled so installs don’t fail on Helm ownership conflicts.
Changes:
- Adds
installation.createNamespaces(defaulttrue) to control whether the chart renders the platform namespaces. - Wraps the
00-namespace.yamltemplate in a conditional so it renders 0 Namespace objects when the flag is disabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| chart/apl/values.yaml | Documents and defaults the new installation.createNamespaces flag. |
| chart/apl/templates/00-namespace.yaml | Conditionally renders the 3 platform Namespace manifests based on the new flag. |
Suppressed comments (1)
chart/apl/templates/00-namespace.yaml:26
00-namespace.yamlcurrently leaves a trailing whitespace-only line outside theifblock (line 26). Wheninstallation.createNamespacesis false this template will still render whitespace, which is best avoided to prevent any chance of Helm treating it as an (invalid) manifest fragment.
{{- end }}
| ## Create the namespaces the platform needs (apl-operator, otomi, apl-secrets). | ||
| ## Set to false when they are created out-of-band — bootstrap tooling often has to create them | ||
| ## first to land CRDs, StorageClasses or NetworkPolicies ahead of the operator, and helm refuses | ||
| ## to adopt a namespace it does not already own ("invalid ownership metadata"). | ||
| ## When disabling this, create the namespaces with the labels this chart would have set: | ||
| ## kubernetes.io/metadata.name: <name> | ||
| ## name: <name> | ||
| ## The platform's NetworkPolicies select namespaces by the `name` label. | ||
| createNamespaces: true |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
chart/apl/templates/00-namespace.yaml:5
- With the current top-level
if, switchinginstallation.createNamespacesfromtrue(default) tofalseon an existing release will remove these Namespace objects from the rendered manifests. Duringhelm upgrade, Helm will treat them as deleted resources and attempt to delete the Namespaces, which can cascade-delete everything inapl-operator,otomi, andapl-secrets. Consider keeping the Namespaces rendered when they are already owned by this release (so toggling the flag can’t accidentally trigger deletion).
{{- if .Values.installation.createNamespaces }}
apiVersion: v1
kind: Namespace
metadata:
name: apl-operator
📌 Summary
Fixes #3418.
The chart renders
apl-operator,otomiandapl-secretsfrom a bare00-namespace.yaml. When any of them already exists, the install fails outright:That's a common position to be in: bootstrap tooling frequently has to create a namespace before the operator installs, to land CRDs, StorageClasses or NetworkPolicies first.
Adds
installation.createNamespaces(defaulttrue, so nothing changes for existing installs). Set it tofalseand the chart leaves the namespaces alone.🔍 Reviewer Notes
kubernetes.io/metadata.name,name), because the platform's NetworkPolicies select namespaces by thenamelabel — dropping it fails in a way that's hard to trace back here.installation.alongsideskipOperatorDeployment, which is the same shape of knob.installationisadditionalProperties: truein values-schema, so the new key validates; I confirmedhelm lintpasses against the generatedvalues.schema.jsonboth with the flag set and unset.helm templaterenders 3 Namespaces by default and 0 with--set installation.createNamespaces=false.🧹 Checklist
helm lint/helm templateinlint:apl-chart