Skip to content

Fix loadBalancerSourceRanges rendering in service template#333

Merged
ChrisJBurns merged 4 commits into
backstage:mainfrom
verevoir:aigency/B5-17
Jun 1, 2026
Merged

Fix loadBalancerSourceRanges rendering in service template#333
ChrisJBurns merged 4 commits into
backstage:mainfrom
verevoir:aigency/B5-17

Conversation

@adsurg
Copy link
Copy Markdown
Contributor

@adsurg adsurg commented May 30, 2026

Closes #326.

What was wrong

charts/backstage/templates/service.yaml rendered service.loadBalancerSourceRanges by interpolating the slice directly:

loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}

When given a list of CIDRs, Go's default slice stringification produced output like loadBalancerSourceRanges: [192.168.0.0/16 10.0.0.0/8], which is not a valid value for the Kubernetes loadBalancerSourceRanges field — Kubernetes expects a YAML list.

The fix

Render the value with toYaml | nindent, matching the pattern already used for ipFamilies in the same file:

loadBalancerSourceRanges:
  {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}

Test coverage

Added charts/backstage/ci/loadBalancerSourceRanges-values.yaml so chart-testing exercises the field with a representative pair of CIDRs and service.type: LoadBalancer (the field only applies for LoadBalancer services).

@adsurg adsurg requested a review from a team as a code owner May 30, 2026 12:58
adsurg added 2 commits May 30, 2026 14:27
Signed-off-by: Adam Surgenor <adam@surgenor.me>
Signed-off-by: Adam Surgenor <adam@surgenor.me>
adsurg added 2 commits May 31, 2026 11:06
chart-testing requires a chart version bump when the chart changes; this covers the loadBalancerSourceRanges service-template fix.

Signed-off-by: Adam Surgenor <adam@surgenor.me>
…ixture

The 2.8.1 chart version bump requires the helm-docs-generated README version
badge to be regenerated — this is what the pre-commit hook flagged.

The loadBalancerSourceRanges CI fixture set service.type=LoadBalancer, which
never receives an external IP in the kind cluster used by `ct install`, so
`helm install --wait` timed out. Remove it: the rendering fix is a template-only
change, validated by `ct lint` / `helm template`. A render regression guard
belongs in helm-unittest, which this chart does not currently use.

Signed-off-by: Adam Surgenor <adam@surgenor.me>
@adsurg
Copy link
Copy Markdown
Contributor Author

adsurg commented Jun 1, 2026

Pushed a fix-up:

  • Regenerated the chart README.md for the 2.8.1 version bump (the helm-docs pre-commit hook flagged the stale version badge).
  • Removed charts/backstage/ci/loadBalancerSourceRanges-values.yaml. It sets service.type: LoadBalancer, which never receives an external IP in the kind cluster used by ct install, so helm install --wait timed out — that was the Test Charts failure, not the fix itself. The rendering change is template-only and is exercised by ct lint / helm template; a permanent render regression-guard would be better placed in helm-unittest, which this chart doesn't currently use. Happy to follow up with that separately if you'd like.

@ChrisJBurns
Copy link
Copy Markdown
Contributor

@adsurg Much appreciate for the fix!

@ChrisJBurns ChrisJBurns merged commit a33ab0e into backstage:main Jun 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect rendering of service.loadBalancerSourceRanges causes invalid Kubernetes Service spec

2 participants