This playbook will build an HA Kubernetes cluster with k3s
& kube-vip
via ansible
.
- You will need Ansible installed on your machine.
- You should have passwordless SSH access to
server
andagent
nodes
- otherwise you can supply
--ask-pass --ask-become-pass
arguments to provide credentials for each command
- You will need (ideally) 5 machines in one local network, and each of them
- should be running one of the following OS
- Debian
- Ubuntu
- CentOS
- should be on one of the processor architectures
- x64
- arm64
- armhf
- Copy
inventory/sample
directory
cp -R inventory/sample inventory/my-cluster
- Edit
inventory/my-cluster/hosts.ini
to match your environment
- if multiple hosts are in the master group, the playbook will automatically set up k3s in HA mode with etcd
- Edit
inventory/my-cluster/group_vars/all.yml
- Especially put your attention to k3s token. If it isn't changed, your internal kubernetes network can be considered as compromised (because this secret is publicly stored in this repo)
Start provisioning of the cluster using the following command:
ansible-playbook site.yml -i inventory/my-cluster/hosts.ini
After deployment control plane will be accessible via virtual ip-address
which is defined in inventory/group_vars/all.yml as apiserver_endpoint
.
ansible-playbook reset.yml -i inventory/my-cluster/hosts.ini
You should also reboot these nodes due to the VIP not being destroyed
To copy your kube config
locally so that you can access your Kubernetes cluster run:
scp your-user@ip-of-the-master:~/.kube/config ~/.kube/config
See the commands here.
Be sure to see this post on how to troubleshoot common problems.
This repo is just a fork. It wouldn't been possible without these repos and ✨awesome✨ people: