mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Implement KEP-3458
This commit is contained in:
parent
e30c49b0e8
commit
d7060f02ce
@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
@ -41,6 +42,7 @@ import (
|
||||
servicehelper "k8s.io/cloud-provider/service/helpers"
|
||||
"k8s.io/component-base/featuregate"
|
||||
controllersmetrics "k8s.io/component-base/metrics/prometheus/controllers"
|
||||
"k8s.io/controller-manager/pkg/features"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
@ -658,6 +660,12 @@ func nodeNames(nodes []*v1.Node) sets.String {
|
||||
}
|
||||
|
||||
func shouldSyncUpdatedNode(oldNode, newNode *v1.Node) bool {
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.StableLoadBalancerNodeSet) {
|
||||
// Only Nodes with changes to the label
|
||||
// "node.kubernetes.io/exclude-from-external-load-balancers" will
|
||||
// trigger a load balancer re-sync.
|
||||
return respectsPredicates(oldNode, nodeIncludedPredicate) != respectsPredicates(newNode, nodeIncludedPredicate)
|
||||
}
|
||||
// Evaluate the individual node exclusion predicate before evaluating the
|
||||
// compounded result of all predicates. We don't sync ETP=local services
|
||||
// for changes on the readiness condition, hence if a node remains NotReady
|
||||
@ -932,9 +940,21 @@ var (
|
||||
nodeIncludedPredicate,
|
||||
nodeUnTaintedPredicate,
|
||||
}
|
||||
stableNodeSetPredicates []NodeConditionPredicate = []NodeConditionPredicate{
|
||||
nodeIncludedPredicate,
|
||||
// This is not perfect, but probably good enough. We won't update the
|
||||
// LBs just because the taint was added (see shouldSyncUpdatedNode) but
|
||||
// if any other situation causes an LB sync, tainted nodes will be
|
||||
// excluded at that time and cause connections on said node to not
|
||||
// connection drain.
|
||||
nodeUnTaintedPredicate,
|
||||
}
|
||||
)
|
||||
|
||||
func getNodePredicatesForService(service *v1.Service) []NodeConditionPredicate {
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.StableLoadBalancerNodeSet) {
|
||||
return stableNodeSetPredicates
|
||||
}
|
||||
if service.Spec.ExternalTrafficPolicy == v1.ServiceExternalTrafficPolicyLocal {
|
||||
return etpLocalNodePredicates
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user