K3S on Alpine linux

Boot the iso  and run through the normal setup using setup-alpine . Once installed reboot and then disable the swap file: swapoff -a and remove from /etc/fstab. Finally enable cgroups rc-update add cgroups default and reboot.

Then you are ready to setup k3s on the master node

# curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--cluster-cidr=10.244.0.0/16 --no-deploy traefik --no-deploy servicelb" sh -

To get the token from the master: cat /var/lib/rancher/k3s/server/node-token

To setup a node:

# curl -sfL https://get.k3s.io | K3S_URL=https://192.168.50.94:6443 K3S_TOKEN=K10aab442463c3e0272b481a869aca51f9cf1de0d34517df34693d385a1ae85beb5::node:0c31c8bf8ad0fdfcfcf6ec4afffdfa16 sh -
# kubectl get nodes -o wide
NAME       STATUS   ROLES    AGE   VERSION         INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
alpine02   Ready    worker   18m   v1.15.4-k3s.1   192.168.50.95   <none>        Alpine Linux v3.10   4.19.80-0-virt   containerd://1.2.8-k3s.1
alpine01   Ready    master   19m   v1.15.4-k3s.1   192.168.50.94   <none>        Alpine Linux v3.10   4.19.80-0-virt   containerd://1.2.8-k3s.1

To install a LoadBalancer, I use Metallb

# kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml

Setup a configmap of the ip ranges to use

# cat map.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.50.200-192.168.50.209

Finally apply the config map and test the service

# kubectl create -f map.yaml
# cat nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
    - name: http
      port: 80
      targetPort: 80
  selector:
    app: nginx
  type: LoadBalancer
# kubectl create -f nginx.yaml
# kubectl get svc