Skip to content

Commit 01ffe07

Browse files
authored
Merge pull request kubernetes#2441 from andrewsykim/prr-2086
KEP-2086: alpha prod readiness review
2 parents 8d9379b + c0a9f9c commit 01ffe07

File tree

3 files changed

+62
-50
lines changed

3 files changed

+62
-50
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kep-number: 2086
2+
alpha:
3+
approver: "@wojtek-t"

keps/sig-network/2086-service-internal-traffic-policy/README.md

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
Items marked with (R) are required *prior to targeting to a milestone / release*.
3636

3737
- [X] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
38-
- [ ] (R) KEP approvers have approved the KEP status as `implementable`
39-
- [ ] (R) Design details are appropriately documented
40-
- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
41-
- [ ] (R) Graduation criteria is in place
42-
- [ ] (R) Production readiness review completed
38+
- [X] (R) KEP approvers have approved the KEP status as `implementable`
39+
- [X] (R) Design details are appropriately documented
40+
- [X] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
41+
- [X] (R) Graduation criteria is in place
42+
- [X] (R) Production readiness review completed
4343
- [ ] Production readiness review approved
4444
- [ ] "Implementation History" section is up-to-date for milestone
4545
- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
@@ -56,40 +56,37 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
5656

5757
## Summary
5858

59-
Add a new field `spec.internalTrafficPolicy` to Service that allows node-local routing for Service internal traffic.
59+
Add a new field `spec.trafficPolicy` to Service that allows node-local and topology-aware routing for Service traffic.
6060

6161
## Motivation
6262

63-
Internal traffic routed to a Service is not topology aware today. The [Topolgoy Aware Subsetting](/keps/sig-network/2004-topology-aware-subsetting)
64-
KEP addresses topology aware routing for Services by subsetting endpoints to dedicated EndpointSlices.
65-
While this approach works for the standard zone/region topologies, it wouldn't work for node level
66-
topologies since that would require an EndpointSlice per node. In larger clusters this wouldn't scale well.
67-
68-
This KEP proposes a new field in Service to treat node-local topologies as a first class concept in Service similar
69-
to `externalTrafficPolicy`. This addresses the node-local use-case for Service while avoiding EndpointSlice
70-
subsetting per node.
63+
Internal traffic routed to a Service has always been randomly distributed to all endpoints.
64+
This KEP proposes a new API in Service to address use-cases such as node-local and topology aware routing
65+
for internal Service traffic.
7166

7267
### Goals
7368

74-
* Allow internal Service traffic to be routed to node-local endpoints.
69+
* Allow internal Service traffic to be routed to node-local or topology-aware endpoints.
7570
* Default behavior for internal Service traffic should not change.
7671

7772
### Non-Goals
7873

79-
* Topology aware routing for zone/region topologies.
74+
* Topology aware routing for zone/region topologies -- while this field enables this feature, this KEP only covers node-local routing.
75+
See the Topology Aware Hints KEP for more details.
8076

8177
## Proposal
8278

83-
Introduce a new field in Service `spec.internalTrafficPolicy`. The field will have 3 codified values:
79+
Introduce a new field in Service `spec.trafficPolicy`. The field will have 4 codified values:
8480
1. Cluster (default): route to all cluster-wide endpoints (or use topology aware subsetting if enabled).
81+
2. Topology: route to endpoints using topology-aware routing. See Topology Aware Hints KEP for more details.
8582
2. PreferLocal: route to node-local endpoints if it exists, otherwise fallback to behavior from Cluster.
8683
3. Local: only route to node-local endpoints, drop otherwise.
8784

88-
A feature gate `ServiceInternalTrafficPolicy` will also be introduced for the alpha stage of this feature.
89-
The `internalTrafficPolicy` field cannot be set on Service during the alpha stage unless the feature gate is enabled.
85+
A feature gate `ServiceTrafficPolicy` will also be introduced for the alpha stage of this feature.
86+
The `trafficPolicy` field cannot be set on Service during the alpha stage unless the feature gate is enabled.
9087
During the Beta stage, the feature gate will be on by default.
9188

92-
The `internalTrafficPolicy` field will not apply for headless Services or Services of type `ExternalName`.
89+
The `trafficPolicy` field will not apply for headless Services or Services of type `ExternalName`.
9390

9491
### User Stories (Optional)
9592

@@ -115,56 +112,68 @@ Proposed addition to core v1 API:
115112
type ServiceInternalTrafficPolicyType string
116113

117114
const (
118-
ServiceInternalTrafficPolicyTypeCluster ServiceInternalTrafficPolicyType = "Cluster"
119-
ServiceInternalTrafficPolicyTypePreferLocal ServiceInternalTrafficPolicyType = "PreferLocal"
120-
ServiceInternalTrafficPolicyTypeLocal ServiceInternalTrafficPolicyType = "Local"
115+
ServiceTrafficPolicyTypeCluster ServiceTrafficPolicyType = "Cluster"
116+
ServiceTrafficPolicyTypeTopology ServiceTrafficPolicyType = "Topology"
117+
ServiceTrafficPolicyTypePreferLocal ServiceTrafficPolicyType = "PreferLocal"
118+
ServiceTrafficPolicyTypeLocal ServiceTrafficPolicyType = "Local"
121119
)
122120

