From d5b1a1abe8bf138dd8c40f40e0b561ebd1645858 Mon Sep 17 00:00:00 2001 From: zhanglikun Date: Tue, 30 Jan 2024 15:56:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=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 --- README.md | 15 ++++++++++++++- cluster.sh | 8 ++++---- scripts/download.sh => download.sh | 9 +++++++-- {scripts => init}/init.sh | 2 ++ {scripts => kubeadm}/create_cluster.sh | 0 scripts/kernel_5.4.sh | 5 ----- scripts/nginx_ingress.sh | 4 ---- temp/md5.sum | 2 ++ 8 files changed, 29 insertions(+), 16 deletions(-) rename scripts/download.sh => download.sh (78%) rename {scripts => init}/init.sh (96%) mode change 100755 => 100644 rename {scripts => kubeadm}/create_cluster.sh (100%) delete mode 100755 scripts/kernel_5.4.sh delete mode 100755 scripts/nginx_ingress.sh diff --git a/README.md b/README.md index 208ae16..3bce1d6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # offline-kubernetes-install - 完全离线的情况下, 安装k8s集群, 基于 CentOS7, k8s 1.21.10 版本, 容器运行时 是docker, 安装工具是kubeadm, 全部采用容器化或者rpm包的形式部署, 坚决不使用二进制。 +## 系统要求 + +centos 7 最小化安装, 所有节点之间做好 ssh 免密并成功登录一次 + +提前执行scripts/download.sh下载离线包才可离线安装 + +## 文件介绍 + + | 脚本 | 说明 | | ------------------ | -------------------------------------- | | kernel_5.4.sh | 可选, 安装5.4内核 | @@ -23,3 +31,8 @@ ## 集群部署 前提条件: 代码克隆到 master1 上面, 确保 master1 可以免密访问其他节点 + +修改 cluster.env 配置 + +执行 cluster.sh 进行初始化 + diff --git a/cluster.sh b/cluster.sh index 4f30699..8b065b1 100755 --- a/cluster.sh +++ b/cluster.sh @@ -29,11 +29,11 @@ ssh root@${MASTER2} "cd /tmp/keepalived/ && bash install.sh && cp -r keepalived2 ssh root@${MASTER3} "cd /tmp/keepalived/ && bash install.sh && cp -r keepalived3.conf /etc/keepalived/keepalived.conf && systemctl restart keepalived" # 创建集群 -ssh root@${MASTER1} "cd /tmp/scripts/ && ./init.sh" -ssh root@${MASTER2} "cd /tmp/scripts/ && ./init.sh" -ssh root@${MASTER3} "cd /tmp/scripts/ && ./init.sh" +ssh root@${MASTER1} "cd /tmp/init/ && ./init.sh" +ssh root@${MASTER2} "cd /tmp/init/ && ./init.sh" +ssh root@${MASTER3} "cd /tmp/init/ && ./init.sh" -cd scripts +cd kubeadm ./create_cluster.sh ${API_SERVER} | tee /tmp/install.log # 获取安装信息 diff --git a/scripts/download.sh b/download.sh similarity index 78% rename from scripts/download.sh rename to download.sh index 030276b..7bdf772 100755 --- a/scripts/download.sh +++ b/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 @@ -10,6 +10,9 @@ curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/downlo curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/kubeadm_rpms/kubeadm_rpms.tar.gz curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/keepalived/keepalived.tar.gz curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/bash-completion/bash-completion-2.1-8.el7.noarch.rpm +curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/git/git-2.31.1.tar.gz +curl -OL -C - https://github.com/iuxt/offline-kubernetes-install/releases/download/rsync/rsync-3.1.2-12.el7_9.x86_64.rpm + md5sum -c md5.sum @@ -20,4 +23,6 @@ tar xf kernel_5.4.tar.gz -C ../kernel_5.4/ tar xf kubeadm_images.tar.gz -C ../kubeadm/ tar xf kubeadm_rpms.tar.gz -C ../kubeadm/ tar xf keepalived.tar.gz -C ../keepalived/ -cp bash-completion-2.1-8.el7.noarch.rpm ../kubeadm/ \ No newline at end of file +cp bash-completion-2.1-8.el7.noarch.rpm ../kubeadm/ +tar xf git-2.31.1.tar.gz -C ../init/ +cp rsync-3.1.2-12.el7_9.x86_64.rpm ../init/ diff --git a/scripts/init.sh b/init/init.sh old mode 100755 new mode 100644 similarity index 96% rename from scripts/init.sh rename to init/init.sh index bf4b3cf..d8fb8d3 --- a/scripts/init.sh +++ b/init/init.sh @@ -26,6 +26,8 @@ sudo sysctl --system swapoff -a sed -i 's/.*swap.*/#&/' /etc/fstab +yum install -y ./*.rpm + cd ../docker && bash ./install.sh && cd - cd ../kubeadm && bash ./install.sh && cd - cd ../flannel && bash install.sh diff --git a/scripts/create_cluster.sh b/kubeadm/create_cluster.sh similarity index 100% rename from scripts/create_cluster.sh rename to kubeadm/create_cluster.sh diff --git a/scripts/kernel_5.4.sh b/scripts/kernel_5.4.sh deleted file mode 100755 index f61bb20..0000000 --- a/scripts/kernel_5.4.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# 更新内核, 可选操作 -cd ../kernel_5.4 && bash install.sh && cd - diff --git a/scripts/nginx_ingress.sh b/scripts/nginx_ingress.sh deleted file mode 100755 index 4374044..0000000 --- a/scripts/nginx_ingress.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -euo pipefail - -cd ../ingress-nginx && bash install.sh && cd - diff --git a/temp/md5.sum b/temp/md5.sum index 36bf4a5..41ec856 100644 --- a/temp/md5.sum +++ b/temp/md5.sum @@ -5,3 +5,5 @@ fdb228d3d72b103d856b43d4387b40c9 ingress-nginx.tar.gz 9beba9e40a72d2b5ae4c8616d11fc10e kubeadm_images.tar.gz abcd0f840ce38a38b5201a3fb29d9d10 kubeadm_rpms.tar.gz 5e7034cf2c2420bf799ecfe0720061b3 kernel_5.4.tar.gz +f6ba68c59a78076898c93671ddcf9153 rsync-3.1.2-12.el7_9.x86_64.rpm +676e3cef57a00644233c536752d481e3 git-2.31.1.tar.gz