Skip to content

Instantly share code, notes, and snippets.

@imsmith
Forked from ruanbekker/k3s_on_alpine.md
Created June 20, 2021 00:46
Show Gist options
  • Save imsmith/1c51a8f80b5bcb3c86596ede49cf6825 to your computer and use it in GitHub Desktop.
Save imsmith/1c51a8f80b5bcb3c86596ede49cf6825 to your computer and use it in GitHub Desktop.
Install k3s on Alpine Linux
$ apk add --no-cache curl
$ echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab

$ cat > /etc/cgconfig.conf <<EOF
mount {
  cpuacct = /cgroup/cpuacct;
  memory = /cgroup/memory;
  devices = /cgroup/devices;
  freezer = /cgroup/freezer;
  net_cls = /cgroup/net_cls;
  blkio = /cgroup/blkio;
  cpuset = /cgroup/cpuset;
  cpu = /cgroup/cpu;
}
EOF

$ sed -i 's/default_kernel_opts="pax_nouderef quiet rootfstype=ext4"/default_kernel_opts="pax_nouderef quiet rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory"/g' /etc/update-extlinux.conf

$ update-extlinux
$ reboot
$ apk add --no-cache cni-plugins --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
$ export PATH=$PATH:/usr/share/cni-plugins/bin
$ echo -e '#!/bin/sh\nexport PATH=$PATH:/usr/share/cni-plugins/bin' > /etc/profile.d/cni.sh
$ apk add iptables
$ wget https://github.com/rancher/k3s/releases/download/v1.17.4%2Bk3s1/k3s
$ mv k3s /usr/bin/
$ chmod +x /usr/bin/k3s

or

$ curl -sfL https://get.k3s.io | sh -
$ kubectl get nodes
NAME     STATUS   ROLES    AGE     VERSION
server   Ready    master   3m40s   v1.17.4+k3s1

# token: /var/lib/rancher/k3s/server/node-token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment