
viatoro/kubesprayKubespray是一个基于Ansible的开源工具,旨在简化生产级Kubernetes集群的部署与管理。它支持在多种云平台(AWS、GCE、Azure等)和裸金属环境中构建高可用、可定制的Kubernetes集群,兼容主流Linux发行版,提供灵活的网络插件选择和持续集成测试支持,适用于企业级生产环境的集群部署需求。
1. 安装依赖
ShellSession# 安装requirements.txt中指定的依赖包 sudo pip install -r requirements.txt
2. 配置Inventory
ShellSession# 复制示例inventory到自定义目录 cp -rfp inventory/sample inventory/mycluster # 使用inventory构建器生成inventory文件(替换为实际节点IP) declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5) CONFIG_FILE=inventory/mycluster/inventory.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]}
3. 调整集群配置
ShellSession# 查看并修改全局配置 cat inventory/mycluster/group_vars/all/all.yml # 查看并修改Kubernetes集群配置 cat inventory/mycluster/group_vars/k8s-cluster/k8s-cluster.yml
4. 执行部署
ShellSession# 以root权限运行Ansible playbook(--become选项必需) ansible-playbook -i inventory/mycluster/inventory.ini --become --become-user=root cluster.yml
注意:若控制机Ansible通过系统包安装,可能出现模块路径冲突,导致类似"ERROR! no action detected in task"的错误。解决方法:卸载系统Ansible后通过pip安装,或设置环境变量
ANSIBLE_LIBRARY和ANSIBLE_MODULE_UTILS指向pip安装的模块目录。
1. 检查Python环境
ShellSession# 验证Python和pip是否安装 python -V && pip -V
2. 安装依赖
ShellSessionsudo pip install -r requirements.txt
3. 启动Vagrant环境
ShellSessionvagrant up
注意:不支持基于Upstart/SysV init的操作系统。
--become参数)通过kube_network_plugin变量指定网络插件,支持以下选项:
flannel:gre/vxlan二层网络calico:bgp三层网络(默认)canal:calico与flannel组合cilium:L3/L4网络,支持BPF安全策略contiv:多网络模式支持weave:无需外部K/V存储的轻量级网络kube-ovn:基于OVN的企业级网络虚拟化kube-router:集成服务代理、网络策略和BGP路由macvlan:直接连接物理网络的Mac/IP独立Podmultus:多网络接口支持的元插件




manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务