From 327ef5f7778a357591c9f2b35edec42a41604707 Mon Sep 17 00:00:00 2001 From: zhanglikun Date: Tue, 12 Sep 2023 23:12:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 18 +++++++++--------- cluster.sh | 8 ++++---- scripts/{0-config.sh => config.sh} | 2 +- scripts/{2-create_k8s.sh => create_cluster.sh} | 4 ++-- scripts/{0-download.sh => download.sh} | 0 scripts/{1-init.sh => init.sh} | 0 scripts/{0-kernel_5.4.sh => kernel_5.4.sh} | 0 .../{3-nginx_ingress.sh => nginx_ingress.sh} | 0 single.sh | 7 +++---- 9 files changed, 19 insertions(+), 20 deletions(-) rename scripts/{0-config.sh => config.sh} (82%) rename scripts/{2-create_k8s.sh => create_cluster.sh} (88%) rename scripts/{0-download.sh => download.sh} (100%) rename scripts/{1-init.sh => init.sh} (100%) rename scripts/{0-kernel_5.4.sh => kernel_5.4.sh} (100%) rename scripts/{3-nginx_ingress.sh => nginx_ingress.sh} (100%) diff --git a/README.md b/README.md index 71105d1..208ae16 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ # offline-kubernetes-install -完全离线的情况下, 安装k8s集群, 基于 CentOS7, k8s 1.21.10 版本, 容器运行时 是docker +完全离线的情况下, 安装k8s集群, 基于 CentOS7, k8s 1.21.10 版本, 容器运行时 是docker, 安装工具是kubeadm, 全部采用容器化或者rpm包的形式部署, 坚决不使用二进制。 | 脚本 | 说明 | | ------------------ | -------------------------------------- | -| 0-kernel_5.4.sh | 可选, 安装5.4内核 | +| kernel_5.4.sh | 可选, 安装5.4内核 | | 0-config.sh | 修改里面的配置, 然后执行 | -| 0-download.sh | 下载离线包, 支持断点续传 | -| 1-init.sh | 初始化配置, 所有节点都需要执行 | -| 2-create_k8s.sh | 创建集群, 只需要在一台master上执行即可 | -| 3-nginx_ingress.sh | 安装nginx-ingress | +| download.sh | 下载离线包, 支持断点续传 | +| init.sh | 初始化配置, 所有节点都需要执行 | +| create_cluster.sh | 创建集群, 只需要在一台master上执行即可 | +| nginx_ingress.sh | 安装nginx-ingress | -事先执行`0-download.sh`下载好离线包到`master1`上面 -5.4内核看个人需求是否执行, 如需更新, 执行 `scripts/0-kernel_5.4.sh` +事先执行`download.sh`下载好离线包到`master1`上面 +5.4内核看个人需求是否执行, 如需更新, 执行 `scripts/kernel_5.4.sh` ## 单节点k8s部署 -1. 执行 scripts/0-download.sh 下载需要的包 +1. 执行 scripts/download.sh 下载需要的包 2. 修改 single.env 里面的apiserver地址 3. 执行 single.sh 即可创建集群 diff --git a/cluster.sh b/cluster.sh index 686c69e..81dc23d 100755 --- a/cluster.sh +++ b/cluster.sh @@ -9,7 +9,7 @@ if [ $(id -u) != "0" ]; then fi cd scripts -./1-init.sh -sed -e "s/^apiserver=.*/apiserver=${VIP}/g" -i 2-create_k8s.sh -./2-create_k8s.sh -./3-nginx_ingress.sh +./init.sh +sed -e "s/^apiserver=.*/apiserver=${VIP}/g" -i create_cluster.sh +./create_cluster.sh +./nginx_ingress.sh diff --git a/scripts/0-config.sh b/scripts/config.sh similarity index 82% rename from scripts/0-config.sh rename to scripts/config.sh index fdb0e58..5c2c098 100755 --- a/scripts/0-config.sh +++ b/scripts/config.sh @@ -11,5 +11,5 @@ sed -e "s/__MASTER1__/${MASTER1}/g" \ -i keepalived/*.conf # 修改脚本内VIP -sed -e "s/__API_SERVER__/${VIP}/g" -i 2-create_k8s.sh +sed -e "s/__API_SERVER__/${VIP}/g" -i create_cluster.sh diff --git a/scripts/2-create_k8s.sh b/scripts/create_cluster.sh similarity index 88% rename from scripts/2-create_k8s.sh rename to scripts/create_cluster.sh index 61bd0d1..1dc46b5 100755 --- a/scripts/2-create_k8s.sh +++ b/scripts/create_cluster.sh @@ -1,12 +1,12 @@ #!/bin/bash set -euo pipefail -apiserver="__API_SERVER__" +source ../single.env # 初始化集群 sudo kubeadm init \ --kubernetes-version 1.21.10 \ - --control-plane-endpoint "${apiserver}:6443" \ + --control-plane-endpoint "${API_SERVER}:6443" \ --upload-certs \ --service-cidr=10.96.0.0/12 \ --pod-network-cidr=10.244.0.0/16 diff --git a/scripts/0-download.sh b/scripts/download.sh similarity index 100% rename from scripts/0-download.sh rename to scripts/download.sh diff --git a/scripts/1-init.sh b/scripts/init.sh similarity index 100% rename from scripts/1-init.sh rename to scripts/init.sh diff --git a/scripts/0-kernel_5.4.sh b/scripts/kernel_5.4.sh similarity index 100% rename from scripts/0-kernel_5.4.sh rename to scripts/kernel_5.4.sh diff --git a/scripts/3-nginx_ingress.sh b/scripts/nginx_ingress.sh similarity index 100% rename from scripts/3-nginx_ingress.sh rename to scripts/nginx_ingress.sh diff --git a/single.sh b/single.sh index 30632ab..2e48129 100755 --- a/single.sh +++ b/single.sh @@ -9,7 +9,6 @@ if [ $(id -u) != "0" ]; then fi cd scripts -./1-init.sh -sed -e "s/^apiserver=.*/apiserver=${API_SERVER}/g" -i 2-create_k8s.sh -./2-create_k8s.sh -./3-nginx_ingress.sh +./init.sh +./create_cluster.sh +./nginx_ingress.sh