使用kargo快速自动化搭建kubernetes集群
程序员文章站
2022-03-10 14:02:07
...
kargo是利用ansible进行自动安装kubernetes的,ansible是自动化运维的优秀工具,我们可以通过ansible完成n台主机的自动安装。
格式正常地址:http://www.wisely.top/2017/05/16/kargo-ansible-kubernetes/
1.安装
1.1 机器列表
此处node1,node2,node3已做好*,见《*/privoxy/docker在CentOS下一起*》
- node1 | 192.168.1.130 | master | CentOS 7.2
- node2 | 192.168.1.131 | worker | CentOS 7.2
- node3 | 192.168.1.132 | worker | CentOS 7.2
- 操作机 |192.168.1.140 | ansible| CentOS 7.2
1.2 操作机安装ansible
yum install -y epel-release
yum install -y python-pip python-netaddr ansible git
pip install --upgrade Jinja2
1.3 操作机免密码登录节点
ssh-keygen
ssh-copy-id root@192.168.1.130
ssh-copy-id root@192.168.1.131
ssh-copy-id root@192.168.1.132
1.4 所有节点关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
1.5 下载kargo
git clone https://github.com/kubernetes-incubator/kargo.git
1.6 编写节点配置
cd kargo
vi inventory/inventory.cfg
[all]
node1 ansible_host=192.168.1.130 ansible_user=root ip=192.168.1.130
node2 ansible_host=192.168.1.131 ansible_user=root ip=192.168.1.131
node3 ansible_host=192.168.1.132 ansible_user=root ip=192.168.1.132
[kube-master]
node1
[kube-node]
node2
node3
[etcd]
node1
[k8s-cluster:children]
kube-node
kube-master
1.7 安装
ansible-playbook -u centos -b -i inventory/inventory.cfg cluster.yml
1.8 完成状态
PLAY RECAP *****************************************************************************************************************************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=0
node1 : ok=381 changed=99 unreachable=0 failed=0
node2 : ok=325 changed=83 unreachable=0 failed=0
node3 : ok=295 changed=72 unreachable=0 failed=0
Tuesday 16 May 2017 17:01:52 +0800 (0:00:00.017) 0:26:53.145 ***********
===============================================================================
download : Download containers if pull is required or told to always pull - 564.05s
download : Download containers if pull is required or told to always pull - 239.69s
kubernetes/preinstall : Update package management cache (YUM) ---------- 72.29s
download : Download containers if pull is required or told to always pull -- 65.27s
download : Download containers if pull is required or told to always pull -- 49.73s
download : Download containers if pull is required or told to always pull -- 46.08s
download : Download containers if pull is required or told to always pull -- 32.69s
download : Download containers if pull is required or told to always pull -- 26.85s
bootstrap-os : Assign inventory name to unconfigured hostnames --------- 25.96s
kubernetes/preinstall : Install packages requirements ------------------ 24.66s
docker : ensure docker packages are installed -------------------------- 19.93s
download : Download containers if pull is required or told to always pull -- 18.71s
network_plugin/calico : Calico | Copy cni plugins from calico/cni container -- 18.50s
network_plugin/calico : Calico | Copy cni plugins from hyperkube ------- 17.12s
download : Download containers if pull is required or told to always pull -- 16.25s
download : Download containers if pull is required or told to always pull -- 14.86s
download : Download containers if pull is required or told to always pull -- 12.75s
kubernetes/master : Master | wait for the apiserver to be running ------ 12.69s
kubernetes/master : Master | wait for kube-scheduler ------------------- 10.54s
docker : Docker | pause while Docker restarts -------------------------- 10.03s
1.9 检验
ssh root@192.168.1.130
kubectl get nodes
[root@node1 ~]# kubectl get nodes
NAME STATUS AGE VERSION
node1 Ready,SchedulingDisabled 1m v1.6.1+coreos.0
node2 Ready 1m v1.6.1+coreos.0
node3 Ready 1m v1.6.1+coreos.0
推荐阅读
-
使用docker快速搭建Spark集群的方法教程
-
使用docker快速搭建Spark集群的方法教程
-
详解从 0 开始使用 Docker 快速搭建 Hadoop 集群环境
-
使用 kind 快速搭建 kubernetes 环境
-
详解从 0 开始使用 Docker 快速搭建 Hadoop 集群环境
-
Kubernetes系列之一:在Ubuntu上快速搭建一个集群Demo
-
使用kubeadm极速搭建Kubernetes集群
-
国内使用 kubeadm 在 Centos 7 搭建 Kubernetes 集群
-
Kubeadm介绍与使用Kubeadm搭建kubernetes集群环境
-
centos7使用kubeadm搭建kubernetes集群