k3s安装

k3s 安装(依赖docker方式)

k3s 是轻量化的k8s。

Master 节点安装

  • 通用地址curl -sfL https://get.k3s.io | sh -s - --docker
  • 国内加速curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - --docker

查看master的token:sudo cat /var/lib/rancher/k3s/server/node-token

Node 节点安装

  • 通用地址curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -s - --docker
  • 国内加速curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -s - --docker

在master中查看集群状态

$sudo kubectl get nodes
NAME       STATUS                     ROLES                  AGE   VERSION
u18node    Ready                      <none>                 12d   v1.21.4+k3s1
ubuntu18   Ready,SchedulingDisabled   control-plane,master   12d   v1.21.4+k3s1

tips: control-plane,master节点可设置为不参与调度(kubectl cordon ubuntu18),这样任务就不会分配过来。

k3s 停止与启动

Master暂停

sudo systemctl stop k3s
sudo k3s-killall.sh

启动master

sudo k3s server &

停止node

sudo systemctl stop k3s-agent
sudo k3s-killall.sh

启动node(切换master, 需先暂停)

sudo k3s agent -s https://192.168.0.7:6443 -t K10308aa1f752ac60633094d080585c3301a7f351a856814698e53fa517f689da77::server:793fa2d4577dd3e8df71128bdd682124

k3s 卸载

Master节点卸载/usr/local/bin/k3s-uninstall.sh

Node节点卸载/usr/local/bin/k3s-agent-uninstall.sh

k3s使用

参考k8s文档https://kubernetes.io/docs/reference/kubectl/overview/

标签: docker, k3s

添加新评论