YAZONG 我的开源

Kubernetes(四)kubespray方式(4.1)分析kubespray部署方案,准备基础环境

  , , ,
0 评论0 浏览

kubespray的官网:"https://kubespray.io/#/"

#节点要求(前两台默认master,后面默认worker)

节点数 >=3台

CPU >=2

Memory >=2G

image.png

#设置IP
三台机器的IP后缀分别改为
172.16.1.21、172.16.1.22、172.16.1.23、
#上下一一对应
10.0.0.21、  10.0.0.22、  10.0.0.23
后,需要重启网卡。
[root@node-XX ~]# cd /etc/sysconfig/network-scripts/
[root@node-XX ~]# vim  ifcfg-ens33
[root@node-XX ~]# vim  ifcfg-ens37
[root@node-XX ~]# systemctl restart network
#设置主机名

[root@node-XX ~]# hostname node-1
[root@node-XX ~]# hostnamectl set-hostname node-1
[root@node-XX ~]# vim /etc/hosts
127.0.0.1   localhost
172.16.1.21 node-1
172.16.1.22 node-2
172.16.1.23 node-3

[root@node-XX ~]# hostname node-2
[root@node-XX ~]# hostnamectl set-hostname node-2
[root@node-XX ~]# vim /etc/hosts
127.0.0.1   localhost
172.16.1.21 node-1
172.16.1.22 node-2
172.16.1.23 node-3

[root@node-XX ~]# hostname node-3
[root@node-XX ~]# hostnamectl set-hostname node-3
[root@node-XX ~]# vim /etc/hosts
127.0.0.1   localhost
172.16.1.21 node-1
172.16.1.22 node-2
172.16.1.23 node-3
#系统设置(所有节点)

# 设置iptables规则
[root@node-XX ~]# iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat && iptables -P FORWARD ACCEPT
# 关闭swap
[root@node-XX ~]# swapoff -a && free -mh

#关闭dnsmasq(否则可能导致容器无法解析域名)
[root@node-XX ~]# service dnsmasq stop && systemctl disable dnsmasq && systemctl status dnsmasq
Redirecting to /bin/systemctl stop dnsmasq.service
Failed to stop dnsmasq.service: Unit dnsmasq.service not loaded.

#安装依赖包
[root@node-XX ~]# yum install -y socat conntrack ipvsadm ipset jq sysstat curl iptables libseccomp yum-utils

# k8s参数设置(所有节点)
# 制作配置文件
$ cat > /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
vm.overcommit_memory = 1
EOF
# 生效文件,这里一定不能报错!
$ sysctl -p /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
vm.overcommit_memory = 1
$ cat /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
vm.overcommit_memory = 1

标题:Kubernetes(四)kubespray方式(4.1)分析kubespray部署方案,准备基础环境
作者:yazong
地址:https://blog.llyweb.com/articles/2022/10/30/1667059387843.html