diff --git a/deploy/scheduler/deployment.yaml b/deploy/scheduler/deployment.yaml index bd50e07d7..105515619 100644 --- a/deploy/scheduler/deployment.yaml +++ b/deploy/scheduler/deployment.yaml @@ -26,9 +26,6 @@ spec: image: ghcr.io/kosmos-io/scheduler:0.0.2 command: - scheduler - - --leader-elect=true - - --leader-elect-resource-name=kosmos-scheduler - - --leader-elect-resource-namespace=kosmos-system - --config=/etc/kubernetes/kube-scheduler/scheduler-config.yaml resources: requests: @@ -67,6 +64,8 @@ data: kind: KubeSchedulerConfiguration leaderElection: leaderElect: true + resourceName: kosmos-scheduler + resourceNamespace: kosmos-system profiles: - schedulerName: kosmos-scheduler plugins: diff --git a/deploy/scheduler/rbac.yaml b/deploy/scheduler/rbac.yaml index 0f008445d..d7f9c28ee 100644 --- a/deploy/scheduler/rbac.yaml +++ b/deploy/scheduler/rbac.yaml @@ -62,8 +62,6 @@ rules: - '' resources: - endpoints - resourceNames: - - kube-scheduler - verbs: - get - list diff --git a/pkg/scheduler/lifted/plugins/knodevolumebinding/knode_volume_binding.go b/pkg/scheduler/lifted/plugins/knodevolumebinding/knode_volume_binding.go index f105a3a2a..2010e54e9 100644 --- a/pkg/scheduler/lifted/plugins/knodevolumebinding/knode_volume_binding.go +++ b/pkg/scheduler/lifted/plugins/knodevolumebinding/knode_volume_binding.go @@ -69,6 +69,7 @@ func (d *stateData) Clone() framework.StateData { type VolumeBinding struct { Binder scheduling.SchedulerVolumeBinder PVCLister corelisters.PersistentVolumeClaimLister + NodeLister corelisters.NodeLister frameworkHandler framework.Handle } @@ -232,6 +233,15 @@ func (pl *VolumeBinding) Filter(_ context.Context, cs *framework.CycleState, pod // Reserve reserves volumes of pod and saves binding status in cycle state. func (pl *VolumeBinding) Reserve(_ context.Context, cs *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status { + node, err := pl.NodeLister.Get(nodeName) + if err == nil { + return framework.NewStatus(framework.Error, "node not found") + } + + if helpers.HasKnodeTaint(node) { + return nil + } + state, err := getStateData(cs) if err != nil { return framework.AsStatus(err) @@ -257,6 +267,15 @@ func (pl *VolumeBinding) Reserve(_ context.Context, cs *framework.CycleState, po // If binding errors, times out or gets undone, then an error will be returned to // retry scheduling. func (pl *VolumeBinding) PreBind(ctx context.Context, cs *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status { + node, err := pl.NodeLister.Get(nodeName) + if err == nil { + return framework.NewStatus(framework.Error, "node not found") + } + + if helpers.HasKnodeTaint(node) { + return nil + } + s, err := getStateData(cs) if err != nil { return framework.AsStatus(err) @@ -283,6 +302,15 @@ func (pl *VolumeBinding) PreBind(ctx context.Context, cs *framework.CycleState, // Unreserve clears assumed PV and PVC cache. // It's idempotent, and does nothing if no cache found for the given pod. func (pl *VolumeBinding) Unreserve(_ context.Context, cs *framework.CycleState, _ *corev1.Pod, nodeName string) { + node, err := pl.NodeLister.Get(nodeName) + if err != nil { + return + } + + if helpers.HasKnodeTaint(node) { + return + } + s, err := getStateData(cs) if err != nil { return @@ -317,6 +345,7 @@ func New(plArgs runtime.Object, fh framework.Handle) (framework.Plugin, error) { return &VolumeBinding{ Binder: binder, PVCLister: pvcInformer.Lister(), + NodeLister: nodeInformer.Lister(), frameworkHandler: fh, }, nil }