MENU

K8S 快速部署(适用于生产环境的多master)(02)

October 3, 2019 • Read: 59 • kubernetes阅读设置

本文适用于已学会K8S 快速部署(单master)(01)的童鞋阅读。

1、规划

1.1架构规划
11.png
1.2 服务器配置规划(此处 LB vip 规划为192.168.3.210)
12.png
1.3 软件版本规划
13.png
1.4 证书规划

2、创建master02

2.1虚拟化环境直接克隆master01(其余环境拷贝相应文件目录即可)到master02
2.2修改IP ,连接网络,修改主机名
2.3修改配置文件IP

cd /opt/kubernetes/cfg/
vi kube-apiserver

14.png

2.4重启服务

systemctl restart kube-apiserver
systemctl restart kube-controller-manager
systemctl restart kube-scheduler

2.5在master02查看集群状态
15.png
2.6查看集群节点
16.png

3、添加2台负载均衡

3.1参考nginx官方文档
https://nginx.org/en/linux_packages.html#RHEL-CentOS

3.2安装前置条件

yum -y install yum-utils

3.3设置安装源

vi /etc/yum.repos.d/nginx.repo

17.png

3.4安装niginx

 yum -y install nginx

3.5查看版本信息
18.png

3.6修改配置文件

vi /etc/nginx/nginx.conf

19.png

3.7 重启nginx并查看监听状态
20.png

3.8修改node连接master的配置
21.png

将文件里面master01 的IP 修改为nginx 的IP

改完重启

systemctl restart kubelet.service

4、为负载均衡配置keepalive

4.1安装keepalived

yum -y install keepalived

4.2修改配置文件

cd /etc/keepalived/
cp keepalived.conf keepalived.conf.back
wget https://tenthpinnemo.s3.cn-northwest-1.amazonaws.com.cn/Deploy/keepalived.conf

绿色部分根据实际情况修改

vi keepalived.conf

vrrp_instance VI_1 {
    state MASTER
    interface ens192
    virtual_router_id 51
    priority 100  
    advert_int 1   
    authentication {
        auth_type PASS
        auth_pass 1111
    }  
    virtual_ipaddress {
        192.168.3.210/24
    }
    track_script {
        check_nginx
    }
}

4.3修改ngnix检测点脚本

vi /usr/local/nginx/sbin/check_nginx.sh

count=$(ps -ef |grep nginx |egrep -cv "grep|$$")

if [ "$count" -eq 0 ];then
    systenctl  stop keepalived
fi

4.4修改备节点配置,红色部分根据实际情况修改

vrrp_instance VI_1 {
    state BACKUP
    interface ens192
    virtual_router_id 51 # VRRP 路由 ID实例,每个实例是唯一的
    priority 90    # 优先级,备服务器设置 90
    advert_int 1    # 指定VRRP 心跳包通告间隔时间,默认1秒
    authentication {
        auth_type PASS      
        auth_pass 1111
    }  
    virtual_ipaddress {
        192.168.3.210/24
    }
    track_script {
        check_nginx
    }
}

5、修改node配置ip为nginx的vip

cd /opt/kubernetes/cfg
vi bootstrap.kubeconfig
vi kubelet.kubeconfig
vi kube-proxy.kubeconfig
systemctl restart kubelet

兼总条贯 知至知终

无标签