cri-o的安装

CRI-O是一个为容器运行时提供轻量级、高效和符合标准的解决方案的开源项目。它是Kubernetes使用的容器运行时接口(CRI)规范的实现之一。

安装

1.关闭防火墙等

#!/bin/bash

# 关闭 防火墙
systemctl stop firewalld
systemctl disable firewalld

# 关闭 SeLinux
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

# 关闭 swap
swapoff -a
yes | cp /etc/fstab /etc/fstab_bak
cat /etc/fstab_bak |grep -v swap > /etc/fstab

# 修改 /etc/sysctl.conf
# modprobe br_netfilter
# 如果有配置,则修改
sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g" /etc/sysctl.conf
sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g" /etc/sysctl.conf
sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g" /etc/sysctl.conf
# 可能没有,追加
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
# 执行命令以应用
sysctl -p

systemctl enable kubelet
systemctl start kubelet

2.安装CRI-O

Centos_7:

export VERSION=1.28
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/CentOS_7/devel:kubic:libcontainers:stable.repo
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:${VERSION}.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:${VERSION}/CentOS_7/devel:kubic:libcontainers:stable:cri-o:${VERSION}.repo

## 通过yum下载
yum install -y cri-o

部署K8s集群

修改配置文件

# 修改镜像,国内地址拉取不到
vim /etc/crio/crio.conf
pause_image = "registry.aliyuncs.com/google_containers/pause:3.1"

# 启动集群
kubeadm init --pod-network-cidr=<192.168.0.0/16> --apiserver-advertise-address=<10.10.101.123> --image-repository registry.aliyuncs.com/google_containers --service-cidr=<10.96.0.0/12> --kubernetes-version=<v1.25.14> --cri-socket=unix:///var/run/crio/crio.sock