Skip to content

Instantly share code, notes, and snippets.

@kennyhyun
Last active October 31, 2023 11:43
Show Gist options
  • Save kennyhyun/badef207c5c2604da30057529fe9a7f7 to your computer and use it in GitHub Desktop.
Save kennyhyun/badef207c5c2604da30057529fe9a7f7 to your computer and use it in GitHub Desktop.
Installing and setting up k3s single node

Installing and setting up k3s single node

K3s - Lightweight Kubernetes

k8s is 10-char-word but k3s is 5-char-word which is half.

Install

See https://docs.k3s.io/quick-start#install-script

curl -sfL https://get.k3s.io | sh -

To set up credentials and adjust permissions

Initiall it's only allowed to root account

So kubectl from user account will fail

$ k3s kubectl version
WARN[0000] Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify kube config permissions 
error: error loading config file "/etc/rancher/k3s/k3s.yaml" : open /etc/rancher/k3s/k3s.yaml: permission denied

To use kubectl from your account, see this

set KUBECONFIG

put following in either .profile, .zshrc, .bashrc

export KUBECONFIG=~/.kube/config

to make it applied, do either

  • source ~/.zshrc
  • sudo su - $USER
  • reconnect ssh

create .kube

mkdir ~/.kube 2> /dev/null
sudo chown $USER:$USER ~/.kube
sudo k3s kubectl config view --raw | tee ~/.kube/config
chmod 600 "$KUBECONFIG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment