Skip to content

Add TrafficDistribution field to describe service output #1736

Closed
kubernetes/kubernetes
#131491
@08volt

Description

@08volt

Motivation:

Kubernetes 1.31 introduced the TrafficDistribution field within the Service specification (spec.trafficDistribution). This field allows users to specify preferences for how traffic should be distributed among endpoints, such as the PreferClose option.

The official documentation describing this feature is here:
https://kubernetes.io/docs/reference/networking/virtual-ips/#traffic-distribution

Currently, kubectl describe service <service-name> does not display this field, even if it is set on the Service object.

Problem:

Users who configure spec.trafficDistribution on their Services lack a straightforward way to view or verify the applied setting using the standard kubectl describe command. They must resort to fetching the full YAML/JSON (kubectl get svc <service-name> -o yaml) and manually inspecting the spec.

Proposed Solution:

Modify the output of kubectl describe service to include the TrafficDistribution field when it is present and non-empty in the Service spec.

The output could look similar to how other optional spec fields like ExternalTrafficPolicy or InternalTrafficPolicy are displayed, for example:

...
Session Affinity: None
External Traffic Policy: Cluster
Internal Traffic Policy: Cluster
Traffic Distribution: PreferClose # <-- Add this line when field is set
HealthCheck NodePort:
Events:
...

Benefits:

  • Increased Visibility: Provides users with a complete view of the Service configuration directly within the commonly used describe output.
  • Easier Debugging: Helps users quickly verify the traffic distribution settings when diagnosing service routing behavior.
  • Improved User Experience: Aligns kubectl describe with the API capabilities introduced in recent Kubernetes versions.

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions