在 pve 中 创建 k8s
准备工作
安装 nano
apt install nano
更改 ssh 配置
nano /etc/ssh/sshd_config
PermitRootLogin yes
systemctl restart ssh
查看 ip
ip a
停用防火墙
systemctl stop firewalld
关掉SELinux防火墙
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
nano /etc/default/grub
cat /etc/selinux/config
update-grub
reboot
安装软件
apt install curl vim wget gnupg apt-transport-https lsb-release ca-certificates -y
安装 docker
wget -O /usr/share/keyrings/docker.asc https://download.docker.com/linux/debian/gpg
echo "deb [signed-by=/usr/share/keyrings/docker.asc] https://download.docker.com/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list
apt update
apt-get install docker-ce docker-ce-cli containerd.io -y
安装 docker-compose
curl -L https://sakitam.oss-cn-beijing.aliyuncs.com/cdn/docker-compose-linux-x86_64 > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
安装 rancher
docker pull rancher/rancher:stable
docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:stable
docker logs fea71c413b46 2>&1 | grep "Bootstrap Password:"
注册 worker 节点
docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.6.6 --server https://192.168.31.246 --token llvhpmwmdtfhbtsgqzwtdh9pw5dwp696kpw66v98f8d846tlzwt6p4 --ca-checksum 5c369817f9071ba91da8a745f7e47808524d0a0b1bdb8fbf83d05a06e6cbe069 --etcd --controlplane --worker