Skip to main content

pod/deployment使用队列

创建测试队列:

test-queue.yaml
apiVersion: scheduling.volcano.sh/v1beta1
kind: Queue
metadata:
name: test-queue
spec:
capability:
cpu: 10
memory: 10Gi

通过Pod测试:

example-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: example-pod
annotations:
# 需要注意,只能使用annotations,不能使用labels指定队列,
# 否则无法设置队列,生成的PodGroup的队列名称为默认的default
scheduling.volcano.sh/queue-name: "test-queue"
spec:
schedulerName: volcano
containers:
- name: example-container
image: nginx

通过Deployment测试:

example-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
# 只能在annotations中设置队列名称,不能在labels中设置
# 只能这里设置队列名称,不能在Deployment的annotations中设置
scheduling.volcano.sh/queue-name: "test-queue"
spec:
schedulerName: volcano
containers:
- name: nginx
image: nginx:1.14.2

gang调度

创建一个限制资源上限的队列:

test-gang-queue.yaml
apiVersion: scheduling.volcano.sh/v1beta1
kind: Queue
metadata:
name: test-gang-queue
spec:
capability:
cpu: 2
memory: 2Gi

创建一个gang调度的Job

test-gang-job.yaml
apiVersion: batch.volcano.sh/v1alpha1
kind: Job
metadata:
name: test-gang-job
spec:
minAvailable: 5
schedulerName: volcano
queue: test-gang-queue
policies:
- action: CompleteJob
event: TaskCompleted
tasks:
- replicas: 5
name: worker
template:
spec:
restartPolicy: Never
containers:
- image: alpine:latest
imagePullPolicy: IfNotPresent
name: worker
command: ["sh", "-c", "sleep 1d"]
resources:
requests:
cpu: 1
memory: 100Mi

Job中的所有Pod都不会创建出来,因为队列的CPU资源上限为2,而Job中的Pod需要5CPU