From 19766ba1a16c4328899e176c16f21aa4b7aaf890 Mon Sep 17 00:00:00 2001 From: zhanglikun Date: Tue, 12 Sep 2023 17:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E6=96=87=E4=BB=B6=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 -- scripts/0-config.sh | 5 ++++- scripts/0-kernel_5.4.sh | 2 +- scripts/1-init.sh | 4 ++-- scripts/2-create_k8s.sh | 2 +- scripts/3-nginx_ingress.sh | 2 +- single.sh | 18 ++++++++++++++++++ 7 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 single.sh 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