Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"なるべくスケジューリングしない" を実現する "PreferNoSchedule" taint

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Kazuki Suda Kazuki Suda
November 25, 2025

"なるべくスケジューリングしない" を実現する "PreferNoSchedule" taint

Kubernetes Meetup Tokyo 72 - LT

Avatar for Kazuki Suda

Kazuki Suda

November 25, 2025
Tweet

More Decks by Kazuki Suda

Other Decks in Technology

Transcript

  1. @superbrothers  Kubernetes Meetup Tokyo # 7 2 - LT

    ( 2025 / 11 / 25 ) SUDA Kazuki “なるべくスケジューリングしない” を実現する “PreferNoSchedule” taint
  2. @superbrothers  ノードの taint ノードに Pods をスケジューリングしないように制御する機能 2 kind: Node

    taints: - key: "key1" value: "value1" effect: "NoSchedule" kind: Pod tolerations: - key: "key1" value: "value1" effect: "NoSchedule" ノードの taints を許容するための設定
  3. @superbrothers  ノードの taint: e ff ect の種類 ▶ NoSchedule

    + Pod が合致する toleration を持たなければスケジューリングしない ▶ NoExecute + Pod が合致する toleration を持たなければスケジューリングしない + 既に実 行 中の Pod がノードから排除される ▶ PreferNoSchedule + Pod が合致する toleration を持たなければ ”なるべくスケジューリングしない” 3 目立ってないけど、taints/tolerations が Kubernetes に初めて実装された v1.3 から存在してます。
  4. @superbrothers  PreferNoSchedule taint: なるべくスケジューリングしない 4 GPU Node taints: -

    key: “nvidia.com/gpu“ effect: “PreferNoSchedule" allocatable: cpu: “36” nvidia.com/gpu: “8” GPU pod resources: requests: cpu: “1000m" limits: nvidia.com/gpu: 8 CPU pod resources: requests: cpu: “1000m" CPU Node allocatable: cpu: “24” GPU ノードにしか入らないのでそのまま入っていく GPU ノードに PreferNoSchedule taint があるので CPU ノードに空きがあればこっちが優先される CPU ノードに空きがなければ GPU ノードに入る
  5. @superbrothers  PreferNoSchedule taint の使いどころ ▶ GPU ノードに CPU pods

    をなるべくスケジューリングしたくない + GPU ノードに nvidia.com/gpu:PreferNoSchedule taint を付与する + GPU pod をスケジューリングする際に CPU 割り当て量が 足 りずにスケジューリングできない 自 体を避けたいが、CPU ノードのリソースが 足 りない場合は GPU ノードへのスケジューリン グを許容したい ▶ これからメンテナンスするノードに pods を新たになるべくスケジューリングしたくない + メンテ対象の全ノードに maintenance-20251125:PreferNoSchedule taint を付与して 1ノードずつ完了後に削除する + メンテでノード上の pods を drain する際にこれからメンテされるノードではなく、既にメン テが完了したノードになるべくスケジューリングして evict の機会を減らしたい + Cluster API ではクラスタアップグレード時にロールアウト対象ノードに PreferNoSchedule taint を設定することでこれを実現している 5
  6. @superbrothers  PreferNoSchedule taint を実現する “TaintToleration” scheduler plugin ▶ 各ノードで

    intolerable な (許容できない) taint の個数が最少のノードを100、最多を0の範囲で 線形に正規化する(スコア値が 高 いノードが望ましいノード) 6 func (pl *TaintToleration) Score(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeInfo fwk.NodeInfo) (int64, *fwk.Status) { node := nodeInfo.Node() s, err := getPreScoreState(state) if err != nil { return 0, fwk.AsStatus(err) } score := int64(countIntolerableTaintsPreferNoSchedule(node.Spec.Taints, s.tolerationsPreferNoSchedule)) return score, nil } // CountIntolerableTaintsPreferNoSchedule gives the count of intolerable taints of a pod with effect PreferNoSchedule func countIntolerableTaintsPreferNoSchedule(taints []v1.Taint, tolerations []v1.Toleration) (intolerableTaints int) { for _, taint := range taints { // check only on taints that have effect PreferNoSchedule if taint.Effect != v1.TaintEffectPreferNoSchedule { continue } if !v1helper.TolerationsTolerateTaint(tolerations, &taint) { intolerableTaints++ } } return } https://github.com/kubernetes/kubernetes/blob/v 1 . 34 . 2 /pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go#L 1 8 3 -L 1 9 4