helm/v2-alpha: manager templating rewrites sidecar values
What happened
The Helm plugin applies manager-related replacements across the whole rendered Deployment.
As a result, matching values in sidecars can also be rewritten.
Example:
- name: proxy
livenessProbe:
httpGet:
path: /healthz
port: 9440
ports:
- containerPort: 9440
name: healthBecomes:
- name: proxy
livenessProbe:
httpGet:
path: /healthz
port: {{ .Values.manager.healthProbe.port }}
ports:
- containerPort: {{ .Values.manager.healthProbe.port }}
name: healthChanging manager.healthProbe.port then also changes the sidecar.
Expected behavior
Only values from the manager container should use manager chart values.
Sidecars should remain unchanged.
Cause
The rules in:
pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/templater/appliers/ports.gomatch across the whole Deployment instead of only the manager container.
Webhook detection has the same problem because it also checks the full rendered document.
Suggested approach
We might want to address this at the design level instead of fixing each port rule separately.
Ideally, all manager-specific templating should be scoped to the manager container, including:
- ports
- probes
- arguments
- metrics
- webhooks
- future manager values
The templater could reuse the same manager-container lookup already used by the extractor.
Tests should cover a Deployment with a manager and a sidecar and verify that only the manager is templated.
Source: kubernetes-sigs/kubebuilder