single单节点部署搞定
This commit is contained in:
parent
bbbd644c88
commit
adb0301f61
4
.env
4
.env
@ -1,4 +0,0 @@
|
|||||||
MASTER1="10.0.0.112"
|
|
||||||
MASTER2="10.0.0.122"
|
|
||||||
MASTER3="10.0.0.132"
|
|
||||||
VIP="10.0.0.32"
|
|
@ -16,3 +16,10 @@
|
|||||||
|
|
||||||
## 单节点k8s部署
|
## 单节点k8s部署
|
||||||
|
|
||||||
|
1. 执行 scripts/0-download.sh 下载需要的包
|
||||||
|
2. 修改 single.env 里面的apiserver地址
|
||||||
|
3. 执行 single.sh 即可创建集群
|
||||||
|
|
||||||
|
## 集群部署
|
||||||
|
|
||||||
|
前提条件: 代码克隆到 master1 上面, 确保 master1 可以免密访问其他节点
|
||||||
|
@ -3,7 +3,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
apiserver="__API_SERVER__"
|
apiserver="__API_SERVER__"
|
||||||
|
|
||||||
|
# 初始化集群
|
||||||
sudo kubeadm init \
|
sudo kubeadm init \
|
||||||
--kubernetes-version 1.21.10 \
|
--kubernetes-version 1.21.10 \
|
||||||
--control-plane-endpoint "${apiserver}:6443" \
|
--control-plane-endpoint "${apiserver}:6443" \
|
||||||
@ -11,10 +11,12 @@ sudo kubeadm init \
|
|||||||
--service-cidr=10.96.0.0/12 \
|
--service-cidr=10.96.0.0/12 \
|
||||||
--pod-network-cidr=10.244.0.0/16
|
--pod-network-cidr=10.244.0.0/16
|
||||||
|
|
||||||
|
# 配置kubeconfig
|
||||||
mkdir -p $HOME/.kube
|
mkdir -p $HOME/.kube
|
||||||
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
||||||
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
||||||
|
|
||||||
|
# kubectl自动补全
|
||||||
if [ $(grep -c "kubectl completion bash" /root/.bashrc) -eq 0 ];then
|
if [ $(grep -c "kubectl completion bash" /root/.bashrc) -eq 0 ];then
|
||||||
cat <<EOF | sudo tee -a /root/.bashrc
|
cat <<EOF | sudo tee -a /root/.bashrc
|
||||||
source /usr/share/bash-completion/bash_completion
|
source /usr/share/bash-completion/bash_completion
|
||||||
@ -22,4 +24,5 @@ source <(kubectl completion bash)
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 安装flannel
|
||||||
cd ../flannel && bash install.sh && cd -
|
cd ../flannel && bash install.sh && cd -
|
||||||
|
2
single.env
Normal file
2
single.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 单节点 填自己的IP地址
|
||||||
|
API_SERVER="10.0.0.32"
|
4
single.sh
Normal file → Executable file
4
single.sh
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
VIP="10.0.0.32"
|
source single.env
|
||||||
|
|
||||||
if [ $(id -u) != "0" ]; then
|
if [ $(id -u) != "0" ]; then
|
||||||
echo "Error: You must be root to run this script"
|
echo "Error: You must be root to run this script"
|
||||||
@ -10,6 +10,6 @@ fi
|
|||||||
|
|
||||||
cd scripts
|
cd scripts
|
||||||
./1-init.sh
|
./1-init.sh
|
||||||
sed -e "s/^apiserver=.*/apiserver=${VIP}/g" -i 2-create_k8s.sh
|
sed -e "s/^apiserver=.*/apiserver=${API_SERVER}/g" -i 2-create_k8s.sh
|
||||||
./2-create_k8s.sh
|
./2-create_k8s.sh
|
||||||
./3-nginx_ingress.sh
|
./3-nginx_ingress.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user