k8s-docker适配
Dockershim 在 Kubernetes 1.24 中被弃用并删除,
Mirantis 正在维护cri-dockerd使Docker继续和K8S适配。
该适配器为Docker Engine提供了一个 shim ,使之可以通过 Kubernetes Container Runtime Interface控制 Docker 。
1.安装Docker【略】
2.安装cri-dockerd
下载地址:https://github.com/Mirantis/cri-dockerd/releases
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.1/cri-dockerd-0.3.1.amd64.tgz tar -xvf cri-dockerd-0.3.1.amd64.tgz cd cri-dockerd install -o root -g root -m 0755 ./cri-dockerd /usr/local/bin/cri-dockerd
3.添加启动文件cri-docker.socker
cri-docker.service【https://github.com/Mirantis/cri-dockerd/tree/master/packaging/systemd】
sudo tee /etc/systemd/system/cri-docker.service << EOF [Unit] Description=CRI Interface for Docker Application Container Engine Documentation=https://docs.mirantis.com After=network-online.target firewalld.service docker.service Wants=network-online.target Requires=cri-docker.socket [Service] Type=notify ExecStart=/usr/local/bin/cri-dockerd --container-runtime-endpoint fd:// --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.7 ExecReload=/bin/kill -s HUP $MAINPID TimeoutSec=0 RestartSec=2 Restart=always StartLimitBurst=3 StartLimitInterval=60s LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process [Install] WantedBy=multi-user.target EOF sudo tee /etc/systemd/system/cri-docker.socket << EOF [Unit] Description=CRI Docker Socket for the API PartOf=cri-docker.service [Socket] ListenStream=%t/cri-dockerd.sock SocketMode=0660 SocketUser=root SocketGroup=docker [Install] WantedBy=sockets.target EOF
1、需要追加--network-plugin=cni
,通过该配置告诉容器,使用kubernetes的网络接口。
2、覆盖沙盒 (pause) 镜像,正常情况下,国内你是拉取不到k8s.gcr.io/pause
镜像的,可以换成国内的kubebiz/pause或者阿里云
,这个镜像是一切的 Pod 的基础,要么自己手动导入进来,要么改成国内的镜像,通过设置--pod-infra-container-image配置来覆盖默认的沙盒镜像
4.启动
systemctl daemon-reload systemctl start cri-docker.service systemctl enable cri-docker.service systemctl enable --now cri-docker.socket systemctl is-active cri-docker.socket