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服务。

k8s master节点高可用 nginx+keepalived配置文件的更多相关文章

  1. 二进制搭建kubernetes多master集群【三、配置k8s master及高可用】

    前面两篇文章已经配置好了etcd和flannel的网络,现在开始配置k8s master集群. etcd集群配置参考:二进制搭建kubernetes多master集群[一.使用TLS证书搭建etcd集 ...

  2. kubeadm部署多master节点高可用k8s1.16.2

    一.架构信息 系统版本:CentOS 7.6 内核:3.10.0‐1062.4.1.el7.x86_64 Kubernetes: v1.16.2 Docker­ce: 19.03 推荐硬件配置:2核4 ...

  3. centos7.4安装高可用(haproxy+keepalived实现)kubernetes1.6.0集群(开启TLS认证)

    目录 目录 前言 集群详情 环境说明 安装前准备 提醒 一.创建TLS证书和秘钥 安装CFSSL 创建 CA (Certificate Authority) 创建 CA 配置文件 创建 CA 证书签名 ...

  4. 4、keepalived高可用nginx负载均衡

    keepalived: HTTP_GET        //使用keepalived获取后端real server健康状态检测 SSL_GET(https)  //这里以为这后端使用的是http协议 ...

  5. JAVAEE——宜立方商城03:Nginx负载均衡高可用、Keepalived+Nginx实现主备

    1 nginx负载均衡高可用 1.1 什么是负载均衡高可用 nginx作为负载均衡器,所有请求都到了nginx,可见nginx处于非常重点的位置,如果nginx服务器宕机后端web服务将无法提供服务, ...

  6. centos实现三个节点高可用

    centos实现三个节点高可用 使用的资源为keepalived和nginx 高可用主机IP地址 192.168.136.131 192.168.136.133 192.168.136.134 ngi ...

  7. 高可用之KeepAlived(2):keepalived+lvs

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  8. 17.Linux高可用之Keepalived

    1.什么是高可用,为什么要设计高可用? 两台机器启动着相同的业务系统,当有一台机器宕机,另外一台服务器能快速的接管,对于访问的用户是无感知的. 减少系统不能提供服务的时间. 2.高可用使用什么工具来实 ...

  9. 用Kolla在阿里云部署10节点高可用OpenStack

    为展现 Kolla 的真正实力,我在阿里云使用 Ansible 自动创建 10 台虚机,部署一套多节点高可用 OpenStack 集群! 前言 上次 Kolla 已经表示了要打 10 个的愿望,这次我 ...

  10. K8s多节点部署+负载均衡+keepalived ——囊萤映雪

    K8s多节点部署+负载均衡+keepalived --囊萤映雪 1.多节点master2 部署 2.负载均衡部署+keepalived 1.多节点master2部署: #从master01节点上拷贝证 ...

随机推荐

  1. vue增强第三方UI库(element-ui)

    vue增强第三方UI库(element-ui) 目前笔者了解有以下思路拓展第三方ui库,此系列以element-ui作为例子 指令. 混入. 二次封装. fork一份element-ui仓库,修改代码 ...

  2. 从Encoder-Decoder(Seq2Seq)理解Attention的本质

    0. 目录 1. 前言 2. Transformer模型结构 2.1 Transformer的编码器解码器 2.2 输入层 2.3 位置向量 2.4 Attention模型 3. 总结 1. 语言模型 ...

  3. codeforce C. Maximal Intersection

    http://codeforces.com/contest/1029/problem/C 从第一天吃晚饭做到第二天吃完饭--你无法想象我的代码曾经150行 o( ̄┰ ̄*)ゞ 找到所有线段最远的左边和最 ...

  4. Vue 项目中实现的微信、微博、QQ空间分享功能(亲测有效)

    需求:文章添加分享功能(包括微信.微博.QQ空间) 如下图所示: 点击图标分别跳转到如下界面:(实现效果如下) 话不多说直接代码(可以封装成组件) <template> <div c ...

  5. 创建maven项目时,IntelliJ IDEA2019出现:Unable to import maven project: See logs for details 报错

    开发环境:IntelliJ IDEA 2019.1.3 + Maven3.6.3 报错截图 主要原因 IntelliJ IDEA 2019.1.3 与 Maven3.6.3 不兼容问题 解决方案 将m ...

  6. MTSC2021上海站PPT 分享

  7. ENGG1340 Computer Programming II

    课程内容笔记,自用,不涉及任何 assignment,exam 答案 Notes for self use, not included any assignments or exams Module ...

  8. lombok安装不了的问题

  9. SpringMVC学习day03

    第1个springmvc程序 这是根据狂神说视频和资料学习的,用于加强自己的记忆 入门学习 1. 步骤: 1.新建一个Moudle , springmvc-02-hello , 添加web的支持! 2 ...

  10. (原创)odoo14下qweb模板的前端与后端语法区别

    1.后端(qweb打包) 后端使用t-inherit 指定继承的模板,使用t-inherit-mode 指定继承的模式,使用xpath定位标记,使用position指定扩展位置. 2.前端 前端仍旧使 ...