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

Beginning with version v1.4.0 of OpenYurt, the apps.openyurt.io/v1beta1 version of the NodePool resource is the recommended choice for use.

  • Create a nodepool with type=Cloud
  1. $ cat <<EOF | kubectl apply -f -
  2. apiVersion: apps.openyurt.io/v1beta1
  3. kind: NodePool
  4. metadata:
  5. name: beijing
  6. spec:
  7. type: Cloud
  8. EOF
  • Create a nodepool with type=Edge and hostNetwork=true, also include Annotation, Label, Taint.
  1. $ cat <<EOF | kubectl apply -f -
  2. apiVersion: apps.openyurt.io/v1beta1
  3. kind: NodePool
  4. metadata:
  5. name: hangzhou
  6. spec:
  7. type: Edge
  8. hostNetwork: true
  9. annotations:
  10. apps.openyurt.io/example: test-hangzhou
  11. labels:
  12. apps.openyurt.io/example: test-hangzhou
  13. taints:
  14. - key: apps.openyurt.io/example
  15. value: test-hangzhou
  16. effect: NoSchedule
  17. 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 with label: apps.openyurt.io/nodepool=beijing

  1. $ kubectl label node master apps.openyurt.io/nodepool=beijing
  2. master labeled

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

  1. $ kubectl label node k8s-node1 apps.openyurt.io/nodepool=hangzhou
  2. k8s-node1 labeled
  3. $ kubectl label node k8s-node2 apps.openyurt.io/nodepool=hangzhou
  4. 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: nodepool.openyurt.io/hostnetwork

  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. nodepool.openyurt.io/hostnetwork: "true"
  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. ***