123121
// ServiceSpec describes the attributes that a user creates on a service.
124122
type ServiceSpec struct {
125123
...
126124
...
127125

128-
// internalTrafficPolicy denotes if the internal traffic for a Service should route
129-
// to cluster-wide endpoints or node-local endpoints. "Cluster" routes internal traffic
130-
// to a Service to all cluster-wide endpoints. "PreferLocal" will route internal traffic
131-
// to node-local endpoints if one exists, otherwise it will fallback to the same behavior
132-
// as "Cluster". "Local" routes traffic to node-local endpoints only, traffic is dropped
133-
// if no node-local endpoints are ready.
134-
InternalTrafficPolicy ServiceInternalTrafficPolicyType `json:"internalTrafficPolicy,omitempty"`
126+
// trafficPolicy denotes if the traffic for a Service should route
127+
// to cluster-wide endpoints or node-local endpoints. "Cluster" routes traffic
128+
// to a Service to all cluster-wide endpoints. "Topology" routes traffic based on
129+
// topology hints. "PreferLocal" will route internal traffic to node-local endpoints
130+
// if one exists, otherwise it will fallback to the same behavior as "Cluster".
131+
// "Local" routes traffic to node-local endpoints only, traffic is dropped
132+
// if no node-local endpoints are ready. When externalTrafficPolicy is "Cluster",
133+
// traffic from external sources will be routed based on the trafficPolicy. When
134+
// externalTrafficPolicy is "Local", trafficPolicy is ignored for traffic from
135+
// external sources.
136+
// +optional
137+
// +feature-gate=ServiceTrafficPolicy
138+
TrafficPolicy ServiceTrafficPolicyType `json:"trafficPolicy,omitempty"`
135139
}
136140
```
137141

142+
This new field will intersect with externalTrafficPolicy in the following ways:
143+
* if `externalTrafficPolicy=Cluster`, traffic will be routed based on `trafficPolicy` for external sources
144+
* if `externalTrafficPolicy=Local`, `externalTrafficPolicy` will take precedent over `trafficPolicy`, but only for external sources.
145+
138146
Proposed changes to kube-proxy:
139-
* when `internalTrafficPolicy=Cluster`, default to existing behavior today.
140-
* when `internalTrafficPolicy=PreferLocal`, route to endpoints in EndpointSlice that matches the local node's topology (topology defined by `kubernetes.io/hostname`),
147+
* when `trafficPolicy=Cluster`, default to existing behavior today.
148+
* when `trafficPolicy=Topology`, use topology hints from EndpointSlice API.
149+
* when `trafficPolicy=PreferLocal`, route to endpoints in EndpointSlice that matches the local node's topology (topology defined by `kubernetes.io/hostname`),
141150
fall back to "Cluster" behavior if there are no local endpoints.
142-
* when `internalTrafficPolicy=Local`, route to endpoints in EndpointSlice that maches the local node's topology, drop traffic if none exist.
151+
* when `trafficPolicy=Local`, route to endpoints in EndpointSlice that maches the local node's topology, drop traffic if none exist.
143152

144153
### Test Plan
145154

146155
Unit tests:
147-
* unit tests validating API strategy/validation for when `internalTrafficPolicy` is set on Service.
148-
* unit tests exercising kube-proxy behavior when `internalTrafficPolicy` is set to all possible values.
156+
* unit tests validating API strategy/validation for when `trafficPolicy` is set on Service.
157+
* unit tests exercising kube-proxy behavior when `trafficPolicy` is set to all possible values.
149158

150159
E2E test:
151-
* e2e tests validating default behavior with kube-proxy did not change when `internalTrafficPolicy` defaults to `Cluster`. Existing tests should cover this.
152-
* e2e tests validating that traffic is preferred to local endpoints when `internalTrafficPolicy` is set to `PreferLocal`.
153-
* e2e tests validating that traffic is only sent to node-local endpoints when `internalTrafficPolicy` is set to `Local`.
160+
* e2e tests validating default behavior with kube-proxy did not change when `trafficPolicy` defaults to `Cluster`. Existing tests should cover this.
161+
* e2e tests validating that traffic is preferred to local endpoints when `trafficPolicy` is set to `PreferLocal`.
162+
* e2e tests validating that traffic is only sent to node-local endpoints when `trafficPolicy` is set to `Local`.
154163

155164
### Graduation Criteria
156165

157166
Alpha:
158-
* feature gate `ServiceInternalTrafficPolicy` _must_ be enabled for apiserver to accept values for `spec.internalTrafficPolicy`. Otherwise field is dropped.
159-
* kube-proxy handles traffic routing for 3 initial internal traffic policies `Cluster`, `PreferLocal` and `Local`.
167+
* feature gate `ServiceTrafficPolicy` _must_ be enabled for apiserver to accept values for `spec.trafficPolicy`. Otherwise field is dropped.
168+
* kube-proxy handles traffic routing for 4 initial internal traffic policies `Cluster`, `Topology`, `PreferLocal` and `Local`.
160169
* Unit tests as defined in "Test Plan" section above. E2E tests are nice to have but not required for Alpha.
161170

162171

163172
### Upgrade / Downgrade Strategy
164173

165-
* The `internalTrafficPolicy` field will be off by default during the alpha stage but can handle any existing Services that has the field already set.
174+
* The `trafficPolicy` field will be off by default during the alpha stage but can handle any existing Services that has the field already set.
166175
This ensures n-1 apiservers can handle the new field on downgrade.
167-
* On upgrade, if the feature gate is enabled there should be no changes in the behavior since the default value for `internalTrafficPolicy` is `Cluster`.
176+
* On upgrade, if the feature gate is enabled there should be no changes in the behavior since the default value for `trafficPolicy` is `Cluster`.
168177

169178
### Version Skew Strategy
170179

@@ -178,7 +187,7 @@ _This section must be completed when targeting alpha to a release._
178187

179188
* **How can this feature be enabled / disabled in a live cluster?**
180189
- [X] Feature gate (also fill in values in `kep.yaml`)
181-
- Feature gate name: `ServiceInternalTrafficPolicy`
190+
- Feature gate name: `ServiceTrafficPolicy`
182191
- Components depending on the feature gate: kube-apiserver, kube-proxy
183192
- [ ] Other
184193
- Describe the mechanism:
@@ -189,7 +198,7 @@ _This section must be completed when targeting alpha to a release._
189198

190199
* **Does enabling the feature change any default behavior?**
191200

192-
No, enabling the feature does not change any default behavior since the default value of `internalTrafficPolicy` is `Cluster`.
201+
No, enabling the feature does not change any default behavior since the default value of `trafficPolicy` is `Cluster`.
193202

194203
* **Can the feature be disabled once it has been enabled (i.e. can we roll back
195204
the enablement)?**
@@ -198,11 +207,11 @@ Yes, the feature gate can be disabled, but Service resource that have set the ne
198207

199208
* **What happens if we reenable the feature if it was previously rolled back?**
200209

201-
New Services should be able to set the `internalTrafficPolicy` field. Existing Services that have the field set already should not be impacted.
210+
New Services should be able to set the `trafficPolicy` field. Existing Services that have the field set already should not be impacted.
202211

203212
* **Are there any tests for feature enablement/disablement?**
204213

205-
There will be unit tests to verify that apiserver will drop the field when the `ServiceInternalTrafficPolicy` feature gate is disabled.
214+
There will be unit tests to verify that apiserver will drop the field when the `ServiceTrafficPolicy` feature gate is disabled.
206215

207216
### Rollout, Upgrade and Rollback Planning
208217

@@ -304,7 +313,7 @@ resource usage (CPU, RAM, disk, IO, ...) in any components?**
304313

305314
Any increase in CPU usage by kube-proxy to calculate node-local topology will likely
306315
be offset by reduced iptable rules it needs to sync when using `PreferLocal` or `Local`
307-
internal traffic policies.
316+
traffic policies.
308317

309318
### Troubleshooting
310319

@@ -348,7 +357,7 @@ for large clusters since that would require an EndpointSlice resource per node.
348357

349358
### Bool Field For Node Local
350359

351-
Instead of `internalTrafficPolicy` field with codified values, a bool field can be used to enable node-local routing.
360+
Instead of `trafficPolicy` field with codified values, a bool field can be used to enable node-local routing.
352361
While this is simpler, it is not expressive enough for the `PreferLocal` use-case where traffic should ideally go
353362
to a local endpoint, but be routed somewhere else otherwise.
354363

keps/sig-network/2086-service-internal-traffic-policy/kep.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ stage: alpha
2323
# The most recent milestone for which work toward delivery of this KEP has been
2424
# done. This can be the current (upcoming) milestone, if it is being actively
2525
# worked on.
26-
# latest-milestone: "v1.21"
26+
latest-milestone: "v1.21"
2727

2828
# The milestone at which this feature was, or is targeted to be, at each stage.
2929
milestone:
@@ -34,7 +34,7 @@ milestone:
3434
# The following PRR answers are required at alpha release
3535
# List the feature gate name and the components for which it must be enabled
3636
feature-gates:
37-
- name: ServiceInternalTrafficPolicy
37+
- name: ServiceITrafficPolicy
3838
components:
3939
- kube-apiserver
4040
- kube-proxy

0 commit comments

Comments
 (0)