mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #84274 from liggitt/beta-gate-pdb-informers
Feature-gate PDB informer starts
This commit is contained in:
commit
09a251ce92
@ -21,14 +21,16 @@ limitations under the License.
|
||||
package app
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/scale"
|
||||
"k8s.io/kubernetes/pkg/controller/disruption"
|
||||
|
||||
"net/http"
|
||||
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/scale"
|
||||
"k8s.io/kubernetes/pkg/controller/disruption"
|
||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
||||
)
|
||||
|
||||
func startDisruptionController(ctx ControllerContext) (http.Handler, bool, error) {
|
||||
@ -42,6 +44,10 @@ func startDisruptionController(ctx ControllerContext) (http.Handler, bool, error
|
||||
resource, group+"/"+version)
|
||||
return nil, false, nil
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.PodDisruptionBudget) {
|
||||
klog.Infof("Refusing to start disruption because the PodDisruptionBudget feature is disabled")
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
client := ctx.ClientBuilder.ClientOrDie("disruption-controller")
|
||||
config := ctx.ClientBuilder.ConfigOrDie("disruption-controller")
|
||||
|
@ -492,6 +492,13 @@ const (
|
||||
//
|
||||
// Enables the users to skip TLS verification of kubelets on pod logs requests
|
||||
AllowInsecureBackendProxy featuregate.Feature = "AllowInsecureBackendProxy"
|
||||
|
||||
// owner: @mortent
|
||||
// alpha: v1.3
|
||||
// beta: v1.5
|
||||
//
|
||||
// Enable all logic related to the PodDisruptionBudget API object in policy
|
||||
PodDisruptionBudget featuregate.Feature = "PodDisruptionBudget"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -572,6 +579,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
||||
EvenPodsSpread: {Default: false, PreRelease: featuregate.Alpha},
|
||||
StartupProbe: {Default: false, PreRelease: featuregate.Alpha},
|
||||
AllowInsecureBackendProxy: {Default: true, PreRelease: featuregate.Beta},
|
||||
PodDisruptionBudget: {Default: true, PreRelease: featuregate.Beta},
|
||||
|
||||
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
|
||||
// unintentionally on either side:
|
||||
|
@ -332,9 +332,15 @@ func (g *genericScheduler) Preempt(ctx context.Context, state *framework.CycleSt
|
||||
// In this case, we should clean-up any existing nominated node name of the pod.
|
||||
return nil, nil, []*v1.Pod{pod}, nil
|
||||
}
|
||||
pdbs, err := g.pdbLister.List(labels.Everything())
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
var (
|
||||
pdbs []*policy.PodDisruptionBudget
|
||||
err error
|
||||
)
|
||||
if g.pdbLister != nil {
|
||||
pdbs, err = g.pdbLister.List(labels.Everything())
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
}
|
||||
nodeToVictims, err := g.selectNodesForPreemption(ctx, state, pod, potentialNodes, pdbs)
|
||||
if err != nil {
|
||||
|
@ -226,6 +226,11 @@ func NewConfigFactory(args *ConfigFactoryArgs) *Configurator {
|
||||
csiNodeLister = args.CSINodeInformer.Lister()
|
||||
}
|
||||
|
||||
var pdbLister policylisters.PodDisruptionBudgetLister
|
||||
if args.PdbInformer != nil {
|
||||
pdbLister = args.PdbInformer.Lister()
|
||||
}
|
||||
|
||||
c := &Configurator{
|
||||
client: args.Client,
|
||||
informerFactory: args.InformerFactory,
|
||||
@ -235,7 +240,7 @@ func NewConfigFactory(args *ConfigFactoryArgs) *Configurator {
|
||||
controllerLister: args.ReplicationControllerInformer.Lister(),
|
||||
replicaSetLister: args.ReplicaSetInformer.Lister(),
|
||||
statefulSetLister: args.StatefulSetInformer.Lister(),
|
||||
pdbLister: args.PdbInformer.Lister(),
|
||||
pdbLister: pdbLister,
|
||||
nodeLister: args.NodeInformer.Lister(),
|
||||
podLister: args.PodInformer.Lister(),
|
||||
storageClassLister: storageClassLister,
|
||||
|
@ -29,12 +29,15 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/informers"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
policyv1beta1informers "k8s.io/client-go/informers/policy/v1beta1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/tools/events"
|
||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||
latestschedulerapi "k8s.io/kubernetes/pkg/scheduler/api/latest"
|
||||
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
@ -279,6 +282,11 @@ func New(client clientset.Interface,
|
||||
}
|
||||
registry.Merge(options.frameworkOutOfTreeRegistry)
|
||||
|
||||
var pdbInformer policyv1beta1informers.PodDisruptionBudgetInformer
|
||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.PodDisruptionBudget) {
|
||||
pdbInformer = informerFactory.Policy().V1beta1().PodDisruptionBudgets()
|
||||
}
|
||||
|
||||
// Set up the configurator which can create schedulers from configs.
|
||||
configurator := NewConfigFactory(&ConfigFactoryArgs{
|
||||
Client: client,
|
||||
@ -291,7 +299,7 @@ func New(client clientset.Interface,
|
||||
ReplicaSetInformer: informerFactory.Apps().V1().ReplicaSets(),
|
||||
StatefulSetInformer: informerFactory.Apps().V1().StatefulSets(),
|
||||
ServiceInformer: informerFactory.Core().V1().Services(),
|
||||
PdbInformer: informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||
PdbInformer: pdbInformer,
|
||||
StorageClassInformer: informerFactory.Storage().V1().StorageClasses(),
|
||||
CSINodeInformer: informerFactory.Storage().V1beta1().CSINodes(),
|
||||
VolumeBinder: volumeBinder,
|
||||
|
Loading…
Reference in New Issue
Block a user