技术积累LZ 2019-07-01
K3s是一个轻量的K8s,主要面向IOT、Edge、CI等场景。
Lightweight Kubernetes. 5 less than k8s.K3s和K8s的对比,移除了:
带来了:
## 下载镜像,避免无网络或访问不了gcr.io $ wget https://github.com/rancher/k3s/releases/download/v0.3.0/k3s-airgap-images-amd64.tar $ sudo mkdir -p /var/lib/rancher/k3s/agent/images/ $ sudo cp k3s-airgap-images-amd64.tar /var/lib/rancher/k3s/agent/images/ ## 安装 $ curl -sfL https://get.k3s.io | sh - [INFO] Finding latest release [INFO] Using v0.3.0 as release [INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v0.3.0/sha256sum-amd64.txt [INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v0.3.0/k3s [INFO] Verifying binary download [INFO] Installing k3s to /usr/local/bin/k3s [INFO] Creating /usr/local/bin/kubectl symlink to k3s [INFO] Creating /usr/local/bin/crictl symlink to k3s [INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh [INFO] systemd: Creating environment file /etc/systemd/system/k3s.service.env [INFO] systemd: Creating service file /etc/systemd/system/k3s.service [INFO] systemd: Enabling k3s unit Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service. [INFO] systemd: Starting k3s
完成后就可以用kubectl正常访问k3s:
$ kubectl get pods --all-namespaces kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-7748f7f6df-phxck 1/1 Running 33 38d kube-system helm-install-traefik-8tjss 0/1 Completed 0 51s kube-system svclb-traefik-78cbd58b59-smdf8 2/2 Running 0 51s kube-system traefik-5cc8776646-x9bw9 1/1 Running 0 34s $ kubectl get nodes NAME STATUS ROLES AGE VERSION archlinux Ready <none> 43m48s v1.13.5-k3s.1
注意:K3s默认使用containerd,要使用docker需要设置--docker
:
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--docker" sh -
更多的安装方式和配置可以参考文档。