将Pod调度到VNode
更新时间:2025-06-05
本文介绍如何将Pod调度到虚拟节点VNode。
概述
对于CCE集群,即混合使用普通节点和虚拟节点(VNode)的模式下,由于虚拟节点上默认配置了污点,用户需要为工作负载增加容忍以及调度策略,,您可以通过在Pod Spec配置nodeSelector和tolerations,将Pod调度到BCI。还可以通过标签将Pod调度到VNode上运行,详细请参考通过标签将Pod调度到VNode上运行。
配置示例
在Pod Spec中添加如下的nodeSelector和tolerations字段,将Pod调度到虚拟节点上。
Plain Text
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 labels:
5 type: pod-perf-test
6 name: nginx-test
7 namespace: default
8spec:
9 replicas: 1
10 revisionHistoryLimit: 10
11 selector:
12 matchLabels:
13 type: pod-perf-test
14 template:
15 metadata:
16 labels:
17 type: pod-perf-test
18 spec:
19 containers:
20 - image: registry.baidubce.com/qatest/nginx:1.23.0
21 imagePullPolicy: IfNotPresent
22 name: pod-perf-test
23 resources:
24 limits:
25 cpu: 0.25
26 memory: 512Mi
27 requests:
28 cpu: 0.25
29 memory: 512Mi
30 terminationMessagePath: /dev/termination-log
31 terminationMessagePolicy: File
32 dnsPolicy: Default
33 nodeSelector:
34 type: virtual-kubelet
35 tolerations:
36 - effect: NoSchedule
37 key: virtual-kubelet.io/provider
38 operator: Equal
39 value: baidu
查看是否调度成功,可查看到Pod所在节点在虚拟节点(bci-virtual-kubelet-0)上。
Plain Text
1$ kubectl get pod -o wide
2NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
3test-pod 1/1 Running 0 30d 192.168.128.53 bci-virtual-kubelet-0 <none> <none>