#setenforce 0 #sed -i '/^SELINUX=/cSELINUX=disabled' /etc/sysconfig/selinux
# yum -y install etcd kubernetes
配置etcd。確保列出的這些項都配置正確而且沒有被註釋掉,下面的配置都是如此 node
#vim /etc/etcd/etcd.conf ETCD_NAME=default ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
配置kuberneteslinux
vim /etc/kubernetes/apiserver KUBE_API_ADDRESS="--address=0.0.0.0" KUBE_API_PORT="--port=8080" KUBELET_PORT="--kubelet_port=10250" KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379" KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" KUBE_API_ARGS=""
# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done
3.設置etcd網絡算法
#etcdctl -C 10.0.0.81:2379 set /atomic.io/network/config '{"Network":"10.1.0.0/16"}'
# kubectl get nodes NAME LABELS STATUS
# yum -y install flannel kubernetes
配置kubernetes鏈接的服務端IPdocker
#vim /etc/kubernetes/config KUBE_MASTER="--master=http://10.0.0.81:8080" KUBE_ETCD_SERVERS="--etcd_servers=http://10.0.0.81:2379"
配置kubernetes ,(請使用每臺minion本身的IP地址好比10.0.0.81:代替下面的$LOCALIP)vim
#vim /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=0.0.0.0" KUBELET_PORT="--port=10250" # change the hostname to this host’s IP address KUBELET_HOSTNAME="--hostname_override=$LOCALIP" KUBELET_API_SERVER="--api_servers=http://10.0.0.81:8080" KUBELET_ARGS=""
# ifconfig docker0 Link encap:Ethernet HWaddr 02:42:B2:75:2E:67 inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
warning:在運行過docker的機器上能夠看到有docker0,這裏在啓動服務以前須要刪掉docker0配置,在命令行運行:sudo ip link delete docker0centos
3.配置flannel網絡api
#vim /etc/sysconfig/flanneld FLANNEL_ETCD_ENDPOINTS="http://10.0.0.81:2379" FLANNEL_ETCD_PREFIX="/atomic.io/network"
# for SERVICES in flanneld kube-proxy kubelet docker; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done
# kubectl get nodes NAME STATUS AGE 10.0.0.82 Ready 1m 10.0.0.83 Ready 1m
能夠看到配置的兩臺minion已經在master的node列表中了。若是想要更多的node,只須要按照minion的配置,配置更多的機器就能夠了。bash