十年河东,十年河西,莫欺少年穷
学无止境,精益求精
1、准备三台虚拟机,分别命名为master 、 node1 、 node2
master 192.168.136.135
node1 192.168.136.136
node2 192.168.136.137
2、检查虚拟机的版本,centos 系统必须是7.5以上版本
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core)
3、主机名解析
注:企业级建议使用企业内部的DNS服务器进行解析,没有DNS服务器,就通过这种方式
vim /etc/hosts
192.168.136.135 master 192.168.136.136 node1 192.168.136.137 node2
此时三台虚拟机可以相互 ping 通
我在master 中 ping node1虚拟机
4、时间同步,kuberneters 要求 master 和 各个Node节点之间的时间必须是一致的
三台虚拟机同时开通从网络同步时间
[root@localhost etc]# systemctl start chronyd [root@localhost etc]# systemctl enable chronyd [root@localhost etc]# date 2022年 05月 07日 星期六 14:08:36 CST
5、禁用Iptables 和 firewalld 防火墙 【生产环境中关闭防火墙一定要慎重】
关闭防火墙
[root@localhost etc]# systemctl stop firewalld [root@localhost etc]# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
关闭iptables
[root@localhost ~]# systemctl stop iptables [root@localhost ~]# systemctl disable iptables
6、禁用selinux ,这是个奇葩的服务,一定要坚决关掉
临时关闭selinux服务
setenforce [1|0] --- 1表示临时开启Enforcing,0表示临时关闭Permissive getenforce --- 关闭后确认 [root@server ~]# setenforce 0 [root@server ~]# getenforce Permissive
永久关闭selinux服务 【推荐永久关闭】
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. --- 服务处于正常开启状态 # permissive - SELinux prints warnings instead of enforcing. --- 服务被临时关闭了 # disabled - No SELinux policy is loaded. --- 服务被永久关闭 SELINUX=enforcing
第一步:修改配置文件
[root@server ~]# vi /etc/selinux/config SELINUX=disabled
第二步:系统重启生效配置
[root@server ~]# reboot
第三步:确认服务状态
[root@server ~]# getenforce disabled
7、禁用swap分区
linux 的 swap 分区的作用是当虚拟机的物理内存用完后,允许借用磁盘空间虚拟成物理内存,这样虽然增加了可用内存,但严重影响了系统性能,kuberneters 要求禁用swap 分区,如果因某种原因确实不能禁用,需要在k8s安装集群过程中相关配置参数中明确说明。
这里建议禁用swap分区
临时关闭
swapoff -a
永久关闭,需要 reboot 重启虚拟机,可以在所有配置改好后一块重启
vim /etc/fstab
将 swap 这行注释
8、修改linux内核参数,添加网桥过滤和地址转发功能
vim /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1
然后重新加载配置
sysctl -p
加载网桥过滤模块
modprobe br_netfilter
查看配置是否成功
lsmod | grep br_netfilter
9、配置Ipvs功能
在kubernetes中service有两种代理模型,一种是基于iptables的,一种是基于ipvs的
两者比较的话,ipvs的性能明显要高一些,但是如果要使用它,需要手动载入ipvs模块
1、安装ipset和ipvsadm
yum install ipset ipvsadmin -y
cat <<EOF > /etc/sysconfig/modules/ipvs.modules
3、输入脚本
#!/bin/bash
modprobe -- ip_vs modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- ip_vs_sh modprobe -- nf_conntrack_ipv4 EOF
chmod +x /etc/sysconfig/modules/ipvs.modules
5、执行脚本
/bin/bash /etc/sysconfig/modules/ipvs.modules
6、查看对应模块是否加载成功
lsmod | grep -e ip_vs -e nf_conntrack_ipv4
至此,整个kuberbeters所需要的环境就准备好了。
注意,以上步骤在master节点服务器和node节点服务器都要安装。
安装完毕后,需要重启服务器、reboot。
最后,分别重启服务器
reboot
@天才卧龙的波尔克
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。