diff --git a/.env b/.env index ce2d672..ddd0a2f 100644 --- a/.env +++ b/.env @@ -1,5 +1,3 @@ -MODE="single" -# MODE="cluster" MASTER1="10.0.0.112" MASTER2="10.0.0.122" MASTER3="10.0.0.132" diff --git a/scripts/0-config.sh b/scripts/0-config.sh index fe8eef6..fdb0e58 100755 --- a/scripts/0-config.sh +++ b/scripts/0-config.sh @@ -3,10 +3,13 @@ set -euo pipefail source .env +# 生成keepalived配置文件 sed -e "s/__MASTER1__/${MASTER1}/g" \ -e "s/__MASTER2__/${MASTER2}/g" \ -e "s/__MASTER3__/${MASTER3}/g" \ -e "s/__VIP__/${VIP}/g" \ -i keepalived/*.conf -sed -e "s/__API_SERVER__/${VIP}/g" -i 2-create_k8s.sh \ No newline at end of file +# 修改脚本内VIP +sed -e "s/__API_SERVER__/${VIP}/g" -i 2-create_k8s.sh + diff --git a/scripts/0-kernel_5.4.sh b/scripts/0-kernel_5.4.sh index 497f057..f61bb20 100755 --- a/scripts/0-kernel_5.4.sh +++ b/scripts/0-kernel_5.4.sh @@ -2,4 +2,4 @@ set -euo pipefail # 更新内核, 可选操作 -cd ../kernel_5.4 && bash install.sh && cd .. +cd ../kernel_5.4 && bash install.sh && cd - diff --git a/scripts/1-init.sh b/scripts/1-init.sh index 661b739..03a88a2 100755 --- a/scripts/1-init.sh +++ b/scripts/1-init.sh @@ -26,6 +26,6 @@ sudo sysctl --system swapoff -a sed -i 's/.*swap.*/#&/' /etc/fstab -cd ./docker && bash ./install.sh && cd .. -cd ./kubeadm && bash ./install.sh && cd .. +cd ../docker && bash ./install.sh && cd - +cd ../kubeadm && bash ./install.sh && cd - diff --git a/scripts/2-create_k8s.sh b/scripts/2-create_k8s.sh index 1e16fa5..1716395 100755 --- a/scripts/2-create_k8s.sh +++ b/scripts/2-create_k8s.sh @@ -25,4 +25,4 @@ source <(kubectl completion bash) EOF fi -cd flannel && bash install.sh && cd .. +cd ../flannel && bash install.sh && cd - diff --git a/scripts/3-nginx_ingress.sh b/scripts/3-nginx_ingress.sh index 22e0aa9..4374044 100755 --- a/scripts/3-nginx_ingress.sh +++ b/scripts/3-nginx_ingress.sh @@ -1,4 +1,4 @@ #!/bin/bash set -euo pipefail -cd ingress-nginx && bash install.sh && cd .. +cd ../ingress-nginx && bash install.sh && cd - diff --git a/single.sh b/single.sh new file mode 100644 index 0000000..925ad73 --- /dev/null +++ b/single.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -euo pipefail + +VIP="10.0.0.32" + +if [ $(id -u) != "0" ]; then + echo "Error: You must be root to run this script" + exit 1 +fi + +source .env + + +cd scripts +./1-init.sh +sed -e "s/__API_SERVER__/${VIP}/g" -i 2-create_k8s.sh +./2-create_k8s.sh +./3-nginx_ingress.sh