k8s系列-07-kubespray方案基础环境准备

网友投稿 796 2022-11-05

本站部分文章、图片属于网络上可搜索到的公开信息,均用于学习和交流用途,不能代表睿象云的观点、立场或意见。我们接受网民的监督,如发现任何违法内容或侵犯了您的权益,请第一时间联系小编邮箱jiasou666@gmail.com 处理。

k8s系列-07-kubespray方案基础环境准备

主旨

我们前面介绍了三种部署方案,分别是kubespray、kubeadm、kubernetes-the-hard-way,我们首先使用kubespray的方式来进行部署一下,往下看。

环境

由于我是测试环境,所以按照最节省资源的方式来进行,资源如下:

hostname
IP地址
角色
cpu
memory
node-1
192.168.112.130master
>=2

>=2
node-2
192.168.112.131master
>=2
>=2
node-3
192.168.112.132worker
>=2
>=2

修改主机名

192.168.112.130 操作,操作完毕之后需要重新连接:

[yunweijia@localhost ~]$ sudo vim etc/hostname# 清空文件原内容,写入下面信息node-1[yunweijia@localhost ~]$ sudo hostname node-1[yunweijia@localhost ~]$ bash[yunweijia@node-1 ~]$

192.168.112.131 操作:

[yunweijia@localhost ~]$ sudo vim etc/hostname# 清空文件原内容,写入下面信息node-2[yunweijia@localhost ~]$ sudo hostname node-2[yunweijia@localhost ~]$ bash[yunweijia@node-2 ~]$

192.168.112.132 操作,操作完毕之后需要重新连接:

[yunweijia@localhost ~]$ sudo vim etc/hostname# 清空文件原内容,写入下面信息node-3[yunweijia@localhost ~]$ sudo hostname node-3[yunweijia@localhost ~]$ bash[yunweijia@node-3 ~]$

PS:下面直接按照主机名来代替,就不单独以IP 地址来表明是哪台服务器了。

关闭安全策略

以下步骤,要在所有的服务器上进行操作,操作内容一致,只写一遍了。

关闭防火墙:

[yunweijia@node-1 ~]$ sudo systemctl stop firewalld.service[yunweijia@node-1 ~]$ sudo systemctl disable firewalld.service

关闭selinux:

[yunweijia@node-1 ~]$ sudo setenforce 0[yunweijia@node-1 ~]$ sudo vim etc/selinux/config SELINUX=enforcing # 该行注释掉,新建行内容如下:SELINUX=disabled[yunweijia@node-1 ~]$

设置iptables规则,该条命令必须在root用户中执行:

[yunweijia@node-1 ~]$ su root密码:[root@node-1 yunweijia]# iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat && iptables -P FORWARD ACCEPT[root@node-1 yunweijia]# exitexit[yunweijia@node-1 ~]$

关闭dnsmasq(否则可能导致容器无法解析域名)

[yunweijia@node-1 ~]$ sudo service dnsmasq stopRedirecting to /bin/systemctl stop dnsmasq.service[yunweijia@node-1 ~]$ sudo systemctl disable dnsmasq[yunweijia@node-1 ~]$

K8s参数设置

以下步骤,要在所有的服务器上进行操作,操作内容一致,只写一遍了。

[yunweijia@node-1 ~]$ sudo vim /etc/sysctl.d/kubernetes.conf net.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1net.ipv4.ip_nonlocal_bind = 1net.ipv4.ip_forward = 1vm.swappiness = 0vm.overcommit_memory = 1[yunweijia@node-1 ~]$ sudo sysctl -p /etc/sysctl.d/kubernetes.conf

移除docker软件相关包

以下步骤,要在所有的服务器上进行操作,操作内容一致,只写一遍了。

[yunweijia@node-1 ~]$ sudo yum remove -y docker*[yunweijia@node-1 ~]$ sudo rm -f /etc/docker/daemon.json

至此,本文结束,下一篇我们将进行kubespray的部署和安装。

上一篇:软件测试培训之基于模拟器的测试
下一篇:软件测试培训之性能需求评估
相关文章

 发表评论

暂时没有评论,来抢沙发吧~