集群节点规划
#系统yum替换
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#添加Kubernetes 镜像源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
关闭selinunx
## 临时并永久关闭SELinux
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
关闭交换分区
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
免密
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.put <romte_ip>
安装keepalived
yum install keepalived -y
cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
acassen
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface ens33
garp_master_delay 10
smtp_alert
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.74.241 label ens33:0
192.168.74.242 label ens33:1
192.168.74.243 label ens33:2
# optional label. should be of the form "realdev:sometext" for
# compatibility with ifconfig.
# 192.168.200.18 label eth0:1
}
}
安装haproxy
yum install haproxy -y
echo <<EOF >>/etc/keepalived/keepalived.conf
listen k8s_api_nodes_6443
bind 192.168.74.241:6443
mode tcp
server 192.168.74.144 192.168.74.144:6443 check inter 2000 fall 3 rise 5
server 192.168.74.145 192.168.74.145:6443 check inter 2000 fall 3 rise 5
server 192.168.74.146 192.168.74.146:6443 check inter 2000 fall 3 rise 5
EOF
安装ansible
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip install ansible -i https:/