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.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 7235179f-38ce-11f1-9bc6-00163e2b0d79 --target codex先 dry-run 确认安装计划,再运行此命令。
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.
常见问题
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.
引用来源 (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
讨论
相关资产
Sidekick — Bare Metal to Production in Minutes on Your VPS
A self-hosted deployment tool that turns a fresh VPS into a production-ready server with Docker, TLS, and zero-downtime deploys via a single CLI command.
kOps — Production-Grade Kubernetes Cluster Management
Create, upgrade, and manage production Kubernetes clusters on AWS, GCE, and other clouds with kOps, the official Kubernetes operations tool.
kube-prometheus — Production-Ready Kubernetes Monitoring Stack
kube-prometheus provides a complete Kubernetes monitoring stack combining Prometheus, Grafana, Alertmanager, and node-exporter with opinionated defaults and pre-built dashboards.
Kedro — Production-Ready ML Pipeline Framework for Python
Kedro is an open-source Python framework by McKinsey QuantumBlack that applies software engineering best practices to data science and ML pipelines. It provides a standardized project structure, data catalog, and pipeline abstraction that makes experimental code production-ready.