【K8S】K8S服务搭建
环境
192.168.116.137 |
master |
192.168.116.138 |
node1 |
192.168.116.139 |
node2 |
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭 selinux
sed -i ‘s/enforcing/disabled/’ /etc/selinux/config
或者
setenforce 0
关闭 swap
临时禁用
swapoff -a
永久禁用
若需要重启后也生效,在禁用swap后还需修改配置文件/etc/fstab,注释swap
sed -ri 's/.*swap.*/#&/' /etc/fstab #永久关闭swap分区,&符号在sed命令中代表上次匹配的结果
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-y4Kh6vyX-1667148672385)(F:\typorase\jpg\1049.png)]](https://i-blog.csdnimg.cn/blog_migrate/b237f3467739844d5318f9f1579da423.png)
添加主机IP对应关系
vim /etc/hosts
192.168.116.137 master
192.168.116.138 node01
192.168.116.139 node02
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e8f1d626626f0f20a58ddede25443fe2.png)
修改主机名
hostnamectl set-hostname master
hostnamectl set-hostname node01
hostnamectl set-hostname node02
将桥接的 IPv4 流量传递到 iptables 的链
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GrAOT6O4-1667148672388)(F:\typorase\jpg\1051.png)]](https://i-blog.csdnimg.cn/blog_migrate/0acec6f1c2ae4a3ce3b6fe9dd65daf10.png)
进行时间同步
ntpdate ntp1.aliyun.com
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-rwT9emcR-1667148672388)(F:\typorase\jpg\1052.png)]](https://i-blog.csdnimg.cn/blog_migrate/efc378acf042a3ae90a9f3be33237d9b.png)
安装docker
安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2
设置阿里云镜像源
cd /etc/yum.repos.d/
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo