2020-04-24 21:21:08 +00:00
|
|
|
k3s - Lightweight Kubernetes
|
2019-01-22 23:06:42 +00:00
|
|
|
===============================================
|
|
|
|
|
2020-04-24 21:21:08 +00:00
|
|
|
Lightweight Kubernetes. Easy to install, half the memory, all in a binary less than 100 MB.
|
2019-01-22 23:06:42 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
Great for:
|
|
|
|
|
2019-01-22 23:06:42 +00:00
|
|
|
* Edge
|
|
|
|
* IoT
|
|
|
|
* CI
|
2020-04-24 21:21:08 +00:00
|
|
|
* Development
|
2019-01-22 23:06:42 +00:00
|
|
|
* ARM
|
2020-05-04 17:11:42 +00:00
|
|
|
* Embedding k8s
|
2019-01-22 23:06:42 +00:00
|
|
|
* Situations where a PhD in k8s clusterology is infeasible
|
|
|
|
|
|
|
|
What is this?
|
|
|
|
---
|
|
|
|
|
2020-04-24 21:21:08 +00:00
|
|
|
k3s is a fully compliant Kubernetes distribution with the following changes:
|
2019-01-22 23:06:42 +00:00
|
|
|
|
2020-05-04 17:11:42 +00:00
|
|
|
1. Packaged as a single binary.
|
2020-04-24 21:21:08 +00:00
|
|
|
1. Lightweight storage backend based on sqlite3 as the default storage mechanism. etcd3, MySQL, Postgres also still available.
|
|
|
|
1. Wrapped in simple launcher that handles a lot of the complexity of TLS and options.
|
|
|
|
1. Secure by default with reasonable defaults for lightweight environments.
|
|
|
|
1. Minimal to no OS dependencies (just a sane kernel and cgroup mounts needed). k3s packages required
|
2019-01-22 23:06:42 +00:00
|
|
|
dependencies
|
|
|
|
* containerd
|
|
|
|
* Flannel
|
|
|
|
* CoreDNS
|
|
|
|
* CNI
|
|
|
|
* Host utilities (iptables, socat, etc)
|
2020-04-24 21:21:08 +00:00
|
|
|
* Ingress controller (traefik)
|
|
|
|
* Embedded service loadbalancer
|
|
|
|
* Embedded network policy controller
|
|
|
|
|
|
|
|
What's with the name?
|
|
|
|
--------------------
|
|
|
|
We wanted an installation of Kubernetes that was half the size in terms of memory footprint. Kubernetes is a
|
|
|
|
10 letter word stylized as k8s. So something half as big as Kubernetes would be a 5 letter word stylized as
|
|
|
|
k3s. There is no long form of k3s and no official pronunciation.
|
2019-03-12 12:47:22 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
Documentation
|
2019-01-22 23:06:42 +00:00
|
|
|
-------------
|
|
|
|
|
2019-07-17 19:46:05 +00:00
|
|
|
Please see [the official docs site](https://rancher.com/docs/k3s/latest/en/) for complete documentation on k3s.
|
2019-01-22 23:06:42 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
Quick-Start - Install Script
|
|
|
|
--------------
|
2020-03-04 09:47:40 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
The k3s `install.sh` script provides a convenient way for installing to systemd or openrc,
|
|
|
|
to install k3s as a service just run:
|
2020-03-04 09:47:40 +00:00
|
|
|
|
2019-01-22 23:06:42 +00:00
|
|
|
```bash
|
2019-03-06 23:02:23 +00:00
|
|
|
curl -sfL https://get.k3s.io | sh -
|
|
|
|
```
|
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
A kubeconfig file is written to `/etc/rancher/k3s/k3s.yaml` and the service is automatically started or restarted.
|
|
|
|
The install script will install k3s and additional utilities, such as `kubectl`, `crictl`, `k3s-killall.sh`, and `k3s-uninstall.sh`, for example:
|
2019-04-26 19:10:27 +00:00
|
|
|
|
|
|
|
```bash
|
2019-07-17 19:44:32 +00:00
|
|
|
sudo kubectl get nodes
|
2019-04-26 19:10:27 +00:00
|
|
|
```
|
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
`K3S_TOKEN` is created at `/var/lib/rancher/k3s/server/node-token` on your server.
|
|
|
|
To install on worker nodes we should pass `K3S_URL` along with
|
|
|
|
`K3S_TOKEN` or `K3S_CLUSTER_SECRET` environment variables, for example:
|
2020-03-04 09:47:40 +00:00
|
|
|
|
2019-04-26 19:10:27 +00:00
|
|
|
```bash
|
2019-07-17 19:44:32 +00:00
|
|
|
curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=XXX sh -
|
2019-04-26 19:10:27 +00:00
|
|
|
```
|
2019-03-06 23:02:23 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
Manual Download
|
2019-03-29 23:39:09 +00:00
|
|
|
---------------
|
2020-03-04 09:47:40 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
1. Download `k3s` from latest [release](https://github.com/rancher/k3s/releases/latest), x86_64, armhf, and arm64 are supported.
|
|
|
|
2. Run server.
|
2019-03-29 23:39:09 +00:00
|
|
|
|
2019-07-17 19:44:32 +00:00
|
|
|
```bash
|
|
|
|
sudo k3s server &
|
|
|
|
# Kubeconfig is written to /etc/rancher/k3s/k3s.yaml
|
|
|
|
sudo k3s kubectl get nodes
|
2019-05-02 20:11:31 +00:00
|
|
|
|
2020-03-04 09:47:40 +00:00
|
|
|
# On a different node run the below. NODE_TOKEN comes from
|
2019-07-17 19:44:32 +00:00
|
|
|
# /var/lib/rancher/k3s/server/node-token on your server
|
|
|
|
sudo k3s agent --server https://myserver:6443 --token ${NODE_TOKEN}
|
2019-06-13 22:12:19 +00:00
|
|
|
```
|
2020-03-04 09:47:40 +00:00
|
|
|
|