Skip to content

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.

Notifications You must be signed in to change notification settings

avinash7r/AutoKube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🚀 AutoKube

Automated Multi-Node Kubernetes Cluster Orchestration with Ansible

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.


🏗 Architecture Overview

                +---------------------------+
                |   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)            |
        +---------------------------------------------+

⚙️ Tech Stack

  • Ansible - Infrastructure Automation
  • Kubernetes (kubeadm) - Cluster Bootstrap
  • containerd - Container Runtime
  • Calico - Kubernetes Networking (CNI)
  • Ubuntu EC2 Instances - Infrastructure Layer

📁 Project Structure

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

🔥 Important: Run server.yaml

To orchestrate the entire cluster lifecycle, you must run:

ansible-playbook playbooks/server.yaml

This ensures:

  • Safe execution order
  • Variable sharing between plays
  • Fully automated cluster provisioning

🔧 What AutoKube Automates

1️⃣ Node Preparation (All Nodes)

  • Disables swap (runtime + persistent)
  • Configures kernel modules
  • Applies Kubernetes-required sysctl parameters
  • Installs base packages

2️⃣ Container Runtime Setup

  • Installs containerd
  • Configures systemd cgroups
  • Installs CNI plugins

3️⃣ Kubernetes Installation

  • Installs kubelet, kubeadm, kubectl
  • Pins versions
  • Configures crictl
  • Enables kubelet

4️⃣ Control Plane Initialization

  • Executes kubeadm init
  • Configures kubeconfig
  • Installs Calico networking

5️⃣ Automated Worker Join

  • Dynamically generates join command
  • Shares token across plays
  • Joins workers idempotently
  • Safe to re-run

➕ Add Any Number of Workers

To scale horizontally:

  1. Add additional EC2 instances.
  2. Update inventory/hosts.ini:
[workers]
worker1 ansible_host=<IP1>
worker2 ansible_host=<IP2>
worker3 ansible_host=<IP3>
worker4 ansible_host=<IP4>
  1. Run:
ansible-playbook playbooks/server.yaml

New nodes will automatically join the cluster.


▶️ Usage

1️⃣ Configure Inventory

[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/key

2️⃣ Run the Full Orchestration

ansible-playbook playbooks/server.yaml

🔍 Verify Cluster

On master:

kubectl get nodes

Expected:

master     Ready   control-plane
worker1    Ready
worker2    Ready

🛡 Design Principles

  • Fully idempotent
  • Role-based modular structure
  • Version pinned Kubernetes components
  • Safe re-runs
  • Clean orchestration flow
  • Production-style Ansible architecture

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published