基于kubeasz高可用集群部署

本文档详细介绍了如何使用kubeasz工具在多节点环境中部署高可用Kubernetes集群,包括集群节点规划、禁用selinux、关闭交换分区、防火墙及设置ssh免密登录,还涉及了keepalived、haproxy的安装以及ansible的使用,最终通过kubeasz完成集群的创建和配置,并验证了安装结果。
摘要由CSDN通过智能技术生成

集群节点规划
在这里插入图片描述

#系统yum替换
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#添加Kubernetes 镜像源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

关闭selinunx

## 临时并永久关闭SELinux
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

关闭交换分区

swapoff -a &&  sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab 

关闭防火墙

systemctl stop firewalld && systemctl disable firewalld

免密

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.put <romte_ip>

安装keepalived

yum install keepalived -y
cat /etc/keepalived/keepalived.conf 
! Configuration File for keepalived

global_defs {
   
   notification_email {
   
     acassen
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}


vrrp_instance VI_1 {
   
    state MASTER
    interface ens33
    garp_master_delay 10
    smtp_alert
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
   
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
   
        192.168.74.241 label ens33:0
        192.168.74.242 label ens33:1
        192.168.74.243 label ens33:2

	# optional label. should be of the form "realdev:sometext" for
	# compatibility with ifconfig.
	# 192.168.200.18 label eth0:1
    }
}

安装haproxy

yum install haproxy -y

echo <<EOF >>/etc/keepalived/keepalived.conf

listen k8s_api_nodes_6443
    bind 192.168.74.241:6443
    mode tcp
    server 192.168.74.144 192.168.74.144:6443 check inter 2000 fall 3 rise 5
    server 192.168.74.145 192.168.74.145:6443 check inter 2000 fall 3 rise 5
    server 192.168.74.146 192.168.74.146:6443 check inter 2000 fall 3 rise 5
EOF

安装ansible

curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip install ansible -i https:/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值