环境: centos7.6,kubespray-2.14.1,内网配置好 yum 源、pip源、docker-ce 源(可以考虑使用 nexus 代理 ),nexus 代理好 docker hub、aliyun docker registry
1、copy 资产目录
[root@ansible002 kubespray-2.14.1]# cp -r inventory/sample inventory/mycluster
2、配置好内网 pip 源,安装 requirement.txt
[root@ansible002 kubespray-2.14.1]# pip install -r requirements.txt
yum install python-netaddr
3、修改资产文件 inventory/mycluster/inventory.ini
[root@ansible002 kubespray-2.14.1]# cat inventory/mycluster/inventory.ini
[all]
node1 ansible_host=192.168.1.222
node2 ansible_host=192.168.1.223
node3 ansible_host=192.168.1.224
node4 ansible_host=192.168.1.225
node5 ansible_host=192.168.1.226
# ## configure a bastion host if your nodes are not directly reachable
# bastion ansible_host=x.x.x.x ansible_user=some_user
[kube-master]
node1
node2
node3
[etcd]
node1
node2
node3
[kube-node]
node1
node2
node3
node4
node5
[calico-rr]
[k8s-cluster:children]
kube-master
kube-node
calico-rr
[all:vars]
#ansible_user=gree
#ansible_become=yes
#ansible_user=root
#ansible_ssh_pass=123456
#ansible_sudo_pass=123456
4、更新 docker registry
做好 ansible 服务器到其他服务器的 ssh 免密登陆
[root@ansible002 kubespray-2.14.1]# cat daemon.json
{
"insecure-registries": [
"10.2.7.11"
],
"registry-mirrors": [
"
https://10.2.7.11"
;
]
}
[root@ansible002 kubespray-2.14.1]# ansible all -i inventory/mycluster/inventory.ini -m copy -a "src=daemon.json dest=/etc/docker/daemon.json"
[root@ansible002 kubespray-2.14.1]# ansible all -i inventory/mycluster/inventory.ini -m shell -a "systemctl

本文指导如何在内网环境中,通过配置内网pip源、YUM源和Docker镜像源,使用Kubespray 2.14.1部署Kubernetes集群,包括资产复制、配置Ansible、更新dockerregistry、设置镜像仓库和解决安装过程中遇到的问题。
最低0.47元/天 解锁文章
2384





