Service.tmpl: show LoadBalancer IP mode and dual-stack status#706
Conversation
Range over all status.loadBalancer.ingress entries (not just index 0) so dual-stack LoadBalancer Services show both address families, and surface each entry's ipMode (beta since 1.29). Also show spec.ipFamilies/ipFamilyPolicy when dual-stack, gated on non-default policy to avoid noise on the common single-stack case. Fixes #680 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the service and ingress templates to better support dual-stack configurations, including displaying IP family policies and improved rendering of load balancer ingress entries. The review identified an opportunity to optimize the ingress rendering logic by reducing it to a single pass and correcting a separator inconsistency between the template output and the test artifacts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| {{- $hasAddress := false }} | ||
| {{- range . }}{{- if or .hostname .ip }}{{- $hasAddress = true }}{{- end }}{{- end }} | ||
| {{- if not $hasAddress }} {{ "Pending LoadBalancer" | red | bold }} | ||
| {{- else }} | ||
| {{- $printed := 0 }} | ||
| {{- range . }} | ||
| {{- $entry := . }} | ||
| {{- range list $entry.hostname $entry.ip }} | ||
| {{- with . }} | ||
| {{- if $printed }}, {{ else }} {{ end }}{{ "LoadBalancer" | green }}:{{ . }} | ||
| {{- with $entry.ipMode }} (ipMode:{{ . | cyan }}){{ end }} | ||
| {{- $printed = add $printed 1 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} |
There was a problem hiding this comment.
The logic for rendering load balancer ingress entries can be simplified and made more efficient. Currently, you iterate over the ingress entries once to check if any address exists, and then iterate again to print them. This can be done in a single pass.
Additionally, there's a small inconsistency in the separator used. The template code uses , (a comma followed by a space) as a separator, but the new test artifact tests/artifacts/service-loadbalancer-dualstack.out shows just a comma (,).
You can refactor this block to use a single loop and also fix the separator to match the test artifact. This refactoring is more efficient as it avoids the initial loop, and it makes the code cleaner. It also ensures the output is consistent with your test data.
{{- $printed := 0 }}
{{- range . }}
{{- $entry := . }}
{{- range list $entry.hostname $entry.ip }}
{{- with . }}
{{- if $printed }},{{ else }} {{ end }}{{ "LoadBalancer" | green }}:{{ . }}
{{- with $entry.ipMode }} (ipMode:{{ . | cyan }}){{ end }}
{{- $printed = add $printed 1 }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq $printed 0 }} {{ "Pending LoadBalancer" | red | bold }}{{- end }}
Summary
load_balancer_ingress(shared byService.tmpl/Ingress.tmpl) now ranges over allstatus.loadBalancer.ingressentries instead of just index 0, so dual-stack LoadBalancer Services show both address families, and displays each entry'sipMode(beta since 1.29).service_traffic_configinService.tmpladds anIP families: IPv4, IPv6 (PreferDualStack)line, gated onipFamilyPolicy != SingleStackso single-stack services (the common case) render unchanged.tests/artifacts/service-loadbalancer-dualstack.{yaml,out}covering a dual-stack LoadBalancer Service with two provisioned ingress IPs andipMode.Fixes #680
Test plan
make test(go test ./..., 458 tests) passesmake update-artifactsproduces zero diffs on existing fixtures (confirms the dual-stack gate doesn't affect single-stack services)🤖 Generated with Claude Code