UnitedDeployment
在上一篇文章 中我们介绍了节点池的使用,主要是节点池的创建和管理,进一步,我们开发了基于节点池的应用单元化部署能力,提高用户的运维效率。
在这篇文章中,我们将展示yurt-app-manager如何帮助用户管理工作负载。假设我们已经拥有一个基于原生kubernetes搭建起来的OpenYurt集群,且至少有两个节点。
UnitedDeployment用户手册
创建UnitedDeployment
- 利用deployment template创建一个UnitedDeployment
$ cat <<EOF | kubectl apply -f -
apiVersion: apps.openyurt.io/v1alpha1
kind: UnitedDeployment
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: ud-test
spec:
selector:
matchLabels:
app: ud-test
workloadTemplate:
deploymentTemplate:
metadata:
labels:
app: ud-test
spec:
template:
metadata:
labels:
app: ud-test
spec:
containers:
- name: nginx
image: nginx:1.19.3
topology:
pools:
- name: beijing
nodeSelectorTerm:
matchExpressions:
- key: apps.openyurt.io/nodepool
operator: In
values:
- beijing
replicas: 1
- name: hangzhou
nodeSelectorTerm:
matchExpressions:
- key: apps.openyurt.io/nodepool
operator: In
values:
- hangzhou
replicas: 2
tolerations:
- effect: NoSchedule
key: apps.openyurt.io/example
operator: Exists
revisionHistoryLimit: 5
EOF
- 查看UnitedDeployment
$ kubectl get ud
NAME READY WORKLOADTEMPLATE AGE
ud-test 3 Deployment 120m
检查由yurt-app-manager组件创建的deployment
$ kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
ud-test-beijing-fp58z 1/1 1 1 122m
ud-test-hangzhou-xv454 2/2 2 2 122m
$ kubectl get pod -l app=ud-test
NAME READY STATUS RESTARTS AGE
ud-test-beijing-fp58z-787d5b6b54-g4jk6 1/1 Running 0 100m
ud-test-hangzhou-xv454-5cd9c4f6b5-b5tsr 1/1 Running 0 124m
ud-test-hangzhou-xv454-5cd9c4f6b5-gmbgp 1/1 Running 0 124m