namespace added to Helm Chart#345
Conversation
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge — all namespace-scoped resources now emit an explicit namespace field, cluster-scoped RBAC resources are correctly unchanged, and the ServiceMonitor's user-configurable namespace is deliberately preserved. The change is mechanical and consistent: every namespace-scoped resource across all three sub-charts gets the same unconditional namespace addition. The RBAC ClusterRoleBindings already reference .Release.Namespace in their subjects[].namespace field. The configmap-mounts.yaml correctly uses $.Release.Namespace for the root context inside a range loop. All 8 golden test files are updated and pass. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[helm install/upgrade] --> B{Release.Namespace}
B --> C[namespace-scoped resources]
C --> D[ConfigMap]
C --> E[Deployment / DaemonSet]
C --> F[ServiceAccount]
C --> G[Service / HTTPRoute / Ingress]
C --> I[Test Pods]
D & E & F & G & I --> J[metadata.namespace set to Release.Namespace]
B --> K[cluster-scoped resources]
K --> L[ClusterRole]
K --> M[ClusterRoleBinding]
L & M --> N[no namespace field added]
B --> O[ServiceMonitor]
O --> P[namespace set to Values.serviceMonitor.namespace]
J --> Q[GitOps tools apply to correct namespace]
N --> Q
P --> R[Prometheus Operator monitoring namespace]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[helm install/upgrade] --> B{Release.Namespace}
B --> C[namespace-scoped resources]
C --> D[ConfigMap]
C --> E[Deployment / DaemonSet]
C --> F[ServiceAccount]
C --> G[Service / HTTPRoute / Ingress]
C --> I[Test Pods]
D & E & F & G & I --> J[metadata.namespace set to Release.Namespace]
B --> K[cluster-scoped resources]
K --> L[ClusterRole]
K --> M[ClusterRoleBinding]
L & M --> N[no namespace field added]
B --> O[ServiceMonitor]
O --> P[namespace set to Values.serviceMonitor.namespace]
J --> Q[GitOps tools apply to correct namespace]
N --> Q
P --> R[Prometheus Operator monitoring namespace]
Reviews (6): Last reviewed commit: "ran make chart-test-update-golden" | Re-trigger Greptile |
| {{- if ne .Release.Namespace "default" }} | ||
| namespace: {{ .Release.Namespace }} | ||
| {{- end}} |
There was a problem hiding this comment.
Non-standard conditional omits namespace for
default
Every changed template guards the namespace field with {{- if ne .Release.Namespace "default" }}, which means rendering with --namespace default (or no --namespace flag) produces manifests without an explicit namespace: field. When those manifests are applied through a GitOps tool such as ArgoCD or Flux, the resource is placed into whatever the cluster's contextual default namespace is rather than default — recreating the very bug (#344) this PR intends to fix, just scoped to that one namespace.
The Helm-recommended pattern is to emit the namespace unconditionally: namespace: {{ .Release.Namespace }}. The same conditional appears in all 11 files changed by this PR.
There was a problem hiding this comment.
This was to retain compatibility with how helm template functioned before.
If user specifies namespace=default or omits it, they are free to kubectl apply to any namespace they choose.
If namespace: default is in the manifest, it must be applied to the default namespace.
Can remove the conditional if we are fine with changing the default behavior.
|
Thanks for filing both the issue and the fix, @kevin-kho — the direction looks right to me. A few items though: 1. Conditional guard should be removed The current pattern: {{- if ne .Release.Namespace "default" }}
namespace: {{ .Release.Namespace }}
{{- end }}re-introduces the original bug for anyone deploying to the namespace: {{ .Release.Namespace }}Kubernetes accepts an explicit 2. Test Pod template coverage
3. Gap created by recent merge PR #347 (merged after this PR was filed) added metadata:
name: {{ include "node-data-broker.configMapMountName" (dict "root" $ "name" .name) }}
namespace: {{ $.Release.Namespace }}4. Rebase needed The PR is based on |
305166a to
389b030
Compare
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
Signed-off-by: Kevin Ho <kevinkh08@gmail.com>
3968c50 to
a06a005
Compare
Description
Adds
metadata.namespaceto namespace scoped resources in the Helm Chart Templates.Addresses #344
Checklist
git commit -s).