與原生的Kubernetes調度器相比,容器服務ACK的調度器擴展出更多其他功能,例如Gang Scheduling、CPU拓撲感知、ECI彈性調度等。本文介紹通過為注冊集群安裝ack-co-scheduler組件的方式,以實現在您的本地集群中使用阿里云容器服務ACK的調度能力,讓您能夠便捷地使用容器服務對于大數據、AI等應用擴展出的差異化能力,提高應用的運行效率。
前提條件
已創建注冊集群,并將自建Kubernetes集群接入注冊集群。具體操作,請參見創建注冊集群。
系統組件版本要求具體如下表所示。
組件
版本要求
Kubernetes
1.18.8及以上版本
Helm
3.0及以上版本
Docker
19.03.5
操作系統
CentOS 7.6、CentOS 7.7、Ubuntu 16.04、Ubuntu 18.04、Alibaba Cloud Linux
注意事項
在部署任務時需要指定調度器的名稱為ack-co-scheduler,即將.template.spec.schedulerName
配置為ack-co-scheduler
。
安裝ack-co-scheduler組件
通過onectl安裝
在本地安裝配置onectl。具體操作,請參見通過onectl管理注冊集群。
執行以下命令,安裝ack-co-scheduler組件。
onectl addon install ack-co-scheduler
預期輸出:
Addon ack-co-scheduler, version **** installed.
通過控制臺安裝
登錄容器服務管理控制臺,在左側導航欄選擇集群。
在集群列表頁面,單擊目標集群名稱,然后在左側導航欄,選擇 。
在組件管理頁面,單擊其他頁簽,找到ack-co-scheduler組件,在卡片右下方單擊安裝。
在提示對話框中單擊確定。
Gang scheduling
阿里云容器服務ACK基于新版的Kube-scheduler框架實現Gang scheduling的能力,解決原生調度器無法支持All-or-Nothing作業調度的問題。
使用以下模板向集群中提交Tensorflow分布式作業。關于如何運行Tensorflow的分布式作業,請參見使用Gang scheduling。
apiVersion: "kubeflow.org/v1"
kind: "TFJob"
metadata:
name: "tf-smoke-gpu"
spec:
tfReplicaSpecs:
PS:
replicas: 1
template:
metadata:
creationTimestamp: null
labels:
pod-group.scheduling.sigs.k8s.io/name: tf-smoke-gpu
pod-group.scheduling.sigs.k8s.io/min-available: "2"
spec:
schedulerName: ack-co-scheduler #指定調度器的名稱為ack-co-scheduler。
containers:
- args:
- python
- tf_cnn_benchmarks.py
- --batch_size=32
- --model=resnet50
- --variable_update=parameter_server
- --flush_stdout=true
- --num_gpus=1
- --local_parameter_device=cpu
- --device=cpu
- --data_format=NHWC
image: registry.cn-hangzhou.aliyuncs.com/kubeflow-images-public/tf-benchmarks-cpu:v20171202-bdab599-dirty-284af3
name: tensorflow
ports:
- containerPort: 2222
name: tfjob-port
resources:
limits:
cpu: '10'
workingDir: /opt/tf-benchmarks/scripts/tf_cnn_benchmarks
restartPolicy: OnFailure
Worker:
replicas: 4
template:
metadata:
creationTimestamp: null
labels:
pod-group.scheduling.sigs.k8s.io/name: tf-smoke-gpu
pod-group.scheduling.sigs.k8s.io/min-available: "2"
spec:
schedulerName: ack-co-scheduler
containers:
- args:
- python
- tf_cnn_benchmarks.py
- --batch_size=32
- --model=resnet50
- --variable_update=parameter_server
- --flush_stdout=true
- --num_gpus=1
- --local_parameter_device=cpu
- --device=gpu
- --data_format=NHWC
image: registry.cn-hangzhou.aliyuncs.com/kubeflow-images-public/tf-benchmarks-cpu:v20171202-bdab599-dirty-284af3
name: tensorflow
ports:
- containerPort: 2222
name: tfjob-port
resources:
limits:
cpu: 10
workingDir: /opt/tf-benchmarks/scripts/tf_cnn_benchmarks
restartPolicy: OnFailure
CPU拓撲感知調度
在使用CPU拓撲感知調度前,需要預先部署組件resource-controller。具體操作,請參見管理組件。
使用以下模板在Deployment中使用CPU拓撲感知調度。關于CPU拓撲感知調度的更多信息,請參見CPU拓撲感知調度。
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-numa
labels:
app: nginx-numa
spec:
replicas: 2
selector:
matchLabels:
app: nginx-numa
template:
metadata:
annotations:
cpuset-scheduler: "true"
labels:
app: nginx-numa
spec:
schedulerName: ack-co-scheduler #指定調度器的名稱為ack-co-scheduler。
containers:
- name: nginx-numa
image: nginx:1.13.3
ports:
- containerPort: 80
resources:
requests:
cpu: 4
limits:
cpu: 4
ECI彈性調度
ECI彈性調度是阿里云提供的彈性調度策略。您可以在部署服務時通過添加Annotations來申明只使用ECS或ECI彈性資源,或者是在ECS資源不足時自動申請ECI資源。通過ECI彈性調度可以滿足您在不同工作負載的場景下對彈性資源的不同需求。
在使用ECI彈性調度前,需要在集群中預先部署組件ack-virtual-node。具體操作,請參見ACK使用ECI。
使用以下模板在Deployment中使用ECI彈性調度。關于如何使用ECI彈性調度,請參見使用ECI彈性調度。
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 4
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx
annotations:
alibabacloud.com/burst-resource: eci #添加注解,選擇彈性調度的資源類型。
labels:
app: nginx
spec:
schedulerName: ack-co-scheduler #指定調度器的名稱為ack-co-scheduler。
containers:
- name: nginx
image: nginx
resources:
limits:
cpu: 2
requests:
cpu: 2
在template. metadata
下配置Pod的Annotations alibabacloud.com/burst-resource
,聲明彈性調度資源的類型。alibabacloud.com/burst-resource
取值說明如下:
默認不填Annotations時:只使用集群現有的ECS資源。
eci
:當前集群ECS資源不足時,使用ECI彈性資源。eci_only
:只使用ECI彈性資源,不使用集群的ECS資源。
共享GPU調度
關于如何使用共享GPU調度,請參見運行共享GPU調度組件、監控和隔離GPU資源、基于節點池管理共享GPU。