共计 1747 个字符,预计需要花费 5 分钟才能阅读完成。
K3s 是一个轻量的 K8s,主要面向 IOT、Edge、CI 等场景。
Lightweight Kubernetes. 5 less than k8s.
K3s 和 K8s 的对比,移除了:
非默认的、遗留的特性
Alpha 阶段的特性
In-tree 的云服务提供商
In-tree 的存储驱动
Docker (可选)
带来了:
简化安装
SQLite3 支持,替代 etcd
TLS 管理
自动的 Manifest 和 Helm Chart 管理
containerd, CoreDNS, Flannel
快速安装
## 下载镜像,避免无网络或访问不了 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 –
更多的安装方式和配置可以参考文档。