Skip to content

Commit 722d7bc

Browse files
authored
Merge pull request #29156 from PI-Victor/docs/service-traffic-policies
Document the ProxyTerminatingEndpoints feature
2 parents 6b03513 + 02fbd11 commit 722d7bc

File tree

1 file changed

+34
-0
lines changed
  • content/en/docs/concepts/services-networking

1 file changed

+34
-0
lines changed

content/en/docs/concepts/services-networking/service.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,40 @@ The IP address that you choose must be a valid IPv4 or IPv6 address from within
385385
If you try to create a Service with an invalid clusterIP address value, the API
386386
server will return a 422 HTTP status code to indicate that there's a problem.
387387

388+
## Traffic policies
389+
390+
### External traffic policy
391+
392+
You can set the `spec.externalTrafficPolicy` field to control how traffic from external sources is routed.
393+
Valid values are `Cluster` and `Local`. Set the field to `Cluster` to route external traffic to all ready endpoints
394+
and `Local` to only route to ready node-local endpoints. If the traffic policy is `Local` and there are are no node-local
395+
endpoints, the kube-proxy does not forward any traffic for the relevant Service.
396+
397+
{{< note >}}
398+
{{< feature-state for_k8s_version="v1.22" state="alpha" >}}
399+
If you enable the `ProxyTerminatingEndpoints`
400+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
401+
`ProxyTerminatingEndpoints` for the kube-proxy, the kube-proxy checks if the node
402+
has local endpoints and whether or not all the local endpoints are marked as terminating.
403+
If there are local endpoints and **all** of those are terminating, then the kube-proxy ignores
404+
any external traffic policy of `Local`. Instead, whilst the node-local endpoints remain as all
405+
terminating, the kube-proxy forwards traffic for that Service to healthy endpoints elsewhere,
406+
as if the external traffic policy were set to `Cluster`.
407+
This forwarding behavior for terminating endpoints exists to allow external load balancers to
408+
gracefully drain connections that are backed by `NodePort` Services, even when the health check
409+
node port starts to fail. Otherwise, traffic can be lost between the time a node is still in the node pool of a load
410+
balancer and traffic is being dropped during the termination period of a pod.
411+
{{< /note >}}
412+
413+
### Internal traffic policy
414+
415+
{{< feature-state for_k8s_version="v1.22" state="beta" >}}
416+
417+
You can set the `spec.internalTrafficPolicy` field to control how traffic from internal sources is routed.
418+
Valid values are `Cluster` and `Local`. Set the field to `Cluster` to route internal traffic to all ready endpoints
419+
and `Local` to only route to ready node-local endpoints. If the traffic policy is `Local` and there are no node-local
420+
endpoints, traffic is dropped by kube-proxy.
421+
388422
## Discovering services
389423

390424
Kubernetes supports 2 primary modes of finding a Service - environment

0 commit comments

Comments
 (0)