k3s
Multi master with k3s
Start the first master
curl -sfL https://get.k3s.io | sh -s - --no-deploy=traefik --cluster-init
check the node (you should have one)
kubectl get nodes
Get the token
cat /var/lib/rancher/k3s/server/node-token
Start another master
curl -sfL https://get.k3s.io | sh -s - --no-deploy=traefik --server https://IP:6443 --token "TOKEN"
Enjoy :heart:
Archived
Cool links:
- https://medium.com/@rboulanouar/5fe6c3497a1e1
- https://ahmermansoor.blogspot.com/2019/05/install-lightweight-kubernetes-k3s-with-k3os.html
- https://github.com/rancher/k3os/blob/master/README.md
Questions ? (for me)
- Package manager ? (apt equivalent)
Installation
- Download executable (https://k3os.io/ not https://k3s.io/ if you want k3s as your OS)
- Boot
- Change rancher password :
sudo passwd rancher - Connect with ssh
Setup
- Install OS:
sudo os-config - Special part (Config system with cloud-init file?)
- Install as
server - token or cluster secret will be require when you want to add a new node to your cluster
- One you have installed k3s, you should rechange the password ! (First time you changed it to the OS loaded in ram)
- Try
kubectl get nodes. Finish !
Add ssh key
Here https://github.com/rancher/k3os/blob/master/README.md#configuration-reference there is an example of /var/lib/rancher/k3os/config.yaml which is a file readed at the boot of k3s. It allows you to specify public keys.
ssh_authorized_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2TBZGjE+J8ag11dzkFT58J3XPONrDVmalCNrKxsfADfyy0eqdZrG8hcAxAR/5zuj90Gin2uBR4Sw6Cn4VHsPZcFpXyQCjK1QDADj+WcuhpXOIOY3AB0LZBly9NI0ll+8lo3QtEaoyRLtrMBhQ6Mooy2M3MTG4JNwU9o3yInuqZWf9PvtW6KxMl+ygg1xZkljhemGZ9k0wSrjqif+8usNbzVlCOVQmZwZA+BZxbdcLNwkg7zWJSXzDIXyqM6iWPGXQDEbWLq3+HR1qKucTCSxjbqoe0FD5xcW7NHIME5XKX84yH92n6yn+rxSsyUfhJWYqJd+i0fKf5UbN6qLrtd/D"
Use host kubectl command
You can use kubectl from your host without ssh connection !
For that, you have to get a config file and copy it on your local machine. (Display and copy it is the fast way 😛)
# On k3s
cat /etc/rancher/k3s/k3s.yaml
# On host
mkdir ~/.kube
vim ~/.kube/config
Do not forget to replace localhost with your k3s server ip.
After it, install kubectl on your host machine
# Arch linux
yaourt -S kubectl
# MacOS
brew install kubernetes-cli
kubectl get nodes should work from your host !
Installation of Helm (k8s package manager)
# Arch linux
yaourt -S helm
# MacOS
brew install kubernetes-helm