ScriptsApr 15, 2026·3 min read

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.

TL;DR
Kubespray uses Ansible to deploy highly available Kubernetes clusters on any infrastructure.
§01

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.

§02

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.

§03

How to use

  1. Clone the Kubespray repository and install Ansible dependencies.
  2. Copy the sample inventory and define your hosts (control plane nodes, worker nodes, etcd nodes).
  3. Customize cluster variables (CNI plugin, container runtime, Kubernetes version).
  4. Run the cluster deployment playbook.
§04

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
§05

Related on TokRepo

§06

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

What Linux distributions does Kubespray support?+

Kubespray supports Ubuntu, Debian, CentOS, Rocky Linux, Fedora, and openSUSE. Each distribution is tested in the Kubespray CI pipeline.

Does Kubespray support high availability?+

Yes. Kubespray deploys multiple control plane nodes with etcd clustering and a load balancer (HAProxy or kube-vip) for API server high availability.

Can I upgrade Kubernetes with Kubespray?+

Yes. Kubespray provides an upgrade playbook that handles rolling upgrades of control plane and worker nodes with configurable drain and cordon settings.

How does Kubespray compare to kubeadm?+

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.

Does Kubespray work with cloud providers?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets