1. 环境
K3S 单 Mater 节点 IP:192.168.10.36
系统:Ubuntu 18.04
k3s:v1.22.5
docker:v20.10.17 # 当时最新版本
关闭 swap:vi /etc/fstab
关闭 se:
关闭 fw:sudo ufw disable(status/enable)
修改主机名:hostnamectl set-hostname k3s-master && su
添加 hosts:vi /etc/hosts
添加内核参数:
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
2. docker 安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
systemctl start docker && systemctl enable docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://4iv7219l.mirror.aliyuncs.com"]
}
systemctl daemon-reload && systemctl restart docker && systemctl status docker
docker version
3. 安装 k3s
指定版本安装:http://49.232.8.65/k3s/
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn INSTALL_K3S_VERSION=v1.22.5+k3s1 sh -s - --docker
4. 安装完检查
[root@k3s-master ~]#service k3s status
● k3s.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-07-17 15:41:22 CST; 58s ago
Docs: https://k3s.io
Process: 12021 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Process: 12016 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
Process: 12014 ExecStartPre=/bin/sh -xc ! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service (code=exited, status=0/SUCCESS)
Main PID: 12025 (k3s-server)
Tasks: 68
CGroup: /system.slice/k3s.service
└─12025 /usr/local/bin/k3s server
......
# 运行配置检查
[root@k3s-master ~]# k3s check-config
......
STATUS: pass
[root@k3s-master ~]#kubectl get node
NAME STATUS ROLES AGE VERSION
k3s-master Ready control-plane,master 2m51s v1.22.5+k3s1
[root@k3s-master ~]#kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system local-path-provisioner-64ffb68fd-dnd59 1/1 Running 0 3m21s
kube-system coredns-85cb69466-8pb2d 1/1 Running 0 3m21s
kube-system helm-install-traefik-crd--1-nwk68 0/1 Completed 0 3m21s
kube-system metrics-server-9cf544f65-9fz58 1/1 Running 0 3m21s
kube-system helm-install-traefik--1-wq66f 0/1 Completed 3 3m21s
kube-system svclb-traefik-2fst5 2/2 Running 0 94s
kube-system traefik-786ff64748-2f6rm 1/1 Running 0 94s