一、服务器地址规划

iphostnameinstallation
192.168.1.71master1kube-apiserver,kube-controller-manager,kube-scheduler,etcd,kube-proxy,flannel
192.168.1.72node1kube-proxy,coredns,flannel
192.168.1.73node2kube-proxy,coredns,flannel

二、服务器环境配置(所有服务器)

1、安装epel源

yum -y install epel-release

2、安装常用工具

yum -y install vim wget nmap lsof iotop lrzsz ntpdate tree

3、修改服务器时区,时间同步

rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate time1.aliyun.com
crontab -e
*/3 * * * * /usr/sbin/ntpdate time1.aliyun.com >/dev/null 2>&1

4、关闭防火墙、selinux

systemctl disable firewalld.service
systemctl stop firewalld.service
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config && setenforce 0

5、关闭swap

swapoff -a
sed -i 's/^.*swap/#&/g'  /etc/fstab

6、内核参数优化

cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
vm.max_map_count = 262144
fs.file-max = 655350
net.core.somaxconn=20480
net.ipv4.ip_forward = 1
EOF
sysctl -p

7、调整文件描述符和进程数量的限制

cat >> /etc/security/limits.conf << EOF
*    soft    nofile   655350
*    hard    nofile   655350
*    soft    nproc    655350
*    hard    nproc    655350
EOF

8、重启服务器

reboot

 

三、安装docker-ce服务(所有服务器)

1、卸载服务器可能已安装的docker环境

yum -y remove docker-ce docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine

2、安装docker依赖包

yum -y install yum-utils device-mapper-persistent-data lvm2

3、添加yum源

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、安装docker-ce服务

yum -y install --setopt=obsoletes=0 docker-ce
systemctl daemon-reload
systemctl enable docker
systemctl start docker

 

四、安装kubeadm、kubectl、kubelet(所有服务器)

1、添加yum源

cat > /etc/yum.repos.d/kubernetes.repo << EOF
[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
EOF

2、卸载服务器上可能已安装的版本

yum -y remove kubelet kubeadm kubectl

3、安装kubeadm、kubectl、kubelet

yum -y install kubelet-1.16.2-0.x86_64 kubeadm-1.16.2-0.x86_64 kubectl-1.16.2-0.x86_64 --disableexcludes=kubernetes
systemctl daemon-reload
systemctl enable kubelet

4、开启bridge-nf模式

cat >> /etc/sysctl.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl -p
echo 1 >/proc/sys/net/bridge/bridge-nf-call-iptables
echo 1 >/proc/sys/net/bridge/bridge-nf-call-ip6tables

5、开启IP数据包转发功能

echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p

五、准备安装所需的镜像

1、master服务器

2、node服务器

yum -y install vim wget nmap lsof iotop lrzsz ntpdate tree

01-07 11:58
查看更多