Skip to content

Service.tmpl: show LoadBalancer IP mode and dual-stack status#706

Merged
bergerx merged 1 commit into
masterfrom
service-dualstack-lb-ipmode
Jul 17, 2026
Merged

Service.tmpl: show LoadBalancer IP mode and dual-stack status#706
bergerx merged 1 commit into
masterfrom
service-dualstack-lb-ipmode

Conversation

@bergerx

@bergerx bergerx commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • load_balancer_ingress (shared by Service.tmpl/Ingress.tmpl) now ranges over all status.loadBalancer.ingress entries instead of just index 0, so dual-stack LoadBalancer Services show both address families, and displays each entry's ipMode (beta since 1.29).
  • service_traffic_config in Service.tmpl adds an IP families: IPv4, IPv6 (PreferDualStack) line, gated on ipFamilyPolicy != SingleStack so single-stack services (the common case) render unchanged.
  • New static fixture tests/artifacts/service-loadbalancer-dualstack.{yaml,out} covering a dual-stack LoadBalancer Service with two provisioned ingress IPs and ipMode.

Fixes #680

Test plan

  • make test (go test ./..., 458 tests) passes
  • make update-artifacts produces zero diffs on existing fixtures (confirms the dual-stack gate doesn't affect single-stack services)
  • Manually verified both-hostname-and-ip ingress entries still render both addresses (preserves prior behavior)
  • CI e2e suite (local pre-push e2e run hit unrelated resource-contention flakiness on this machine — different unrelated tests failed on two consecutive local retries; none touch Service/Ingress LoadBalancer rendering)

🤖 Generated with Claude Code

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +93 to 108
{{- $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 }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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 }}

@bergerx
bergerx merged commit 7dd344c into master Jul 17, 2026
2 checks passed
@bergerx
bergerx deleted the service-dualstack-lb-ipmode branch July 17, 2026 22:28
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.

Service.tmpl: show dual-stack status and LoadBalancer IP mode

1 participant