Commit a7820484 by tingweiwang

修复node节点自动打label

1 parent fbf71e83
Showing with 4 additions and 2 deletions
...@@ -171,8 +171,10 @@ ansible new_node -m shell -a "systemctl enable kubelet.service" ...@@ -171,8 +171,10 @@ ansible new_node -m shell -a "systemctl enable kubelet.service"
ansible new_node -m shell -a "systemctl enable kube-proxy.service" ansible new_node -m shell -a "systemctl enable kube-proxy.service"
######################为新添加节点设置lable################################################# ######################为新添加节点设置lable#################################################
echo "分发kubectl以及kubeconfig,使node节点可以执行kubectl命令" echo "分发kubectl以及kubeconfig,使node节点可以执行kubectl命令"
ansible new_node -m copy -a "src=/usr/bin/kubectl dest=/usr/bin/kubectl mode-777" ansible new_node -m copy -a "src=/usr/bin/kubectl dest=/usr/bin/kubectl mode=777"
ansible new_node -m shell -a "mkdir /root/.kube/ -pv" ansible new_node -m shell -a "mkdir /root/.kube/ -pv"
ansible new_node -m copy -a "src=/root/.kube/config dest=/root/.kube/config mode=777" ansible new_node -m copy -a "src=/root/.kube/config dest=/root/.kube/config mode=777"
echo "根据自己的节点类型通过kubectl打标签" echo "根据自己的节点类型通过kubectl打标签"
ansible new_node -m shell -a 'if [ `lspci |grep -i nvidia|wc -l` -gt 0 ]; then echo "本机是gpu节点,开始打标签" && kubectl label node `hostname`; else echo "cpu节点安装docker"&& apt install docker-ce --allow-unauthenticated -y ; fi' ansible new_node -m shell -a 'if [ `lspci |grep -i nvidia|wc -l` -gt 0 ]; then echo "本机是gpu节点,开始打gpu类型标签" && kubectl label node `hostname` autodl=true kpl=true gpu=true cpu=true user_job_node=true internal_service_node=true; else echo "本机是cpu节点,开始打cpu类型标签"&& kubectl label node `hostname` autodl=true kpl=true cpu=true user_job_node=true internal_service_node=true ; fi'
sleep 3
kubectl get node --show-labels
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!