K3S与Docker常用命令

一. 安装docker与k3s

1. 安装Docker

curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh

2. 启动Docer并开机自启

systemctl start docker

systemctl enable docker

3. 查看docker版本

docker version

3. 安装k3s master节点,指定使用docker容器

curl -sfL https://get.k3s.io | sh -s - server --docker

(中国地区加速 <span><strong>curl -sfL https://docs.rancher.cn/k3s/k3s-install.sh </strong><span><strong>| </strong><span><strong>INSTALL_K3S_MIRROR</strong><span><strong>=cn</strong> <strong>sh -s - server --docker</strong></span></span></span></span>)

4. 确认k3s节点信息

kubectl get node -o wide

5. 查看master节点的token(K3S_TOKEN)

cat /var/lib/rancher/k3s/server/node-token

6. 安装k3s worker节点 

<span>curl -sfL https://get.k3s.io <span>| <span>K3S_URL<span>=https://myserver:6443 <span>K3S_TOKEN<span>=XXX <strong>--docker </strong><span>sh -</span></span></span></span></span></span></span>

(中国地区加速 curl -sfL https://docs.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=XXX  --docker sh -)

相关推荐