@@ -384,6 +384,40 @@ The IP address that you choose must be a valid IPv4 or IPv6 address from within
384
384
If you try to create a Service with an invalid clusterIP address value, the API
385
385
server will return a 422 HTTP status code to indicate that there's a problem.
386
386
387
+ # # Traffic policies
388
+
389
+ # ## External traffic policy
390
+
391
+ You can set the `spec.externalTrafficPolicy` field to control how traffic from external sources is routed.
392
+ Valid values are `Cluster` and `Local`. Set the field to `Cluster` to route external traffic to all ready endpoints
393
+ and `Local` to only route to ready node-local endpoints. If the traffic policy is `Local` and there are are no node-local
394
+ endpoints, the kube-proxy does not forward any traffic for the relevant Service.
395
+
396
+ {{< note >}}
397
+ {{< feature-state for_k8s_version="v1.22" state="alpha" >}}
398
+ If you enable the `ProxyTerminatingEndpoints`
399
+ [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
400
+ ` ProxyTerminatingEndpoints` for the kube-proxy, the kube-proxy checks if the node
401
+ has local endpoints and whether or not all the local endpoints are marked as terminating.
402
+ If there are local endpoints and **all** of those are terminating, then the kube-proxy ignores
403
+ any external traffic policy of `Local`. Instead, whilst the node-local endpoints remain as all
404
+ terminating, the kube-proxy forwards traffic for that Service to healthy endpoints elsewhere,
405
+ as if the external traffic policy were set to `Cluster`.
406
+ This forwarding behavior for terminating endpoints exists to allow external load balancers to
407
+ gracefully drain connections that are backed by `NodePort` Services, even when the health check
408
+ node port starts to fail. Otherwise, traffic can be lost between the time a node is still in the node pool of a load
409
+ balancer and traffic is being dropped during the termination period of a pod.
410
+ {{< /note >}}
411
+
412
+ # ## Internal traffic policy
413
+
414
+ {{< feature-state for_k8s_version="v1.22" state="beta" >}}
415
+
416
+ You can set the `spec.internalTrafficPolicy` field to control how traffic from internal sources is routed.
417
+ Valid values are `Cluster` and `Local`. Set the field to `Cluster` to route internal traffic to all ready endpoints
418
+ and `Local` to only route to ready node-local endpoints. If the traffic policy is `Local` and there are are no node-local
419
+ endpoints, traffic is dropped by kube-proxy.
420
+
387
421
# # Discovering services
388
422
389
423
Kubernetes supports 2 primary modes of finding a Service - environment
0 commit comments