$30 off During Our Annual Pro Sale. View Details »

より適応的な Scheduling を目指して #containersig / Container SIG 2018 Fall

y_taka_23
October 24, 2018

より適応的な Scheduling を目指して #containersig / Container SIG 2018 Fall

Container SIG 2018 Fall で使用したスライドです。Kubernetes の Scheduling は原則として Pod 作成時にしか行われないため、状況によっては非効率的な配置が行われる可能性があります。この問題を解決するため、クラスタの状況を Scheduling に反映させるという切り口から、Preemption、Vertical Pod Autoscaler、Descheduler の 3 種類の機能について簡単に解説しました。

イベント概要:https://containersig.connpass.com/event/101214/
録画:https://crash.academy/video/363/1689

y_taka_23

October 24, 2018
Tweet

More Decks by y_taka_23

Other Decks in Technology

Transcript

  1. より適応的な
    Scheduling を目指して
    チェシャ猫 (@y_taka_23)
    Container SIG Meet-up 2018 Fall (2018/10/24)
    #containersig

    View Slide

  2. Node 1
    1G
    Replicas: 3
    1G
    Node 2 Node 3
    Manifest Scheduling Queue
    1G 1G
    #containersig

    View Slide

  3. 実際は一筋縄ではいかない
    #containersig

    View Slide

  4. 欲しい Pod がブロックされる
    #containersig

    View Slide

  5. Node 1
    F
    Batch
    B
    Node 2 Node 3
    Scheduling Queue
    B B
    Frontend
    F
    #containersig

    View Slide

  6. Node 1
    B B
    Batch
    B
    Node 2 Node 3
    Scheduling Queue
    F
    Frontend
    F
    #containersig

    View Slide

  7. Resource Request が不正確
    #containersig

    View Slide

  8. Node 1
    Replicas: 1
    2G
    Node 2 Node 3
    Manifest Scheduling Queue
    2G
    #containersig

    View Slide

  9. Node 1
    Replicas: 1
    2G
    Node 2 Node 3
    Manifest Scheduling Queue
    2G
    #containersig

    View Slide

  10. Node 1
    Replicas: 1
    2G
    Node 2 Node 3
    Manifest Scheduling Queue
    1G
    #containersig

    View Slide

  11. Node 間のバランスが崩れる
    #containersig

    View Slide

  12. Node 1 Node 2 Node 3
    Scheduling Queue
    #containersig

    View Slide

  13. Node 1 Node 2 Node 3
    (failure)
    Scheduling Queue
    #containersig

    View Slide

  14. Node 1 Node 2 Node 3
    (failure)
    Scheduling Queue
    #containersig

    View Slide

  15. Node 1 Node 2 Node 3
    Scheduling Queue
    #containersig

    View Slide

  16. 素朴な Scheduler の問題点
    ● 先着順でしか処理できない
    ○ 重要な Pod がブロックされる可能性
    ● 実際のリソース使用量が反映されない
    ○ 無駄にコストが掛かる可能性
    ● 配置の判断は Pod 生成時のみ
    ○ 特に Node の追加に追従できない
    ○ 結果として冗長性が損なわれる可能性
    #containersig

    View Slide

  17. 動的な状況が反映されない
    #containersig

    View Slide

  18. もっと適応的 (adaptive) に
    #containersig

    View Slide

  19. 18.06
    18.09
    18.12
    #containersig

    View Slide

  20. 18.06
    18.09
    18.12
    v1.11: Priority + Preemption (beta)
    https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
    #containersig

    View Slide

  21. Priority と Preemption
    ● Priority
    ○ 各 Pod に優先度を定義
    ○ Scheduler のデキューが優先度順になる
    ● Preemption
    ○ Pod を配置できる Node がないときに発動
    ○ 稼働中の低優先度 Pod を強制的に evict
    ○ 影響が小さくなる Node を選ぶ
    #containersig

    View Slide

  22. Node 1
    Batch
    B
    Node 2 Node 3
    Scheduling Queue
    B
    Frontend
    F
    #containersig
    F B

    View Slide

  23. 18.06
    18.09
    18.12
    v1.11: Priority + Preemption (beta)
    https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
    v1.12: Vertical Pod Autoscaler (beta)
    https://github.com/kubernetes/autoscaler/
    #containersig

    View Slide

  24. Vertical Pod Autoscaler
    ● Resource Request の推奨値を算出
    ○ Metrics Server から得た実データを参照
    ○ 許容できる Request の範囲を計算
    ● 自動的に推奨値を適用
    ○ 実データを元にした Scheduling が可能に
    ○ 許容範囲に収まらない Pod を evict
    ○ Admission Webhook で Pod 作成に割込み
    #containersig

    View Slide

  25. Node 1
    Replicas: 1
    2G
    Node 2 Node 3
    Manifest Scheduling Queue
    1G
    #containersig

    View Slide

  26. 18.06
    18.09
    18.12
    v1.11: Priority + Preemption (beta)
    https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
    v1.12: Vertical Pod Autoscaler (beta)
    https://github.com/kubernetes/autoscaler/
    v1.13: Descheduler (incubator 卒業?)
    https://github.com/kubernetes-incubator/descheduler
    #containersig

    View Slide

  27. Descheduler
    ● 運用中に崩れた Pod のバランスを回復
    ○ 現状デーモンではなく使い切りのコマンド
    ○ クラスタ構成の変化後に実行
    ● 特定の条件下で Pod を evict
    ○ Replica が同じ Node に固まっている
    ○ リソース利用率が一定以下の Node がある
    ○ Affinity の条件に違反している
    #containersig

    View Slide

  28. Node 1 Node 2 Node 3
    Scheduling Queue
    #containersig

    View Slide

  29. まとめ:適応的な Scheduling
    ● Priority と Preemption
    ○ 重要な Pod を優先的に配置
    ● Vertical Pod Autoscaler
    ○ 実使用量を見て Resource Request を調整
    ● Descheduler
    ○ 運用中に生じた Pod の偏りを修正
    ○ Contributor が足りないらしいので是非
    #containersig

    View Slide

  30. Have a Nice Scheduling!
    Presented by チェシャ猫 (@y_taka_23)
    #containersig

    View Slide