mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-25 11:15:39 +00:00
Fix containerd config: use standard paths and socket
Replace non-standard /run/cri-containerd/ paths with official /run/containerd/containerd.sock, simplify service setup to use default containerd config generation, and add unix:// prefix to CRI socket URIs per Kubernetes conventions.
This commit is contained in:
@@ -20,54 +20,25 @@ $ sudo yum install containerd.io
|
||||
|
||||
### 14.1.2 配置 containerd
|
||||
|
||||
新建 `/etc/systemd/system/cri-containerd.service` 文件
|
||||
生成默认配置文件:
|
||||
|
||||
```bash
|
||||
[Unit]
|
||||
Description=containerd container runtime for kubernetes
|
||||
Documentation=https://containerd.io
|
||||
After=network.target local-fs.target
|
||||
|
||||
[Service]
|
||||
ExecStartPre=-/sbin/modprobe overlay
|
||||
ExecStart=/usr/bin/containerd --config /etc/cri-containerd/config.toml
|
||||
|
||||
Type=notify
|
||||
Delegate=yes
|
||||
KillMode=process
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
## Having non-zero Limit*s causes performance problems due to accounting overhead
|
||||
|
||||
## in the kernel. We recommend using cgroups to do container-local accounting.
|
||||
|
||||
LimitNPROC=infinity
|
||||
LimitCORE=infinity
|
||||
LimitNOFILE=infinity
|
||||
|
||||
## Comment TasksMax if your systemd version does not supports it.
|
||||
|
||||
## Only systemd 226 and above support this version.
|
||||
|
||||
TasksMax=infinity
|
||||
OOMScoreAdjust=-999
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
$ sudo mkdir -p /etc/containerd
|
||||
$ containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
|
||||
```
|
||||
新建 `/etc/cri-containerd/config.toml` containerd 配置文件
|
||||
|
||||
修改 `/etc/containerd/config.toml` 配置文件
|
||||
|
||||
```toml
|
||||
version = 2
|
||||
|
||||
## persistent data location
|
||||
|
||||
root = "/var/lib/cri-containerd"
|
||||
root = "/var/lib/containerd"
|
||||
|
||||
## runtime state information
|
||||
|
||||
state = "/run/cri-containerd"
|
||||
state = "/run/containerd"
|
||||
plugin_dir = ""
|
||||
disabled_plugins = []
|
||||
required_plugins = []
|
||||
@@ -77,7 +48,7 @@ required_plugins = []
|
||||
oom_score = 0
|
||||
|
||||
[grpc]
|
||||
address = "/run/cri-containerd/cri-containerd.sock"
|
||||
address = "/run/containerd/containerd.sock"
|
||||
tcp_address = ""
|
||||
tcp_tls_cert = ""
|
||||
tcp_tls_key = ""
|
||||
@@ -204,7 +175,7 @@ oom_score = 0
|
||||
max_conf_num = 1
|
||||
conf_template = ""
|
||||
[plugins."io.containerd.grpc.v1.cri".registry]
|
||||
config_path = "/etc/cri-containerd/certs.d"
|
||||
config_path = "/etc/containerd/certs.d"
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.headers]
|
||||
# Foo = ["bar"]
|
||||
|
||||
@@ -214,7 +185,7 @@ oom_score = 0
|
||||
tls_cert_file = ""
|
||||
tls_key_file = ""
|
||||
[plugins."io.containerd.internal.v1.opt"]
|
||||
path = "/opt/cri-containerd"
|
||||
path = "/opt/containerd"
|
||||
[plugins."io.containerd.internal.v1.restart"]
|
||||
interval = "10s"
|
||||
[plugins."io.containerd.metadata.v1.bolt"]
|
||||
@@ -339,14 +310,14 @@ $ sudo systemctl daemon-reload
|
||||
#### master
|
||||
|
||||
```bash
|
||||
$ systemctl enable cri-containerd
|
||||
$ systemctl enable containerd
|
||||
|
||||
$ systemctl start cri-containerd
|
||||
$ systemctl start containerd
|
||||
|
||||
$ sudo kubeadm init \
|
||||
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \
|
||||
--pod-network-cidr 10.244.0.0/16 \
|
||||
--cri-socket /run/cri-containerd/cri-containerd.sock \
|
||||
--cri-socket unix:///run/containerd/containerd.sock \
|
||||
--v 5 \
|
||||
--ignore-preflight-errors=all
|
||||
```
|
||||
@@ -386,14 +357,14 @@ kubeadm join 192.168.199.100:6443 --token cz81zt.orsy9gm9v649e5lf \
|
||||
在 **另一主机** 重复 **部署** 小节以前的步骤,安装配置好 kubelet。根据提示,加入到集群。
|
||||
|
||||
```bash
|
||||
$ systemctl enable cri-containerd
|
||||
$ systemctl enable containerd
|
||||
|
||||
$ systemctl start cri-containerd
|
||||
$ systemctl start containerd
|
||||
|
||||
$ kubeadm join 192.168.199.100:6443 \
|
||||
--token cz81zt.orsy9gm9v649e5lf \
|
||||
--discovery-token-ca-cert-hash sha256:5edb316fd0d8ea2792cba15cdf1c899a366f147aa03cba52d4e5c5884ad836fe \
|
||||
--cri-socket /run/cri-containerd/cri-containerd.sock
|
||||
--cri-socket unix:///run/containerd/containerd.sock
|
||||
```
|
||||
|
||||
### 14.1.7 查看服务
|
||||
@@ -401,7 +372,7 @@ $ kubeadm join 192.168.199.100:6443 \
|
||||
所有服务启动后,通过 `crictl` 查看本地实际运行的容器。这些服务大概分为三类:主节点服务、工作节点服务和其它服务。
|
||||
|
||||
```bash
|
||||
CONTAINER_RUNTIME_ENDPOINT=/run/cri-containerd/cri-containerd.sock crictl ps -a
|
||||
CONTAINER_RUNTIME_ENDPOINT=unix:///run/containerd/containerd.sock crictl ps -a
|
||||
```
|
||||
|
||||
#### 主节点服务
|
||||
|
||||
Reference in New Issue
Block a user