k3s单机部署
配置要求
- cpu 2c+(多线程)
- 内存 4G+
- 数据盘 100G+
- 操作系统 CentOS7
前置条件
github地址:https://github.com/rancher/k3s/releases
- k3s
- k3s-airgap-images-amd64.tar
install最新文件获取地址:https://get.k3s.io/
- install.sh
以上三个离线安装文件在master服务器放在同一目录下
k3s部署
master 安装
#规范修改hostname 为 k3s-master
hostnamectl set-hostname k3s-master
#安装docker
#卸载旧版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
#安装和启动docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
#安装镜像
mkdir -p /var/lib/rancher/k3s/agent/images/
cp k3s-airgap-images-amd64.tar /var/lib/rancher/k3s/agent/images/
docker load -i k3s-airgap-images-amd64.tar
#安装selinux
yum install -y container-selinux selinux-policy-base
yum install -y https://rpm.rancher.io/k3s/stable/common/centos/7/noarch/k3s-selinux-0.2-1.el7_8.noarch.rpm
#禁用开机启动防火墙
systemctl disable firewalld
#永久禁用SELinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux
#关闭系统Swap
sed -i 's/.*swap.*/#&/' /etc/fstab
#安装master
chmod +x k3s
cp k3s /usr/local/bin/
chmod +x install.sh
INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC="--docker --no-deploy traefik" ./install.sh
reboot
查看节点
echo "export KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> ~/.bash_profile
source ~/.bash_profile
kubectl get nodes
kubectl get all -n kube-system
文档更新时间: 2024-04-25 16:35 作者:姚连洲