Enabling Service Topology
Kubernetes v1.21 [deprecated]
This feature, specifically the alpha topologyKeys
field, is deprecated since
Kubernetes v1.21.
Topology Aware Hints,
introduced in Kubernetes v1.21, provide similar functionality.
Service Topology enables a Service to route traffic based upon the Node topology of the cluster. For example, a service can specify that traffic be preferentially routed to endpoints that are on the same Node as the client, or in the same availability zone.
Before you begin
You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:
Your Kubernetes server must be at or later than version 1.17. To check the version, enterkubectl version
.
The following prerequisites are needed in order to enable topology aware service routing:
- Kubernetes v1.17 or later
- Configure kube-proxy to run in iptables mode or IPVS mode
Enable Service Topology
Kubernetes v1.21 [deprecated]
To enable service topology, enable the ServiceTopology
feature gate for all Kubernetes components:
--feature-gates="ServiceTopology=true`
What's next
- Read about Topology Aware Hints, the replacement for the
topologyKeys
field. - Read about EndpointSlices
- Read about the Service Topology concept
- Read Connecting Applications with Services