This is the playbook I created to setup my k3s cluster.
This playbook is built using some community projects as well as some created by myself.
- https://github.com/k3s-io/k3s-ansible - The playbook on which this is was built on top of.
- https://github.com/racqspace/ansible-role-longhorn - Community built role for installing longhorn into a cluster. (not currently deployed due to helm chart issue)
- https://galaxy.ansible.com/kubernetes/core - Very useful collection for managing k8s clusters.
Deployment environment must have Ansible 2.4.0+ Master and nodes must have passwordless SSH access
First create a new directory based on the sample
directory within the inventory
directory:
cp -R inventory/sample inventory/my-cluster
Second, edit inventory/my-cluster/hosts.ini
to match the system information gathered above. For example:
[master]
192.168.1.26
[node]
192.168.1.34
192.168.1.39
192.168.1.16
192.168.1.32
# Group of 1 machine that will run the kubectl commands for helm deployments, etc.
[k3s_exec]
192.168.1.26
[k3s_cluster:children]
master
node
If needed, you can also edit inventory/my-cluster/group_vars/all.yml
to match your environment.
Start provisioning of the cluster using the following command:
ansible-playbook site.yml -i inventory/my-cluster/hosts.ini
To get access to your Kubernetes cluster just
scp username@master_ip:~/.kube/config ~/.kube/config