Use kargo to quickly and automatically build a kubernetes cluster

Kargo uses ansible to automatically install kubernetes. Ansible is an excellent tool for automatic operation and maintenance. We can complete the automatic installation of n hosts through ansible.

 

Format normal address: http://www.wisely.top/2017/05/16/kargo-ansible-kubernetes/

1. Installation

1.1 Machine List

Here node1, node2, node3 have done scientific Internet access, see " Shadowsocks/privoxy/docker Scientific Internet Access Together under 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
  • Manipulator|192.168.1.140 | ansible| CentOS 7.2

1.2 Install ansible on the operating machine

yum install -y epel-release
yum install -y python-pip  python-netaddr  ansible git
pip install --upgrade Jinja2

1.3 Password-free login node from operating machine

ssh-keygen
ssh-copy-id [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]

1.4 Turn off the firewall on all nodes

systemctl stop firewalld
systemctl disable firewalld

1.5 Download kargo

git clone https://github.com/kubernetes-incubator/kargo.git

1.6 Writing Node Configuration

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 Installation

ansible-playbook -u centos -b -i inventory/inventory.cfg cluster.yml

1.8 Completion Status

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 Inspection

ssh [email protected]
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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326271565&siteId=291194637