Skip to content

Commit e974cb7

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

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
@@ -72,6 +72,15 @@ spec:
7272
- ports
7373
- type
7474
properties:
75+
internalTrafficPolicy:
76+
description: |-
77+
InternalTrafficPolicy describes how nodes distribute service traffic they
78+
receive on the ClusterIP. If set to "Local", the proxy will assume that pods
79+
only want to talk to endpoints of the service on the same node as the pod,
80+
dropping the traffic if there are no local endpoints. The default value,
81+
"Cluster", uses the standard behavior of routing to all endpoints evenly
82+
(possibly modified by topology and other features).
83+
type: string
7584
ips:
7685
description: ip will be used as the VIP for this service when type is ClusterSetIP.
7786
type: array
@@ -145,6 +154,15 @@ spec:
145154
Default value is 10800(for 3 hours).
146155
type: integer
147156
format: int32
157+
trafficDistribution:
158+
description: |-
159+
TrafficDistribution offers a way to express preferences for how traffic
160+
is distributed to Service endpoints. Implementations can use this field
161+
as a hint, but are not required to guarantee strict adherence. If the
162+
field is not set, the implementation will apply its default routing
163+
strategy. If set to "PreferClose", implementations should prioritize
164+
endpoints that are in the same zone.
165+
type: string
148166
type:
149167
description: |-
150168
type defines the type of this service.

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
@@ -84,6 +84,24 @@ type ServiceImportSpec struct {
8484
// sessionAffinityConfig contains session affinity configuration.
8585
// +optional
8686
SessionAffinityConfig *v1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
87+
88+
// InternalTrafficPolicy describes how nodes distribute service traffic they
89+
// receive on the ClusterIP. If set to "Local", the proxy will assume that pods
90+
// only want to talk to endpoints of the service on the same node as the pod,
91+
// dropping the traffic if there are no local endpoints. The default value,
92+
// "Cluster", uses the standard behavior of routing to all endpoints evenly
93+
// (possibly modified by topology and other features).
94+
// +optional
95+
InternalTrafficPolicy *v1.ServiceInternalTrafficPolicy `json:"internalTrafficPolicy,omitempty"`
96+
97+
// TrafficDistribution offers a way to express preferences for how traffic
98+
// is distributed to Service endpoints. Implementations can use this field
99+
// as a hint, but are not required to guarantee strict adherence. If the
100+
// field is not set, the implementation will apply its default routing
101+
// strategy. If set to "PreferClose", implementations should prioritize
102+
// endpoints that are in the same zone.
103+
// +optional
104+
TrafficDistribution *string `json:"trafficDistribution,omitempty"`
87105
}
88106

89107
// ServicePort represents the port on which the service is exposed

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)