環境說明
node
系統:linux
Centos 7.5docker
集羣:vim
master1 192.168.214.88api
master2 192.168.214.89bash
master3 192.168.214.90服務器
etcd1 192.168.214.200ssh
etcd2 192.168.214.201tcp
etcd3 192.168.214.202ide
node1 192.168.214.203
node2 192.168.214.204
node3 192.168.214.205
各節點組件
Master:二進制安裝kube-apiserver,kube-scheduler,kube-config-manager(master上的三個重要組件)、kubectl(命令行工具)
說明:kube-scheduler、kube-controller-manager 和 kube-apiserver 三者的功能緊密相關; 同時只能有一個 kube-scheduler、kube-controller-manager 進程處於工做狀態,若是運行多個,則須要經過選舉產生一個 leader
Etcd:源碼二進制安裝,選舉leader
Node:安裝flannel,kubelet,kube-proxy,docker-ce
haproxy:配置tcp代理haroxy組件
軟件版本信息
kubernetes:1.12.2
etcd:3.2.22
docker-ce:18.06
flannel:0.9.1
haproxy:1.5.18
準備工做
全部節點關閉防火牆
systemctl stop firewalld && systemctl disable firewalld
全部節點關閉selinux
sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config && setenforce 0
配置yum源,方便kubernetes組件安裝
yum install -y epel-release vim /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
host定向,打通集羣主機名通訊
vim /etc/hosts master1 192.168.214.88 master1 master2 192.168.214.89 master2 etcd1 192.168.214.200 etcd1 etcd2 192.168.214.201 etcd2 etcd3 192.168.214.202 etcd3 node1 192.168.214.203 node1 node2 192.168.214.204 node2
master1生成祕鑰,設置免密登陸集羣其餘節點
ssh-keygen ssh-copy-id -i /root/.ssh/id_rsa.pub master2 ssh-copy-id -i /root/.ssh/id_rsa.pub master3 ssh-copy-id -i /root/.ssh/id_rsa.pub etcd1 ssh-copy-id -i /root/.ssh/id_rsa.pub etcd2 ssh-copy-id -i /root/.ssh/id_rsa.pub etcd3 ssh-copy-id -i /root/.ssh/id_rsa.pub node1 ssh-copy-id -i /root/.ssh/id_rsa.pub node2 ssh-copy-id -i /root/.ssh/id_rsa.pub node3 ssh-copy-id -i /root/.ssh/id_rsa.pub mastercluster
配置ntpdate時間服務器
yum install ntpdate -y systemctl enable ntpdate.service systemctl start ntpdate.service 臨時同步:ntpdate time7.aliyun.com 設置任務計劃crontab -e: */30 * * * * /usr/sbin/ntpdate time7.aliyun.com >/dev/null 2>&1
關閉swap,不然會致使kubelet啓動失敗
## 臨時關閉:swapoff -a ## 永久關閉:sed -i 's/.*swap.*/#&/' /etc/fstab