Notes on k3s

To access the "cluster’s API" server from our local machine, we only need to get the kubeconfig file created on the node during the setup.

$ mkdir ~/k8s
$ cd ~/k8s
$ sudo cat /etc/rancher/k3s/k3s.yaml > k3s.yaml

We then need to change the server key so it references the remote IP address of node1 instead of the localhost.

$ sed -i '' "s/127.0.0.1/$IP/" k3s.yaml

Finally, we configure our local kubectl so it uses the kubeconfig file (k3s.yaml) we’ve just retrieved. A simple way is to set the KUBECONFIG environment variable so it points towards the configuration file.

$ export KUBECONFIG=$PWD/k3s.yaml

And maybe you should put this into your ~/.bashrc