YuniKorn 批处理调度器
YuniKorn 是面向大数据和批处理的 Kubernetes 调度器,支持层级队列、公平共享、资源配额、抢占和 Gang Scheduling。它适合 Spark、Flink、TensorFlow 等多租户批处理平台。
核心概念:Queue(层级队列)、Application、Allocation、ResourceManager 和 scheduler。YuniKorn 作为 secondary scheduler 运行,Pod 通过 schedulerName: yunikorn 使用。
安装:
helm repo add yunikorn https://apache.github.io/yunikorn-release
helm install yunikorn yunikorn/yunikorn \
--namespace yunikorn --create-namespace
kubectl -n yunikorn get pods
配置队列:
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: yunikorn-configs
namespace: yunikorn
data:
queues.yaml: |
partitions:
- name: default
queues:
- name: root
queues:
- name: team-a
resources:
guaranteed: {memory: 100Gi, vcore: 20}
max: {memory: 200Gi, vcore: 40}
- name: team-b
resources:
guaranteed: {memory: 50Gi, vcore: 10}
max: {memory: 100Gi, vcore: 20}
EOF
kubectl -n yunikorn rollout restart deploy/yunikorn-scheduler
提交使用 YuniKorn 的 Pod:
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: spark-driver
namespace: demo
labels:
yunikorn.apache.org/queue: root.team-a
spec:
schedulerName: yunikorn
containers:
- name: spark
image: spark:3.5
resources:
requests:
memory: 4Gi
cpu: "2"
EOF
查看队列和分配:
kubectl get pods -n yunikorn
kubectl logs -n yunikorn deploy/yunikorn-scheduler
kubectl get configmap yunikorn-configs -n yunikorn -o yaml
schedulerName: yunikorn,仍由默认调度器处理。root.team-a 格式,层级写错会落到默认队列。schedulerName: yunikorn 就仍由默认调度器处理,YuniKorn 完全不会介入;只有显式声明该字段的 Pod 才进入它的队列。root.team-a 这种层级格式(示例中通过 yunikorn.apache.org/queue 指定),层级写错会落到默认队列,表现为资源配额与预期不符。yunikorn 命名空间的 yunikorn-configs ConfigMap 的 queues.yaml 键里,改完需要 kubectl -n yunikorn rollout restart deploy/yunikorn-scheduler 才生效。guaranteed 与 max 配置不合理会导致资源闲置或排队,配置前要按各团队实际用量估算。kubectl logs -n yunikorn deploy/yunikorn-scheduler 与 kubectl describe pod 的调度失败事件。kubectl get pods -n yunikorn — 查看调度器kubectl logs -n yunikorn deploy/yunikorn-scheduler — 调度日志kubectl get configmap -n yunikorn — 查看队列配置kubectl describe pod — 查看调度失败事件合上页面,先回答,再展开对照。
schedulerName: yunikorn;不设置则仍由默认调度器处理。root.team-a 这种层级格式;层级写错会落到默认队列。
小程序版
微信扫码,随时查命令