Node Pool Management

1)Install Yurt-Manager Component

nodepool controller is integrated within Yurt-Manager component, and it needs to be installed before using NodePool, you can refer to Deploy OpenYurt for detailed operations.

2)Example of Node Pool usage

  • Create a nodepool
  1. $ cat <<EOF | kubectl apply -f -
  2. apiVersion: apps.openyurt.io/v1alpha1
  3. kind: NodePool
  4. metadata:
  5. name: beijing
  6. spec:
  7. type: Cloud
  8. EOF
  9. $ cat <<EOF | kubectl apply -f -
  10. apiVersion: apps.openyurt.io/v1alpha1
  11. kind: NodePool
  12. metadata:
  13. name: hangzhou
  14. spec:
  15. type: Edge
  16. annotations:
  17. apps.openyurt.io/example: test-hangzhou
  18. labels:
  19. apps.openyurt.io/example: test-hangzhou
  20. taints:
  21. - key: apps.openyurt.io/example
  22. value: test-hangzhou
  23. effect: NoSchedule
  24. EOF
  • Get the nodepool information
  1. $ kubectl get np
  2. NAME TYPE READYNODES NOTREADYNODES AGE
  3. beijing Cloud 35s
  4. hangzhou Edge 28s
  • Add node to nodepool

Add a cloud node to nodepool “beijing”, you only need to label the node as below:

  1. $ kubectl label node {Your_Node_Name} apps.openyurt.io/desired-nodepool=beijing
  1. For example:
  2. $ kubectl label node master apps.openyurt.io/desired-nodepool=beijing
  3. master labeled

Similarly, you can add the edge nodes to nodepool “hangzhou”:

  1. $ kubectl label node {Your_Node_Name} apps.openyurt.io/desired-nodepool=hangzhou
  2. For example:
  3. $ kubectl label node k8s-node1 apps.openyurt.io/desired-nodepool=hangzhou
  4. k8s-node1 labeled
  5. $ kubectl label node k8s-node2 apps.openyurt.io/desired-nodepool=hangzhou
  6. k8s-node2 labeled
  • Verify whether a node is added to a nodepool:

When an edge node is added to a nodepool, all the annotations/labels of the nodepool are added to the node, together with a new label: apps.openyurt.io/nodepool

  1. $ kubectl get node {Your_Node_Name} -o yaml
  2. For Example:
  3. $ kubectl get node k8s-node1 -o yaml
  4. apiVersion: v1
  5. kind: Node
  6. metadata:
  7. annotations:
  8. apps.openyurt.io/example: test-hangzhou
  9. kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
  10. node.alpha.kubernetes.io/ttl: "0"
  11. node.beta.alibabacloud.com/autonomy: "true"
  12. volumes.kubernetes.io/controller-managed-attach-detach: "true"
  13. creationTimestamp: "2021-04-14T12:17:39Z"
  14. labels:
  15. apps.openyurt.io/desired-nodepool: hangzhou
  16. apps.openyurt.io/example: test-hangzhou
  17. apps.openyurt.io/nodepool: hangzhou
  18. beta.kubernetes.io/arch: amd64
  19. beta.kubernetes.io/os: linux
  20. kubernetes.io/arch: amd64
  21. kubernetes.io/hostname: k8s-node1
  22. kubernetes.io/os: linux
  23. openyurt.io/is-edge-worker: "true"
  24. name: k8s-node1
  25. resourceVersion: "1244431"
  26. selfLink: /api/v1/nodes/k8s-node1
  27. uid: 1323f90b-acf3-4443-a7dc-7a54c212506c
  28. spec:
  29. podCIDR: 192.168.1.0/24
  30. podCIDRs:
  31. - 192.168.1.0/24
  32. taints:
  33. - effect: NoSchedule
  34. key: apps.openyurt.io/example
  35. value: test-hangzhou
  36. status:
  37. ***