nginx配置

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
# 四层负载均衡,为两台 Master apiserver 组件提供负载均衡
stream {
log_format main '$remote_addr $upstream_addr - [$time_local] $status
$upstream_bytes_sent';
access_log /var/log/nginx/k8s-access.log main;
upstream k8s-apiserver {
server 192.168.53.36:6443; # k8s-jy-master1 APISERVER IP:PORT
server 192.168.53.37:6443; # k8s-jy-master2 APISERVER IP:PORT
server 192.168.53.38:6443; # k8s-jy-master3 APISERVER IP:PORT
} server {
listen 16443; # 由于 nginx 与 master 节点复用,这个监听端口不能是 6443,否则会冲突
proxy_pass k8s-apiserver;
}
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80 default_server;
server_name _;
location / {
}
}
}

### 如果没有加载stream模块启动会失败,yum安装得nginx这个模块是动态加载得 可以直接yum安装

yum install -y nginx-mod-stream

keepalived配置

! Configuration File for keepalived

global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
# vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
} vrrp_script check_nginx {
script "/etc/keepalived/check_nginx.sh"
interval 2
weight -2
} vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
check_nginx
}
virtual_ipaddress {
192.168.53.40/24
}
}

——nginx 健康检测脚本

#!/bin/bash
count=`ps aux |grep nginx|grep -v grep|wc -l`
if [ $count -eq 0 ];then
nginx
else
sleep 3
systemctl stop keepalived.service
fi

最后将所有 Worker Node(kubectl get node 命令查看到的节点)组件配置文件,由 原来 连接 修改为 VIP,重启kubelet服务和kube-proxy服务。

最新文章

  1. Parallel.js初探
  2. 用qpython3写一个最简单的发送短信的程序
  3. 测试卡尔曼滤波器(Kalman Filter)
  4. Objective-c文件读取
  5. Python之property装饰器
  6. ubuntu 14 安装 JDK
  7. Java 数组基础,java.util.Arrays
  8. NSArray 常用的一些方法
  9. 【设计模式 - 13】之责任链模式(Chain Of Responsibility)
  10. tmux commands
  11. Django 部署到Nginx
  12. poj 3694(割边+lca)
  13. btcpool之BlockMaker
  14. PHP:第一章——PHP中的变量002
  15. NUMA特性禁用
  16. poj1637 Sightseeing tour(混合图欧拉回路)
  17. 数据库入门-基本sql语句及数据类型
  18. 通过chrome console 快速获取网页连接
  19. Luogu P1010 幂次方
  20. jQuery知识总结(转)

热门文章

  1. vue框架回顾
  2. tasklist
  3. shell实现接口初次失败告警,恢复也发送一次通知
  4. java开发细节
  5. Linux 部署apache2.4
  6. vue、iview、VeeValidate 表单验证完整
  7. 083_SFDC Limit(二) 及良好的开发习惯
  8. 2、k8s 基础环境安装
  9. vue3.0学习笔记
  10. 题目集7-9总结性Blog