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 格式,层级写错会落到默认队列。kubectl get pods -n yunikorn — 查看调度器kubectl logs -n yunikorn deploy/yunikorn-scheduler — 调度日志kubectl get configmap -n yunikorn — 查看队列配置kubectl describe pod — 查看调度失败事件helm — 安装和升级