centos 7 基于 containerd 运行 Kubernetes 集群

1. 安装 containerd
# yum install -y yum-utils
# yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
# yum install containerd -y
2. 初始化 containerd 配置
# containerd config default > /etc/containerd/config.toml
# systemctl restart containerd
# systemctl status containerd
● containerd.service - containerd container runtime
   Loaded: loaded (/usr/lib/systemd/system/containerd.service; disabled; vendor preset: disabled)
   Active: active (running) since 六 2020-09-05 13:05:07 CST; 6s ago
     Docs: https://containerd.io
  Process: 1442 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
 Main PID: 1446 (containerd)
    Tasks: 10
   Memory: 27.3M
   CGroup: /system.slice/containerd.service
           └─1446 /usr/bin/containerd

(可选)替换 containerd 默认的 sand_box 镜像,编辑 /etc/containerd/config.toml

centos 7 基于 containerd 运行 Kubernetes 集群_第1张图片

不要忘记重启 containerd 服务:

# systemctl daemon-reload
# systemctl restart containerd
3. 安装 CRI 客户端 crictl
# VERSION="v1.19.0"
# wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
# sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
# rm -f crictl-$VERSION-linux-amd64.tar.gz
# echo "runtime-endpoint: unix:///run/containerd/containerd.sock" > /etc/crictl.yaml

简单测试一下:

# crictl pull registry.aliyuncs.com/google_containers/pause:3.2
# crictl images
IMAGE                                           TAG                 IMAGE ID            SIZE
registry.aliyuncs.com/google_containers/pause   3.2                 80d28bedfe5de       298kB
4. 安装 kubeadm、kubelet、kubectl
# cat > /etc/yum.repos.d/k8s.repo <
5. 初始化 Kubernetes 集群
# yum install libseccomp -y
# systemctl disable firewalld --now
# setenforce 0
# modprobe br_netfilter
# echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
# echo 1 > /proc/sys/net/ipv4/ip_forward
# kubeadm init --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=192.168.0.0/16
# mkdir -p $HOME/.kube
# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# chown $(id -u):$(id -g) $HOME/.kube/config
# kubectl describe node

centos 7 基于 containerd 运行 Kubernetes 集群_第2张图片

# crictl ps
CONTAINER ID        IMAGE               CREATED             STATE               NAME                      ATTEMPT             POD ID
67209afcd12bf       bc9c328f379ce       3 minutes ago       Running             kube-proxy                0                   4dc65e83cb1b7
0deea98b35295       cbdc8369d8b15       3 minutes ago       Running             kube-scheduler            0                   13693ead40d38
999d988fac99f       09d665d529d07       3 minutes ago       Running             kube-controller-manager   0                   b23c4829a16b5
cded56eb74720       1b74e93ece2f5       3 minutes ago       Running             kube-apiserver            0                   1764093b8d99e
2a7055b4045ce       d4ca8726196cb       3 minutes ago       Running             etcd                      0                   c20f6b5f41082

你可能感兴趣的:(Kubernetes,实用指南,containerd,k8s)