@@ -156,7 +156,7 @@ the successors of `topologyKeys` and allow implementations to be more flexible.
156
156
* ** Limitation:** Lacks failover; traffic is dropped if no local endpoint exists.
157
157
158
158
Note that while the initial proposal of InternalTrafficPolicy proposed a
159
- Local policy, it was dropped later on. This meant that now
159
+ ` PreferLocal ` policy, it was dropped later on. This meant that now
160
160
TopologyAwareRouting in conjunction with InternalTrafficPolicy didn’t exactly
161
161
allow users to express a much desired use case from topologyKeys which is
162
162
"prefer node-local, failover to same zone, then route anywhere" While this
@@ -940,6 +940,57 @@ like `routingPreference` might be a better option is:
940
940
preferences as hints, allowing for sophisticated, implementation-specific
941
941
algorithms that can evolve over time.
942
942
943
+ ### Reuse Pod Topology Spread Constraints for Traffic Distribution
944
+
945
+ [ Pod Topology Spread
946
+ Constraints] ( https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ )
947
+ offer a powerful mechanism to influence how Kubernetes schedules pods across
948
+ topology domains (like zones, nodes, or regions). Pod Topology Spread
949
+ Constraints can be re-used to guide traffic to stay within the same topology
950
+ domain as the originating pod.
951
+
952
+ Challenges:
953
+
954
+ * ** Conflicting Domains:** Services often span multiple pods, which might belong to
955
+ different topology domains (e.g., a Service with pods constrained to both
956
+ node-level and zone-level Pod Topology Spread Constraints). Resolving routing
957
+ conflicts in such scenarios would require complex decision-making.
958
+
959
+ * ** Data Plane Overhead:** Informing data planes like kube-proxy of detailed Topology Spread
960
+ Constraints information for each pod could significantly increase the complexity
961
+ of communication between the control plane and data plane. This might
962
+ necessitate changes to resources like ` EndpointSlices ` to communicate this extra
963
+ information to the data plane (or alternatively, have the data-palne watching
964
+ all pods across all nodes, which also tends to be a bad idea.)
965
+
966
+ The potential benefits of traffic routing based solely on Topology Spread
967
+ Constraints might not outweigh the added implementation and configuration
968
+ complexity.
969
+
970
+ A dedicated ` routingPreference ` fields gets us:
971
+
972
+ * ** Clear Intent:** The ` routingPreference ` field provides an explicit way for
973
+ users to signal desired traffic patterns, focusing solely on traffic
974
+ distribution.
975
+
976
+ * ** Implementation Flexibility:** Implementations can intelligently incorporate
977
+ TSC information (if desired) alongside other factors like latency, load, or
978
+ custom heuristics to optimize routing decisions.
979
+
980
+ #### Complementary Use of Pod Topology Spread Constraints and routingPreference
981
+
982
+ Rather than having to choose between the two, Pod Topology Spread Constraints
983
+ and ` routingPreference ` can offer slightly better and resilient traffic
984
+ distribution when used in conjunction.
985
+
986
+ * Users can set ` routingPreference ` to ` Zone ` to express the preference for
987
+ keeping traffic within the same zone as the client.
988
+ * Then, they can configure Pod Topology Spread Constraints to Ensure balanced
989
+ pod distribution across zones, maximizing the likelihood that the
990
+ ` routingPreference ` can be satisfied and reduce (although not completely
991
+ eliminate) chances of overload for a single zone.
992
+
993
+
943
994
## Infrastructure Needed (Optional)
944
995
945
996
N/A
0 commit comments