k8s高可用集群(一)

参考:蘑菇社区 - 专注于技术分享的社区平台

由于从有道笔记转过来,所以有些代码格式比较乱,需要更详细的可以参考我的有道笔记

文档:k8s高可用集群搭建(尚硅谷学习笔记)....
链接:http://note.youdao.com/noteshare?id=294d02f4133dccf37f6313bc12268134&sub=28BB5A24488F4253A0FD991F8A86BE7A

初始化操作

我们需要在这三个节点上进行操作

# 关闭防火墙 systemctl stop firewalld systemctl disable firewalld

# 关闭selinux

# 永久关闭 sed -i 's/enforcing/disabled/' /etc/selinux/config

# 临时关闭 setenforce 0

# 关闭swap

# 临时

swapoff -a

# 永久关闭

sed -ri 's/.*swap.*/#&/' /etc/fstab

# 根据规划设置主机名【master1节点上操作】

hostnamectl set-hostname master1

# 根据规划设置主机名【master2节点上操作】

hostnamectl set-hostname master1

# 根据规划设置主机名【node1节点操作】

hostnamectl set-hostname node1

# r添加hosts 注意此处和单master不同

cat >> /etc/hosts << EOF 192.168.44.158 master.k8s.io k8s-vip 192.168.44.155 master01.k8s.io master1 192.168.44.156 master02.k8s.io master2 192.168.44.157 node01.k8s.io node1 EOF

# 将桥接的IPv4流量传递到iptables的链【3个节点上都执行】

cat > /etc/sysctl.d/k8s.conf << EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF

# 生效

sysctl --system

# 时间同步

yum install ntpdate -y ntpdate time.windows.com

部署keepAlived

下面我们需要在所有的master节点【master1和master2】上部署keepAlive

安装相关包

# 安装相关工具

yum install -y conntrack-tools libseccomp libtool-ltdl

# 安装keepalived

yum install -y keepalived

猜你喜欢

转载自blog.csdn.net/weixin_42821448/article/details/125450019