--- tags: Blue 的學習紀錄 --- # YuniKorn 簡介 Doc: <https://yunikorn.apache.org/docs/next/> Github: <https://github.com/search?q=org%3Aapache+yunikorn&type=repositories> YuniKorn 是一個 resource scheduler for K8s 用於取代 K8s 中的 [default scheduler](https://kubernetes.io/docs/concepts/architecture/#kube-scheduler) 達成 default scheduler 所做不到的事情 :::info **Scheduler 的作用:** Scheduler 是 K8s 中的一個元件,負責決定 Pods 要部署在哪個 Node Scheduler 在做的事情可以簡單拆分成兩階段: Filtering 和 Scoring - Filtering: 將符合條件的 Node 篩選出來,例如根據 Node 的 cpu or memory 資源是否足夠 - Scoring: 對篩選出來的 Node 打分數,選出一個分數最高的 Node [Kubernetes Documentation - Kubernetes Scheduler](https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/) ::: YuniKorn 實作了 default scheduler 不支援的功能 - Application 的概念 當使用者定義複數個 pods 為一個 app 時 YuniKorn 可以確保全部的 pods 都部署成功或者都失敗(All or Nothing) 避免只有部分 pods 成功部署的情形 - Queue 使用者可以定義 queue 每個 queue 可以設定其資源(cpu, memory)的使用上限 # My PRs 我發出過的 PR: https://github.com/search?q=org%3Aapache+yunikorn+is%3Apr+author%3AblueBlue0102&type=pullrequests # 專案結構簡介 - [yunikorn-core](https://github.com/apache/yunikorn-core/pulls?q=is%3Apr+author%3AblueBlue0102+) YuniKorn 的資源排程核心邏輯 可以理解成是一個 library,目前於 K8shim 專案中被引用 - [yunikorn-k8shim](https://github.com/apache/yunikorn-k8shim/pulls?q=is%3Apr+author%3AblueBlue0102+) YuniKorn 與 K8s 溝通的元件 負責監聽 K8s 的事件,例如 pods 的增加或刪除 收到事件交由 core 判斷後,呼叫 K8s 的 API 進行相應的處理 - [yunikorn-scheduler-interface](https://github.com/apache/yunikorn-scheduler-interface/pulls?q=is%3Apr+author%3AblueBlue0102+) 定義 YuniKorn core 與 shim 之間的溝通介面 這樣的設計使 core 與 shim 之間沒有依賴關係 讓 YuniKorn 可以不限於使用在 K8s 上 - [yunikorn-release](https://github.com/apache/yunikorn-release/pulls?q=is%3Apr+author%3AblueBlue0102+) 負責包版 YuniKorn,提供例如 Helm Chart 的模板 - [yunikorn-site](https://github.com/apache/yunikorn-site/pulls?q=is%3Apr+author%3AblueBlue0102+) 官方文件 - [yunikorn-web](https://github.com/apache/yunikorn-web/pulls?q=is%3Apr+author%3AblueBlue0102+) 一個 Dashboard Web 介面 會讀取並顯示 YuniKorn 的相關資訊 例如 app, node 或 queue 等等的資訊 # 研究筆記 - [K8shim 和 Core 之間的溝通方式(RMProxy)](https://hackmd.io/@vegetableBird/r1wtFbwh0) - [App State Scheduling](https://hackmd.io/@vegetableBird/Bk9EoCLsA) - [Gang Scheduling](https://hackmd.io/@vegetableBird/S1tVS52oC) - [Placeholder Pod 運作方式](https://hackmd.io/@vegetableBird/BklErnC6A) - [Jira 2737](https://hackmd.io/@vegetableBird/HJMS3Tk60) - Go Module 是否使用 `replace` hardcode 指定 version,還是讓 `go mod` 來管理?(待研究) 討論串: <https://github.com/apache/yunikorn-k8shim/pull/794> 在 YK 中部份套件會在 `replace` 區塊中指定套件的版本 這個做法的好處似乎在於可以避免不經意的更新導致的失敗 - YK 是否支援 cluster autoscaling? 是 YK 是一個 scheduler,當 pod 因沒有資源而無法成功部署時,只負責將 pod mark 為 `unscheduable`: [Link](https://github.com/apache/yunikorn-k8shim/blob/a53123f2d0bb3fd325dd7f8c1f2cc4640ff448d7/pkg/cache/context.go#L1204) node 的 scale 是由 Cluster Autoscaler 或 Karpenter 等其他元件執行 - [Verifying Apache Project Release (YuniKorn)](https://hackmd.io/@vegetableBird/Sy-zEKOvkx) - [【閱讀紀錄】Next Level Spark on Kubernetes with Apache YuniKorn (Incubating) - Weiwei Yang, Chaoran Yu](https://hackmd.io/@vegetableBird/r1vKtBkuyx) # 參考資訊 - [Next Level Spark on Kubernetes with Apache YuniKorn (Incubating) - Weiwei Yang, Chaoran Yu](https://youtu.be/gOST-iT-hj8?si=6VX5j6BGr2K0sfLj) - [State of Apache YuniKorn - 2024 CoC Aisa](https://docs.google.com/presentation/d/1eOqlN07u1CZwNICg3NYvh0_3i-80i7Y0/edit?usp=sharing&ouid=109715795571680355892&rtpof=true&sd=true) - [JIMMY SONG 整理的 K8s 電子書](https://lib.jimmysong.io/kubernetes-handbook/) - [K8s scheduler 詳解](https://kingjcy.github.io/post/cloud/paas/base/kubernetes/k8s-scheduler/) - Slack Spark 相關資訊連結 - <https://opensource4you.slack.com/archives/C05PH5KB7NZ/p1710517002938709?thread_ts=1710512247.452449&cid=C05PH5KB7NZ> - <https://opensource4you.slack.com/archives/C05PH5KB7NZ/p1717430092634669?thread_ts=1717429769.318569&cid=C05PH5KB7NZ>