mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
kube-proxy: gate topology correctly
This commit is contained in:
parent
1ab1b0af6e
commit
cf532a8e36
@ -145,6 +145,9 @@ func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeLabels m
|
|||||||
// * All of the endpoints for this Service have a topology hint
|
// * All of the endpoints for this Service have a topology hint
|
||||||
// * At least one endpoint for this Service is hinted for this node's zone.
|
// * At least one endpoint for this Service is hinted for this node's zone.
|
||||||
func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[string]string) bool {
|
func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[string]string) bool {
|
||||||
|
if !utilfeature.DefaultFeatureGate.Enabled(features.TopologyAwareHints) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
hintsAnnotation := svcInfo.HintsAnnotation()
|
hintsAnnotation := svcInfo.HintsAnnotation()
|
||||||
if hintsAnnotation != "Auto" && hintsAnnotation != "auto" {
|
if hintsAnnotation != "Auto" && hintsAnnotation != "auto" {
|
||||||
if hintsAnnotation != "" && hintsAnnotation != "Disabled" && hintsAnnotation != "disabled" {
|
if hintsAnnotation != "" && hintsAnnotation != "Disabled" && hintsAnnotation != "disabled" {
|
||||||
|
@ -91,6 +91,20 @@ func TestCategorizeEndpoints(t *testing.T) {
|
|||||||
clusterEndpoints: sets.NewString("10.1.2.3:80", "10.1.2.4:80", "10.1.2.5:80", "10.1.2.6:80"),
|
clusterEndpoints: sets.NewString("10.1.2.3:80", "10.1.2.4:80", "10.1.2.5:80", "10.1.2.6:80"),
|
||||||
localEndpoints: nil,
|
localEndpoints: nil,
|
||||||
}, {
|
}, {
|
||||||
|
name: "hints disabled, hints annotation == auto",
|
||||||
|
hintsEnabled: false,
|
||||||
|
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
||||||
|
serviceInfo: &BaseServiceInfo{hintsAnnotation: "auto"},
|
||||||
|
endpoints: []Endpoint{
|
||||||
|
&BaseEndpointInfo{Endpoint: "10.1.2.3:80", ZoneHints: sets.NewString("zone-a"), Ready: true},
|
||||||
|
&BaseEndpointInfo{Endpoint: "10.1.2.4:80", ZoneHints: sets.NewString("zone-b"), Ready: true},
|
||||||
|
&BaseEndpointInfo{Endpoint: "10.1.2.5:80", ZoneHints: sets.NewString("zone-c"), Ready: true},
|
||||||
|
&BaseEndpointInfo{Endpoint: "10.1.2.6:80", ZoneHints: sets.NewString("zone-a"), Ready: true},
|
||||||
|
},
|
||||||
|
clusterEndpoints: sets.NewString("10.1.2.3:80", "10.1.2.4:80", "10.1.2.5:80", "10.1.2.6:80"),
|
||||||
|
localEndpoints: nil,
|
||||||
|
}, {
|
||||||
|
|
||||||
name: "hints, hints annotation == aUto (wrong capitalization), hints ignored",
|
name: "hints, hints annotation == aUto (wrong capitalization), hints ignored",
|
||||||
hintsEnabled: true,
|
hintsEnabled: true,
|
||||||
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
||||||
|
Loading…
Reference in New Issue
Block a user