Kuberntes Cluster Deployment with Ansible
Kuberntes Cluster Deployment with Ansible
Automate the setup of a Kubernetes cluster using Ansible. We’ll build a single master node and two worker nodes — all provisioned and configured through automation.
🎞️ Watch Video
Prerequisites:
- Ubuntu 22.04 or compatible Linux distribution
- Ansible installed (for running Ansible playbooks)
- Kubernetes knowledge
Create a inventory file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[control_plane]
master-node ansible_host=192.168.X.A
[workers]
worker-node1 ansible_host=192.168.X.B
worker-node2 ansible_host=192.168.X.C
[all:vars]
ansible_python_interpreter=/usr/bin/python3
[control_plane:vars]
ansible_ssh_private_key_file= /root/.ssh/id_rsa
ansible_user=root
[workers:vars]
ansible_ssh_private_key_file= /root/.ssh/id_rsa
ansible_user=root
To set up a gitlab instance, run the following Ansible playbook:
1
2
3
4
5
6
---
- name: Setup Kubernetes Cluster
hosts: all
become: true
roles:
- k8s-cluster-with-ansible
Executing the role to install gitlab server
1
ansible-playbook -i inventory setup_kubernetes.yml
🔗 Reference Links:
This post is licensed under CC BY 4.0 by the author.
