系统学习 Kubernetes 学习路径:从心智模型到生产运维

yunikorn

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

注意

易错点与排错

相关命令

参考链接

读完自测

合上页面,先回答,再展开对照。

  1. 怎样让一个 Pod 交给 YuniKorn 调度?
  2. YuniKorn 的层级队列标签是什么格式?
  3. YuniKorn 与默认调度器同时运行时要注意什么?
答案
  1. 设置 schedulerName: yunikorn;不设置则仍由默认调度器处理。
  2. root.team-a 这种层级格式;层级写错会落到默认队列。
  3. 两者的资源视图可能不一致;要监控 pending Pod 和调度延迟。
微信小程序码:扫码打开命令速查小程序

小程序版

微信扫码,随时查命令