基于 kubeadm 安装 Kubernetes 集群的完整步骤

准备工作

  • 准备好3台服务器 ,每台机器内存2GB以上, master节点cpu 2C以上。
  • 同步服务器时间(NTP)
  • 设置服务器ssh免密配置

安装步骤

设置hosts

vi /etc/hosts

192.168.0.110 master110
192.168.0.109 node109
192.168.0.112 node112

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld

关闭swap

关闭swap (为保证系统的稳定性和性能,k8s建议关闭swap)
临时关闭:swapoff -a

永久关闭(需要重启机子)
vi etc/fstab

[root@master110 ~]# less /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Wed Mar 27 06:37:15 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=ae1ef289-9c30-4338-af1f-6be0af376392 /boot                   xfs     defaults        0 0
#/dev/mapper/centos-swap swap                    swap    defaults        0 0

禁用SELinux

vi /etc/selinux/config

# 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
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
#SELINUXTYPE=targeted
SELINUX=disabled

设置iptables

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF


cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables  = 1
net.bridge.bridge-nf-call-iptables   = 1
net.ipv4.ip_forward                  = 1
EOF

sysctl --system

安装容器运行时 containerd

yum install -y yum-utils
# 添加docker镜像源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装
yum install -y containerd
# 启动containerd
sudo systemctl start containerd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值