更合理的部署方式参见《Centos下Kubernetes+Flannel部署(新)》
一、准备工作
1. 三台centos主机
k8s(即kubernetes,下同)master: 10.16.42.200
k8s node1: 10.16.42.198
k8s node2: 10.16.42.199
2. 程序下载(百度网盘):k8s-1.0.1(也可以使用测试版k8s-1.1.2.beta),Docker-1.8.2,cadvisor-0.14.0,etcd-2.2.1,flannel-0.5.5
二、ETCD集群部署
分别向三台主机的/etc/hosts文件中追加如下设置:
10.16.42.198 bx-42-198 10.16.42.199 bx-42-199 10.16.42.200 bx-42-200
在三台主机中分别解压etcd.tar,将其中的 etcd 和 etcdctl 复制到你的工作目录(如 /openxxs/bin,下同)。
在200的/openxxs/bin目录下创建脚本start_etcd.sh并执行:
1 #!/bin/bash 2 3 etcd_token=kb2-etcd-cluster 4 local_name=kbetcd0 5 local_ip=10.16.42.200 6 local_peer_port=4010 7 local_client_port1=4011 8 local_client_port2=4012 9 node1_name=kbetcd1 10 node1_ip=10.16.42.198 11 node1_port=4010 12 node2_name=kbetcd2 13 node2_ip=10.16.42.199 14 node2_port=4010 15 16 17 ./etcd -name $local_name \ 18 -initial-advertise-peer-urls http://$local_ip:$local_peer_port \ 19 -listen-peer-urls http://0.0.0.0:$local_peer_port \ 20 -listen-client-urls http://0.0.0.0:$local_client_port1,http://0.0.0.0:$local_client_port2 \ 21 -advertise-client-urls http://$local_ip:$local_client_port1,http://$local_ip:$local_client_port2 \ 22 -initial-cluster-token $etcd_token \ 23 -initial-cluster $local_name=http://$local_ip:$local_peer_port,$node1_name=http://$node1_ip:$node1_port,$node2_name=http://$node2_ip:$node2_port \ 24 -initial-cluster-state new