使用containerd从0搭建k8s(kubernetes)集群

2023年 10月 7日 18.1k 0

准备环境

准备两台服务器节点,如果需要安装虚拟机,可以参考《wmware和centos安装过程》

机器名 IP 角色 CPU 内存
centos01 192.168.109.130 master 4核 2G
centos02 192.168.109.131 node 4核 2G
设置主机名,所有节点都执行
vim /etc/hosts
#增加
192.168.109.130 centos01
192.168.109.131 centos02
关闭防火墙,所有节点都执行
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vim /etc/selinux/config
#修改SELINUX的值
SELINUX=disabled
关闭swap内存,所有节点都执行
swapoff -a
vim /etc/fstab
# 将该行注释掉
#/dev/mapper/cs-swap swap
配置网桥,所有节点都执行

1.修改参数

vim /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables 	= 1
net.ipv4.ip_forward 				= 1
vm.swappiness 						= 0

2.然后,加载如下两个模块,所有节点都执行

modprobe ip_vs_rr
modprobe br_netfilter

3.生效配置

[root@centos01 opt]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0

安装containerd

以下步骤所有节点都执行。

安装
wget https://github.com/containerd/containerd/releases/download/v1.7.2/containerd-1.7.2-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.2-linux-amd64.tar.gz
修改配置
mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
vim /etc/containerd/config.toml
#SystemdCgroup的值改为true
SystemdCgroup = true
#由于国内下载不到registry.k8s.io的镜像,修改sandbox_image的值为:
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
启动服务
mkdir -p /usr/local/lib/systemd/system
wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service
mv containerd.service /usr/local/lib/systemd/system
systemctl daemon-reload
systemctl enable --now containerd
验证安装
[root@centos01 opt]# ctr version
Client:
  Version:  v1.7.2
  Revision: 0cae528dd6cb557f7201036e9f43420650207b58
  Go version: go1.20.4

Server:
  Version:  v1.7.2
  Revision: 0cae528dd6cb557f7201036e9f43420650207b58
  UUID: 747cbf1b-17d4-4124-987a-203d8c72de7c

安装runc

以下步骤所有节点都执行。

准备文件
wget https://github.com//opencontainers/runc/releases/download/v1.1.7/runc.amd64
chmod +x runc.amd64
查找containerd安装时已安装的runc所在的位置,如果不存在runc文件,则直接进行下一步
[root@centos01 opt]# which runc
/usr/bin/runc
替换上一步的结果文件
mv -f runc.amd64 /usr/bin/runc
验证安装
[root@centos01 opt]# runc -v
runc version 1.1.7
commit: v1.1.7-0-g860f061b
spec: 1.0.2-dev
go: go1.20.3
libseccomp: 2.5.4

安装kubernetes

添加阿里云的kubernetes源,所有节点都执行
cat

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论