Setting up a Kubernetes cluster in Proxmox using Ansible
git clone --recurse-submodules -j8 [email protected]:krisunni/ptak.git
Version Check
- Proxmox 8.1.3
- Terraform v1.6.5
- Ansible [core 2.16.1]
-
Scripts to create ubuntu image Download and create Ubuntu VM template image.sh
-
Create hosts using Terraform on Proxmox.
- As of writing, Proxmox 8.1.3 API update is still not fixed in the Telmate/terraform-provider-proxmox #869.
- I am using a forked provider that is added as a submodule.
- Build Proxmox Terraform lib as workaround
- Version Check
- GNU Make 3.81
- go version go1.21.1
- Run this command to build the file.
export VERSION=2.9.14 && cd ./terraform/.terraform/providers/terraform.local/frostyfab && make
- Version Check
-
Update Host IP and Gateway for your network in var
variable "ip" {
default = "192.168.0"
}
variable "gateway" {
default = "192.168.0.1"
}
- Apply Terrafrom to create hosts
cd terraform terraform init terraform apply
- Configure host using Ansible
- Modify Host ip in
- Check if Hosts are ready. Note
ANSIBLE_HOST_KEY_CHECKING
disables host key against the known_hosts file. This is optoinal if known_hosts has all the hosts.ANSIBLE_HOST_KEY_CHECKING=False ansible -i hosts.txt all -u ubuntu -m ping
- Example Output
192.168.0.152 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } 192.168.0.212 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } 192.168.0.211 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } 192.168.0.151 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } 192.168.0.111 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" }
- Example Output
- Optional disables host key against the known_hosts file
export ANSIBLE_HOST_KEY_CHECKING=False
- Install Kubernets and deps
ansible-playbook -i hosts.txt install-kube-deps.yml
- Init Kubernets Cluster in the main host
ansible-playbook -i hosts.txt init-cluster.yml
- Get Join command for Agents from Main
ansible-playbook -i hosts.txt join-command.yml
- Join Agents to Main
ansible-playbook -i hosts.txt join-agents.yml
- Optional Get kube/config