From bb0cf1697d3e53a966a0937aa12dfb1b1a2d1143 Mon Sep 17 00:00:00 2001 From: zhanglikun Date: Tue, 12 Sep 2023 17:28:07 +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 ++ 0-kernel_5.4.sh | 4 ---- README.md | 6 ++++++ docker/install.sh | 3 +++ flannel/install.sh | 3 +++ ingress-nginx/install.sh | 3 +++ keepalived/install.sh | 1 + kubeadm/install.sh | 2 ++ 0-config.sh => scripts/0-config.sh | 0 0-download.sh => scripts/0-download.sh | 2 +- scripts/0-kernel_5.4.sh | 5 +++++ 1-init.sh => scripts/1-init.sh | 1 + 2-create_k8s.sh => scripts/2-create_k8s.sh | 4 ++++ 3-nginx_ingress.sh => scripts/3-nginx_ingress.sh | 1 + 14 files changed, 32 insertions(+), 5 deletions(-) delete mode 100755 0-kernel_5.4.sh rename 0-config.sh => scripts/0-config.sh (100%) rename 0-download.sh => scripts/0-download.sh (98%) create mode 100755 scripts/0-kernel_5.4.sh rename 1-init.sh => scripts/1-init.sh (97%) rename 2-create_k8s.sh => scripts/2-create_k8s.sh (94%) rename 3-nginx_ingress.sh => scripts/3-nginx_ingress.sh (76%) diff --git a/.env b/.env index ddd0a2f..ce2d672 100644 --- a/.env +++ b/.env @@ -1,3 +1,5 @@ +MODE="single" +# MODE="cluster" MASTER1="10.0.0.112" MASTER2="10.0.0.122" MASTER3="10.0.0.132" diff --git a/0-kernel_5.4.sh b/0-kernel_5.4.sh deleted file mode 100755 index aecab52..0000000 --- a/0-kernel_5.4.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# 更新内核, 可选操作 -cd kernel_5.4 && bash install.sh && cd .. diff --git a/README.md b/README.md index f308078..8c6d5ca 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,9 @@ | 1-init.sh | 初始化配置, 所有节点都需要执行 | | 2-create_k8s.sh | 创建集群, 只需要在一台master上执行即可 | | 3-nginx_ingress.sh | 安装nginx-ingress | + +事先执行0-download.sh下载好离线包到master1上面 +5.4内核看个人需求是否执行 + +## 单节点k8s部署 + diff --git a/docker/install.sh b/docker/install.sh index ba1453b..56d4672 100644 --- a/docker/install.sh +++ b/docker/install.sh @@ -1,4 +1,7 @@ #!/bin/bash +set -euo pipefail + + yum install -y docker-ce-20.10/*.rpm sudo mkdir /etc/docker diff --git a/flannel/install.sh b/flannel/install.sh index 3591dcf..830dc02 100644 --- a/flannel/install.sh +++ b/flannel/install.sh @@ -1,3 +1,6 @@ #!/bin/bash +set -euo pipefail + + ls *.tar | xargs -I {} docker load -i {} kubectl apply -f ./kube-flannel.yml diff --git a/ingress-nginx/install.sh b/ingress-nginx/install.sh index 74a3681..63b467c 100644 --- a/ingress-nginx/install.sh +++ b/ingress-nginx/install.sh @@ -1,4 +1,7 @@ #!/bin/bash +set -euo pipefail + + ls *.tar | xargs -I {} docker load -i {} kubectl taint node $(hostname) node-role.kubernetes.io/master- kubectl apply -f ./nginx-ingress-daemonset.yaml diff --git a/keepalived/install.sh b/keepalived/install.sh index 22c6679..e7233f3 100644 --- a/keepalived/install.sh +++ b/keepalived/install.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail yum install -y ./*.rpm systemctl enable --now keepalived \ No newline at end of file diff --git a/kubeadm/install.sh b/kubeadm/install.sh index d5d0787..8414d0f 100644 --- a/kubeadm/install.sh +++ b/kubeadm/install.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -euo pipefail + yum install -y ./*.rpm ls *.tar | xargs -I {} docker load -i {} systemctl enable --now kubelet diff --git a/0-config.sh b/scripts/0-config.sh similarity index 100% rename from 0-config.sh rename to scripts/0-config.sh diff --git a/0-download.sh b/scripts/0-download.sh similarity index 98% rename from 0-download.sh rename to scripts/0-download.sh index a27663a..4f9fb46 100755 --- a/0-download.sh +++ b/scripts/0-download.sh @@ -1,7 +1,7 @@ #!/bin/bash set -euo pipefail -cd temp/ +cd ../temp/ curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/docker-ce-20.10.23-3.el7.x86_64/docker-ce-20.10.tar.gz curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/flannel/flannel.tar.gz curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/ingress-nginx/ingress-nginx.tar.gz diff --git a/scripts/0-kernel_5.4.sh b/scripts/0-kernel_5.4.sh new file mode 100755 index 0000000..497f057 --- /dev/null +++ b/scripts/0-kernel_5.4.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -euo pipefail + +# 更新内核, 可选操作 +cd ../kernel_5.4 && bash install.sh && cd .. diff --git a/1-init.sh b/scripts/1-init.sh similarity index 97% rename from 1-init.sh rename to scripts/1-init.sh index bdd12fe..661b739 100755 --- a/1-init.sh +++ b/scripts/1-init.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script" diff --git a/2-create_k8s.sh b/scripts/2-create_k8s.sh similarity index 94% rename from 2-create_k8s.sh rename to scripts/2-create_k8s.sh index fe17eb2..1e16fa5 100755 --- a/2-create_k8s.sh +++ b/scripts/2-create_k8s.sh @@ -1,4 +1,8 @@ #!/bin/bash +set -euo pipefail + +source .env + apiserver="__API_SERVER__" diff --git a/3-nginx_ingress.sh b/scripts/3-nginx_ingress.sh similarity index 76% rename from 3-nginx_ingress.sh rename to scripts/3-nginx_ingress.sh index 5e4f20b..22e0aa9 100755 --- a/3-nginx_ingress.sh +++ b/scripts/3-nginx_ingress.sh @@ -1,3 +1,4 @@ #!/bin/bash +set -euo pipefail cd ingress-nginx && bash install.sh && cd ..