From adb0301f61ec1d1a3796d427b8a726559005f6cf Mon Sep 17 00:00:00 2001 From: zhanglikun Date: Tue, 12 Sep 2023 22:55:48 +0800 Subject: [PATCH] =?UTF-8?q?single=E5=8D=95=E8=8A=82=E7=82=B9=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=90=9E=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 ---- README.md | 9 ++++++++- scripts/2-create_k8s.sh | 5 ++++- single.env | 2 ++ single.sh | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) delete mode 100644 .env create mode 100644 single.env mode change 100644 => 100755 single.sh diff --git a/.env b/.env deleted file mode 100644 index ddd0a2f..0000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -MASTER1="10.0.0.112" -MASTER2="10.0.0.122" -MASTER3="10.0.0.132" -VIP="10.0.0.32" \ No newline at end of file diff --git a/README.md b/README.md index 8c6d5ca..0553d16 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # offline-kubernetes-install -完全离线的情况下, 安装k8s集群, 基于CentOS7, k8s 1.21.10 版本, 容器运行时 是docker +完全离线的情况下, 安装k8s集群, 基于 CentOS7, k8s 1.21.10 版本, 容器运行时 是docker | 脚本 | 说明 | | ------------------ | -------------------------------------- | @@ -16,3 +16,10 @@ ## 单节点k8s部署 +1. 执行 scripts/0-download.sh 下载需要的包 +2. 修改 single.env 里面的apiserver地址 +3. 执行 single.sh 即可创建集群 + +## 集群部署 + +前提条件: 代码克隆到 master1 上面, 确保 master1 可以免密访问其他节点 diff --git a/scripts/2-create_k8s.sh b/scripts/2-create_k8s.sh index 68d425e..61bd0d1 100755 --- a/scripts/2-create_k8s.sh +++ b/scripts/2-create_k8s.sh @@ -3,7 +3,7 @@ set -euo pipefail apiserver="__API_SERVER__" - +# 初始化集群 sudo kubeadm init \ --kubernetes-version 1.21.10 \ --control-plane-endpoint "${apiserver}:6443" \ @@ -11,10 +11,12 @@ sudo kubeadm init \ --service-cidr=10.96.0.0/12 \ --pod-network-cidr=10.244.0.0/16 +# 配置kubeconfig mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config +# kubectl自动补全 if [ $(grep -c "kubectl completion bash" /root/.bashrc) -eq 0 ];then cat <