节点池管理

1)安装 Yurt-Manager 组件

nodepool controller 集成在 Yurt-Manager 组件中,使用 NodePool 之前需要先安装它,您可以参考 【部署 OpenYurt](https://openyurt.io/docs/installation/manually-setup/#32-setup-openyurtopenyurt-components) 了解详细操作。

2)节点池使用Example

  • 创建一个节点池
  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
  • 使用kubectl get节点池信息
  1. $ kubectl get np
  2. NAME TYPE READYNODES NOTREADYNODES AGE
  3. beijing Cloud 35s
  4. hangzhou Edge 28s
  • 将节点加入到节点池

添加云端节点Cloud node到北京节点池,你只需将此节点按如下方式打上label即可

  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

当然,你也可以将你的边缘节点Edge node添加到杭州节点池,方法和上面类似

  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
  • 验证节点已经加入节点池

当Edge node成功加入到节点池,节点的配置信息除了节点池Spec中的所有内容,同时,节点添加了一个新的标签: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. ***