Ingress-controller高可用实战(一)
  1D6o7E39IQo1 2023年11月02日 48 0
节点导入镜像
[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高可用实战(一)_keepalive

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

Ingress-controller高可用实战(一)_高可用_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
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

1D6o7E39IQo1
作者其他文章 更多

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13