1 Star 0 Fork 0

日常程序猿/bash-deploy-wlan-k8s

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
wlan-k8s-master.sh 3.41 KB
一键复制 编辑 原始数据 按行查看 历史
日常程序猿 提交于 2023-08-07 14:03 . update wlan-k8s-master.sh.
#!/bin/bash
#chmod 777 wlan-k8s-master.sh
#sudo bash $HOME/wlan-k8s-master.sh
#install docker
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt-get update
sudo apt-get install -y vim
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor > /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo docker run hello-world
#install k8s
apt-get update && apt-get install -y apt-transport-https
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
systemctl enable docker && systemctl start docker
cat <<EOF > daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": ["https://jjqo0rvk.mirror.aliyuncs.com"]
}
EOF
mv daemon.json /etc/docker/
systemctl daemon-reload
systemctl restart docker
sudo apt install selinux-utils
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
swapoff -a
sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab
containerd config default > /etc/containerd/config.toml
sed -i 's#SystemdCgroup = false#SystemdCgroup = true#' /etc/containerd/config.toml
sed -i 's#registry.k8s.io#registry.aliyuncs.com/google_containers#' /etc/containerd/config.toml
sed -i 's#pause:3.6#pause:3.9#' /etc/containerd/config.toml
sudo systemctl restart containerd
#construct cluster
ifconfig | grep -q -w "$(curl -s ifconfig.me)" || sudo ifconfig eth0:1 $(curl -s ifconfig.me) && \
echo -e "auto eth0:1\niface eth0:1 inet static\naddress $(curl -s ifconfig.me)\nnetmask 255.255.255.0" | sudo tee /etc/network/interfaces && \
sudo apt update && \
sudo apt install -y network-manager && \
sudo systemctl start NetworkManager && \
sudo systemctl restart NetworkManager && \
sudo systemctl enable NetworkManager
sudo kubeadm init --apiserver-advertise-address=$(curl -s ifconfig.me) --image-repository=registry.aliyuncs.com/google_containers \
--token-ttl=0 --apiserver-cert-extra-sans=$(ip -4 addr show eth0 | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}') --pod-network-cidr=10.244.0.0/16 --v=6
#revised to make every user can use kubectl
#mkdir -p $HOME/.kube
#sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
#sudo chown $(id -u):$(id -g) $HOME/.kube/config
#export KUBECONFIG=$HOME/.kube/config
#make every user can use kubectl
sudo find /home -maxdepth 1 -type d -exec mkdir -p {}/.kube \;
sudo find /home -maxdepth 1 -type d -exec cp -p /etc/kubernetes/admin.conf {}/.kube/config \;
sudo find /home -maxdepth 1 -type d -exec chmod 777 {}/.kube/config \;
kubectl apply -f https://gitee.com/huhucs/kube-flannel/raw/master/kube-flannel.yml
kubectl get nodes
kubectl get pods -o wide --all-namespaces
kubeadm token create --print-join-command
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/daitape/kube-flannel.git
git@gitee.com:daitape/kube-flannel.git
daitape
kube-flannel
bash-deploy-wlan-k8s
master

搜索帮助