Skip to content

Commit 0dada84

Browse files
committed
apis: add traffic distribution and internal traffic policies fields
Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
1 parent b2223d7 commit 0dada84

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

config/crd/multicluster.x-k8s.io_serviceimports.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ spec:
103103
mycompany.com/my-custom-protocol.
104104
Field can be enabled with ServiceAppProtocol feature gate.
105105
type: string
106+
internalTrafficPolicy:
107+
description: |-
108+
InternalTrafficPolicy describes how nodes distribute service traffic they
109+
receive on the ClusterIP. If set to "Local", the proxy will assume that pods
110+
only want to talk to endpoints of the service on the same node as the pod,
111+
dropping the traffic if there are no local endpoints. The default value,
112+
"Cluster", uses the standard behavior of routing to all endpoints evenly
113+
(possibly modified by topology and other features).
114+
type: string
106115
name:
107116
description: |-
108117
The name of this port within the service. This must be a DNS_LABEL.
@@ -120,6 +129,15 @@ spec:
120129
The IP protocol for this port. Supports "TCP", "UDP", and "SCTP".
121130
Default is TCP.
122131
type: string
132+
trafficDistribution:
133+
description: |-
134+
TrafficDistribution offers a way to express preferences for how traffic
135+
is distributed to Service endpoints. Implementations can use this field
136+
as a hint, but are not required to guarantee strict adherence. If the
137+
field is not set, the implementation will apply its default routing
138+
strategy. If set to "PreferClose", implementations should prioritize
139+
endpoints that are in the same zone.
140+
type: string
123141
x-kubernetes-list-type: atomic
124142
sessionAffinity:
125143
description: |-

pkg/apis/v1alpha1/serviceexport.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ const (
265265
// annotations.
266266
ServiceExportReasonAnnotationsConflict ServiceExportConditionReason = "AnnotationsConflict"
267267

268+
// ServiceExportReasonInternalTrafficPolicyConflict is used with the "Conflict"
269+
// condition when the exported service has a conflict related to internal traffic policy.
270+
ServiceExportReasonInternalTrafficPolicyConflict ServiceExportConditionReason = "InternalTrafficPolicyConflict"
271+
272+
// ServiceExportReasonTrafficDistributionConflict is used with the "Conflict"
273+
// condition when the exported service has a conflict related to traffic distribution.
274+
ServiceExportReasonTrafficDistributionConflict ServiceExportConditionReason = "TrafficDistributionConflict"
275+
268276
// ServiceExportReasonNoConflicts is used with the "Conflict" condition
269277
// when the condition is False.
270278
ServiceExportReasonNoConflicts ServiceExportConditionReason = "NoConflicts"

pkg/apis/v1alpha1/serviceimport.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ type ServicePort struct {
120120

121121
// The port that will be exposed by this service.
122122
Port int32 `json:"port"`
123+
124+
// InternalTrafficPolicy describes how nodes distribute service traffic they
125+
// receive on the ClusterIP. If set to "Local", the proxy will assume that pods
126+
// only want to talk to endpoints of the service on the same node as the pod,
127+
// dropping the traffic if there are no local endpoints. The default value,
128+
// "Cluster", uses the standard behavior of routing to all endpoints evenly
129+
// (possibly modified by topology and other features).
130+
// +optional
131+
InternalTrafficPolicy *v1.ServiceInternalTrafficPolicy `json:"internalTrafficPolicy,omitempty"`
132+
133+
// TrafficDistribution offers a way to express preferences for how traffic
134+
// is distributed to Service endpoints. Implementations can use this field
135+
// as a hint, but are not required to guarantee strict adherence. If the
136+
// field is not set, the implementation will apply its default routing
137+
// strategy. If set to "PreferClose", implementations should prioritize
138+
// endpoints that are in the same zone.
139+
// +optional
140+
TrafficDistribution *string `json:"trafficDistribution,omitempty"`
123141
}
124142

125143
// ServiceImportStatus describes derived state of an imported service.

pkg/apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)