An Ansible playbook that installs Kubernetes.
A guide for using this repo to spin up a Kubernetes cluster is available at Installing your Kubernetes homelab cluster in minutes with Ansible
Code examples originally adapted from https://perdue.dev/installing-your-kubernetes-homelab-cluster-in-minutes-with-ansible/
- containerd
- calico for pod networking
-
Update inventory/dev with IPs for each master/slave nodes
-
Install a Python virtual envrionment:
python3 -m venv ./venv
- Install
ansible
within the venv
python3 -m pip install ansible
- Run
keyscan.py
Output will look like:
['homelabvm1', 'homelabvm2', 'homelabvm3', 'homelabvm4']
# homelabvm1:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# homelabvm2:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# homelabvm4:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
# homelabvm3:22 SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
- Run
ansible -i inventory/dev all -m ping --user ansible
Output will look like:
homelabvm1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
homelabvm2 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
homelabvm3 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
homelabvm4 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
- Run
ansible-playbook -i inventory/dev playbooks/k8s_all.yaml --user ansible