节点导入镜像
[root@k8smaster1 ~]# ctr -n k8s.io images import ingress-nginx-controllerv1.1.0.tar.gz 
[root@k8smaster1 ~]# ctr -n k8s.io images import kube-webhook-certgen-v1.1.0.tar.gz
创建pod
[root@k8smaster1 ingress]# kubectl apply -f ingress-deploy.yaml

Ingress-controller高可用实战(一)_nginx

安装高可用软件
[root@k8smaster1 ingress]# yum install epel-release nginx  keepalived  nginx-mod-stream

Ingress-controller高可用实战(一)_keepalive_02

修改节点nginx配置文件, 添加高可用配置
stream {

    log_format  main  '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';

    access_log  /var/log/nginx/k8s-access.log  main;

    upstream ingress-controller {
       server 192.168.40.181:80 weight=5 max_fails=3 fail_timeout=30s;   # xianchaonode1 IP:PORT
       server 192.168.40.182:80 weight=5 max_fails=3 fail_timeout=30s;   # xianchaonode2 IP:PORT
    }
    
    server {
       listen 30088; 
       proxy_pass ingress-controller;
    }
}
修改节点keepalived 配置文件
vrrp_script check_nginx {
    script "/etc/keepalived/check_nginx.sh"
}

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.1.199/24
    } 
    track_script {
        check_nginx
    } 
}
授权nginx 进程检测脚本
[root@k8snode1 keepalived]# chmod 755 check_nginx.sh
按顺序启动
### 重载配置
[root@k8snode2 ~]# systemctl daemon-reload
### 配置开机自启
[root@k8snode1 ~]# systemctl enable nginx  keepalived
### 启动nginx
[root@k8snode2 ~]# systemctl start nginx
### 启动keepalived
[root@k8snode2 ~]# systemctl start keepalived