YurtAppSet
In the previous article we introduced the use of NodePool, mainly the creation and management of NodePool. Further, we developed the ability to deploy applications unitized based on NodePool to improve the efficiency of users’ operations.
In this article, we will show how yurt-app-manager can help users manage their workload. Assume we already have an OpenYurt cluster built on native kubernetes with at least two nodes.
1) Create YurtAppSet
- Create
YurtAppSetbyyurtappset_test.yaml
apiVersion: apps.openyurt.io/v1alpha1kind: YurtAppSetmetadata:labels:controller-tools.k8s.io: "1.0"name: yas-testspec:selector:matchLabels:app: yas-testworkloadTemplate:deploymentTemplate:metadata:labels:app: yas-testspec:template:metadata:labels:app: yas-testspec:containers:- name: nginximage: nginx:1.19.3topology:pools:- name: beijingnodeSelectorTerm:matchExpressions:- key: apps.openyurt.io/nodepooloperator: Invalues:- beijingreplicas: 1- name: hangzhounodeSelectorTerm:matchExpressions:- key: apps.openyurt.io/nodepooloperator: Invalues:- hangzhoureplicas: 2tolerations:- effect: NoSchedulekey: apps.openyurt.io/exampleoperator: ExistsrevisionHistoryLimit: 5
- Check
YurtAppSet
$ kubectl get yasNAME READY WORKLOADTEMPLATE AGEyas-test 3 Deployment 43s
2) Check the deployments created by yurt-app-manager
$ kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEyas-test-beijing-k5st4 1/1 1 1 54syas-test-hangzhou-2jkj5 2/2 2 2 54s$ kubectl get pod -l app=yas-testNAME READY STATUS RESTARTS AGEyas-test-beijing-k5st4-56bc98cc7d-h7h86 1/1 Running 0 72syas-test-hangzhou-2jkj5-64588c484b-8mvn8 1/1 Running 0 72syas-test-hangzhou-2jkj5-64588c484b-vx85t 1/1 Running 0 72s
3) Add patch to YurtAppSet
- Add the patch field to the file
yurtappset_test.yamlas follows, lines 36 to 41 of the file
$ kubectl get yas yas-test -o yamltopology:pools:- name: beijingnodeSelectorTerm:matchExpressions:- key: apps.openyurt.io/nodepooloperator: Invalues:- beijingreplicas: 1patch:spec:template:spec:containers:- name: nginximage: nginx:1.19.0- name: hangzhounodeSelectorTerm:matchExpressions:- key: apps.openyurt.io/nodepooloperator: Invalues:- hangzhoureplicas: 2tolerations:***
- This updates the nginx image version to 1.19.0 in the deployments and pods in Beijing NodePool, while keeping the nginx image version at 1.19.3 for the other regions
$ kubectl get deploy yas-test-beijing-k5st4 -o yamlcontainers:- image: nginx:1.19.0$ kubectl get deploy yas-test-hangzhou-2jkj5 -o yamlcontainers:- image: nginx:1.19.3
- After removing the patch, all pods created by YurtAppSet revert back to nginx1.19.3
$ kubectl get pod yas-test-beijing-k5st4-974b6958c-t2kfn -o yamlcontainers:- image: nginx:1.19.3$ kubectl get pod yas-test-hangzhou-2jkj5-64588c484b-8mvn8 -o yamlcontainers:- image: nginx:1.19.3
- Conclusion: Patch solves the upgrade of the NodePool’s single attribute and application release.
