kargo是利用ansible進行自動安裝kubernetes的,ansible是自動化運維的優秀工具,我們可以通過ansible完成n台主機的自動安裝。
格式正常位址:http://www.wisely.top/2017/05/16/kargo-ansible-kubernetes/
1.安裝
1.1 機器清單
此處node1,node2,node3已做好科學上網,見《Shadowsocks/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 [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]
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 安裝
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 檢驗
[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