Skip to main content

For Windows Container, you need to set --image-pull-progress-deadline for kubelet

· 2 min read

Windows 镜像动则几个 G, 基于 Windows Server Core 的镜像 5~10G, Windows 节点上的 kubelet 在下载镜像的时候经常会 cancel 掉:

Failed to pull image "XXX": rpc error: code = Unknown desc = context canceled

造成这个问题的原因是因为默认的 image pulling progress deadline 是 1 分钟, 如果 1 分钟内镜像下载没有任何进度更新, 下载动作就会取消, 比较大的镜像就无法成功下载. 见官方文档:

If no pulling progress is made before this deadline, the image pulling will be cancelled. This docker-specific flag only works when container-runtime is set to docker. (default 1m0s)

解决方法是为 kubelet 配置--image-pull-progress-deadline 参数, 比如指定为 30 分钟:

"c:/k/kubelet.exe ... --image-pull-progress-deadline=30m"

对于 Windows 服务, 使用 sc 指令修改 kubelet 的 binPath:

sc config kubelet binPath= " --image-pull-progress-deadline=30m

然后重启 kubelet 及依赖服务:

sc stop kubeproxy && sc stop kubelet && sc start kubelet && sc start kubeproxy && sc query kubelet && sc query kubeproxy

Refer to: https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/

ClustrMaps