Kubespray — Production-Ready Kubernetes via Ansible
Kubespray is a Kubernetes SIG project that uses Ansible to deploy highly-available, production-grade Kubernetes clusters on any bare-metal, VM, or cloud infrastructure.
What it is
Kubespray is a Kubernetes SIG (Special Interest Group) project that uses Ansible playbooks to deploy production-grade, highly available Kubernetes clusters. It works on bare-metal servers, virtual machines, and cloud infrastructure.
Kubespray targets operations teams who need full control over their Kubernetes deployment without being locked into a managed service. It supports multiple Linux distributions, CNI plugins, and container runtimes.
The project is actively maintained and suitable for both individual developers and teams looking to integrate it into their existing toolchain. Documentation and community support are available for onboarding.
How it saves time or tokens
Kubespray automates the dozens of manual steps required to set up a production Kubernetes cluster: etcd clustering, control plane HA, CNI installation, certificate generation, and node joining. What takes a full day of manual work runs in a single ansible-playbook command. Cluster upgrades are also automated.
For teams evaluating multiple tools in the same category, the clear documentation and active community reduce the time spent on research and troubleshooting. Getting started takes minutes rather than hours of configuration.
How to use
- Clone the Kubespray repository and install Ansible dependencies.
- Copy the sample inventory and define your hosts (control plane nodes, worker nodes, etcd nodes).
- Customize cluster variables (CNI plugin, container runtime, Kubernetes version).
- Run the cluster deployment playbook.
Example
# Clone and set up
git clone https://github.com/kubernetes-sigs/kubespray.git
cd kubespray
pip install -r requirements.txt
# Copy sample inventory
cp -r inventory/sample inventory/mycluster
# Define hosts
declare -a IPS=(10.0.0.1 10.0.0.2 10.0.0.3)
CONFIG_FILE=inventory/mycluster/hosts.yaml \
python3 contrib/inventory_builder/inventory.py ${IPS[@]}
# Deploy the cluster
ansible-playbook -i inventory/mycluster/hosts.yaml \
--become --become-user=root \
cluster.yml
Related on TokRepo
- AI Tools for DevOps — Kubernetes deployment and infrastructure tools.
- AI Tools for Automation — Ansible-based automation and orchestration tools.
Common pitfalls
- Not testing with a staging environment first. Kubespray modifies system packages and kernel parameters. Run it on test nodes before production.
- Using the default CNI plugin without understanding your network requirements. Calico, Flannel, and Cilium have different performance and policy capabilities.
- Forgetting to set up persistent storage. Kubespray deploys Kubernetes but does not configure a storage class. Add a CSI driver for persistent volumes after cluster creation.
- Not reading the changelog before upgrading. Breaking changes between versions can cause unexpected failures in production. Pin your version and review release notes.
- Not pinning dependency versions in production. Floating versions can introduce breaking changes. Lock your dependency versions and test upgrades in staging first.
Frequently Asked Questions
Kubespray supports Ubuntu, Debian, CentOS, Rocky Linux, Fedora, and openSUSE. Each distribution is tested in the Kubespray CI pipeline.
Yes. Kubespray deploys multiple control plane nodes with etcd clustering and a load balancer (HAProxy or kube-vip) for API server high availability.
Yes. Kubespray provides an upgrade playbook that handles rolling upgrades of control plane and worker nodes with configurable drain and cordon settings.
kubeadm handles the core cluster bootstrapping. Kubespray wraps kubeadm with Ansible to automate the full deployment lifecycle including networking, HA, and add-ons. Kubespray is higher-level and more opinionated.
Yes. Kubespray works on AWS, GCP, Azure, and other clouds. It provisions Kubernetes on existing VMs but does not create the VMs. Use Terraform or your cloud provider's CLI to create VMs first, then point Kubespray at them.
Citations (3)
- Kubespray GitHub— Kubernetes SIG project using Ansible for cluster deployment
- Kubespray Documentation— Production-grade HA Kubernetes deployment
- Kubernetes Docs— Kubernetes cluster deployment best practices
Related on TokRepo
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.