AutoKube is a fully automated Kubernetes cluster orchestration project built using Ansible. It provisions and configures a production-ready multi-node Kubernetes cluster using role-based architecture and idempotent automation.
The entire cluster lifecycle is orchestrated through a single master playbook (server.yaml), ensuring safe variable sharing (such as the dynamic kubeadm join token) across plays.
+---------------------------+
| Local Machine |
| (Ansible Control Node) |
+-------------+-------------+
|
| SSH
v
+---------------------------------------------+
| AWS EC2 |
|---------------------------------------------|
| Control Plane Node (master) |
| - kubeadm init |
| - API Server |
| - Controller Manager |
| - Scheduler |
| - Calico CNI |
| |
| Worker Node 1 |
| - kubeadm join |
| |
| Worker Node 2 |
| - kubeadm join |
| |
| (Add as many workers as needed) |
+---------------------------------------------+
- Ansible - Infrastructure Automation
- Kubernetes (kubeadm) - Cluster Bootstrap
- containerd - Container Runtime
- Calico - Kubernetes Networking (CNI)
- Ubuntu EC2 Instances - Infrastructure Layer
ansible/
├── ansible.cfg
├── inventory/
│ └── hosts.ini
├── group_vars/
│ ├── all.yaml
│ └── masters.yaml
├── playbooks/
│ ├── common.yaml
│ ├── master.yaml
│ ├── worker.yaml
│ └── server.yaml # 🔥 Main orchestration playbook
└── roles/
├── common/ # OS preparation
├── containerd/ # Container runtime setup
├── kubeadm/ # Kubernetes binaries installation
├── master/ # kubeadm init + CNI
└── worker/ # Automated worker join
To orchestrate the entire cluster lifecycle, you must run:
ansible-playbook playbooks/server.yamlThis ensures:
- Safe execution order
- Variable sharing between plays
- Fully automated cluster provisioning
- Disables swap (runtime + persistent)
- Configures kernel modules
- Applies Kubernetes-required sysctl parameters
- Installs base packages
- Installs containerd
- Configures systemd cgroups
- Installs CNI plugins
- Installs kubelet, kubeadm, kubectl
- Pins versions
- Configures crictl
- Enables kubelet
- Executes
kubeadm init - Configures kubeconfig
- Installs Calico networking
- Dynamically generates join command
- Shares token across plays
- Joins workers idempotently
- Safe to re-run
To scale horizontally:
- Add additional EC2 instances.
- Update
inventory/hosts.ini:
[workers]
worker1 ansible_host=<IP1>
worker2 ansible_host=<IP2>
worker3 ansible_host=<IP3>
worker4 ansible_host=<IP4>- Run:
ansible-playbook playbooks/server.yamlNew nodes will automatically join the cluster.
[masters]
master ansible_host=<MASTER_IP>
[workers]
worker1 ansible_host=<WORKER1_IP>
worker2 ansible_host=<WORKER2_IP>
[all:vars]
ansible_user=ubuntu
ansible_ssh_private_key_file=/path/to/keyansible-playbook playbooks/server.yamlOn master:
kubectl get nodesExpected:
master Ready control-plane
worker1 Ready
worker2 Ready
- Fully idempotent
- Role-based modular structure
- Version pinned Kubernetes components
- Safe re-runs
- Clean orchestration flow
- Production-style Ansible architecture