mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Merge pull request #54644 from brendandburns/node-label
Automatic merge from submit-queue (batch tested with PRs 54644, 53072). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Flag gate node exclusion for service load balancers. @thockin @jdumars ```release-note Add a new feature gate for enabling an alpha annotation which, if present, excludes the annotated node from being added to a service load balancers. ``` Issue: https://github.com/kubernetes/kubernetes/issues/54743 Notes: The original PR for this feature was: https://github.com/kubernetes/kubernetes/pull/53146 Which didn't include a gate (or the alpha label). This was refined to add the `alpha` label in: https://github.com/kubernetes/kubernetes/pull/53678 Then in the cherry-pick review: https://github.com/kubernetes/kubernetes/pull/53656#issuecomment-335693646 @thockin requested a gate for an alpha feature, which is this PR.
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"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"
|
||||
@@ -40,6 +41,7 @@ import (
|
||||
v1helper "k8s.io/kubernetes/pkg/api/v1/helper"
|
||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||
"k8s.io/kubernetes/pkg/controller"
|
||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/util/metrics"
|
||||
)
|
||||
|
||||
@@ -69,7 +71,7 @@ const (
|
||||
|
||||
// LabelNodeRoleExcludeBalancer specifies that the node should be
|
||||
// exclude from load balancers created by a cloud provider.
|
||||
LabelNodeRoleExcludeBalancer = "alpha.node.role.kubernetes.io/exclude-balancer"
|
||||
LabelNodeRoleExcludeBalancer = "alpha.service-controller.kubernetes.io/exclude-balancer"
|
||||
)
|
||||
|
||||
type cachedService struct {
|
||||
@@ -613,8 +615,10 @@ func getNodeConditionPredicate() corelisters.NodeConditionPredicate {
|
||||
return false
|
||||
}
|
||||
|
||||
if _, hasExcludeBalancerLabel := node.Labels[LabelNodeRoleExcludeBalancer]; hasExcludeBalancerLabel {
|
||||
return false
|
||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.ServiceNodeExclusion) {
|
||||
if _, hasExcludeBalancerLabel := node.Labels[LabelNodeRoleExcludeBalancer]; hasExcludeBalancerLabel {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// If we have no info, don't accept
|
||||
|
||||
Reference in New Issue
Block a user