kubernetes1.2.3 获取docker pid失败处理

起因: k8s版本1.2.3,docker v1.9.1,后因docker升级到了1.10.3, docker 被拆分成了docker + docker_current, docker 为shell的包装。

kubelet打印错误日志:

E0525 16:17:20.437528    1899 container_manager_linux.go:267] failed to detect process id for "docker" - failed to find pid of "docker": exit status 1

原因:因为k8s 1.2.3以前版本中,获取docker的pid默认为docker,但是docker后续版本将名字修改成了docker_current

临时解决方式:修改service文件,设置docker别名

more /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service

[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
ExecStart=/bin/sh -c 'exec -a docker /usr/bin/docker-current daemon \
          --exec-opt native.cgroupdriver=systemd \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY \
          2>&1 | /usr/bin/forward-journald -tag docker'
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
MountFlags=slave
Restart=on-abnormal
StandardOutput=null
StandardError=null

[Install]
WantedBy=multi-user.target

k8s 1.3.0版本中已经修复了该问题,采用优先使用pid文件的方式。

# systemctl daemon-reload
# systemctl restart docker.service
# pidof docker

问题参见:https://github.com/kubernetes/kubernetes/issues/26259

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注