Commit 504352fa by tingweiwang

add_node判断

1 parent 1dd2ca12
Showing with 48 additions and 16 deletions
......@@ -51,21 +51,54 @@ ansible new_node -m shell -a "service flanneld restart"
ansible new_node -m shell -a "service flanneld status"
ansible new_node -m shell -a "systemctl enable flanneld.service"
#############################安装docker############################################
echo "当前harbor仓库地址为$harbor_host,"
sed -i s/harbor_host/$harbor_host/g /root/k8s/config/daemon.json
echo "开始安装docker"
ansible new_node -m shell -a "apt update --allow-insecure-repositories"
ansible new_node -m shell -a "apt install conntrack docker-ce -y --allow-unauthenticated"
echo "拷贝docker.service到新node节点"
ansible new_node -m copy -a "src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
ansible new_node -m shell -a "systemctl daemon-reload"
echo "分发已修改的daemon.json文件"
ansible new_node -m copy -a "src=/root/k8s/config/daemon.json dest=/etc/docker/"
ansible new_node -m shell -a "service docker restart"
ansible new_node -m shell -a "service docker status"
ansible new_node -m shell -a "cat /etc/docker/daemon.json"
echo "还原daemon.json模板文件"
sed -i s/$harbor_host/harbor_host/g /root/k8s/config/daemon.json
echo "判断当前节点是gpu,还是cpu节点,根据节点不同,完成不同操作&& sleep 2"
lspci |grep -i vga |grep -v ASPEED >/dev/null
if [ $? -eq 0 ];then
echo "当前节点是GPU节点,开始按照docker" && sleep 2 && apt install nvidia-docker2 --allow-unauthenticated -y
echo "当前harbor仓库地址为$harbor_host"
sed -i s/harbor_host/$harbor_host/g /root/k8s/config/daemon.json_gpu
echo "开始安装docker"
ansible new_node -m shell -a "apt update --allow-insecure-repositories"
ansible new_node -m shell -a "apt install conntrack docker-ce -y --allow-unauthenticated"
echo "分发已修改的gpu daemon.json文件"
ansible new_node -m copy -a "src=/root/k8s/config/daemon.json_gpu dest=/etc/docker/daemon.json"
ansible new_node -m copy -a "src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
ansible new_node -m shell -a "service docker restart"
ansible new_node -m shell -a "service docker status"
ansible new_node -m shell -a "cat /etc/docker/daemon.json"
echo "还原daemon.json模板文件"
sed -i s/$harbor_host/harbor_host/g /root/k8s/config/daemon.json_gpu
else
echo "当前节点是CPU节点,开始安装配置docker && sleep 2"
echo "当前harbor仓库地址为$harbor_host,"
sed -i s/harbor_host/$harbor_host/g /root/k8s/config/daemon.json_cpu
echo "开始安装docker"
ansible new_node -m shell -a "apt update --allow-insecure-repositories"
ansible new_node -m shell -a "apt install conntrack docker-ce -y --allow-unauthenticated"
echo "分发已修改的daemon.json文件"
ansible new_node -m copy -a "src=/root/k8s/config/daemon.json_cpu dest=/etc/docker/daemon.json"
ansible new_node -m copy -a "src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
ansible new_node -m shell -a "service docker restart"
ansible new_node -m shell -a "service docker status"
ansible new_node -m shell -a "cat /etc/docker/daemon.json"
echo "还原daemon.json模板文件"
sed -i s/$harbor_host/harbor_host/g /root/k8s/config/daemon.json_cpu
fi
#echo "当前harbor仓库地址为$harbor_host,"
#sed -i s/harbor_host/$harbor_host/g /root/k8s/config/daemon.json
#echo "开始安装docker"
#ansible new_node -m shell -a "apt update --allow-insecure-repositories"
#ansible new_node -m shell -a "apt install conntrack docker-ce -y --allow-unauthenticated"
#echo "拷贝docker.service到新node节点"
#ansible new_node -m copy -a "src=/root/k8s/service/docker.service dest=/lib/systemd/system/docker.service mode=755"
#ansible new_node -m shell -a "systemctl daemon-reload"
#echo "分发已修改的daemon.json文件"
#ansible new_node -m copy -a "src=/root/k8s/config/daemon.json dest=/etc/docker/"
#ansible new_node -m shell -a "service docker restart"
#ansible new_node -m shell -a "service docker status"
#ansible new_node -m shell -a "cat /etc/docker/daemon.json"
#echo "还原daemon.json模板文件"
#sed -i s/$harbor_host/harbor_host/g /root/k8s/config/daemon.json
###################################################################################
ansible new_node -m shell -a "apt install nfs-common --allow-unauthenticated"
###########################################################################################
......@@ -139,7 +172,6 @@ KUBE_PROXY_OPTS="--logtostderr=false \
EOF
scp /opt/kubernetes/cfg/kube-proxy.$new_node_ip $new_node_ip:/opt/kubernetes/cfg/kube-proxy
done
##################################################################################
ansible new_node -m copy -a "src=/root/k8s/ssl/kube-proxy.pem dest=/opt/kubernetes/ssl/"
ansible new_node -m copy -a "src=/root/k8s/ssl/kube-proxy-key.pem dest=/opt/kubernetes/ssl/"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!