Kubernetes pod 由于不正确的容器命令而失败

Kubernetes pod failing because of incorrect container command

我正在创建一个 egress-operator。我有一个 pod egress-operator-controller-manager 通过命令 make deploy IMG=my_azure_repo/egress-operator:v0.1makefile 创建。 pod 失败,它在 pod 描述中显示错误:

  State:          Waiting
  Reason:       RunContainerError
  Last State:     Terminated
  Reason:       StartError
  Message:      failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/manager": stat /manager: no such file or directory: unknown
  Failed     44s (x3 over 59s)  kubelet  Error: failed to create containerd task: 
  OCI runtime create failed: container_linux.go:380: starting container process caused: 
  exec: "/manager": stat /manager: no such file or directory: unknown

我怀疑在manager.yaml中,command:/manager is executed.
Can someone let me know what is going wrong in this manager.yaml and whether /manager在deployment.yaml

command:下有效

调试更新
而不是 运行ning Dockerfile,现在我只是在本地构建和 运行 image_azure_repo/egress-operator:v0.1(在同一个 ubuntu 18 VM 上),当我尝试登录时:docker exec -it <container_id> /bin/bash ,我收到错误:

OCI runtime exec failed: exec failed: container_linux.go:380: 
starting container process caused: exec: "/bin/bash": stat /bin/bash: 
no such file or directory: unknown

这与我在 pod 描述中看到的错误类似。而不是 /bin/bash ,我也尝试 docker exec/bin/sh 并且只有 sh ;它给出了同样的错误

  • 在 Dockerfile 中,您提到的入口点是 ENTRYPOINT ["/manager"] 但不应该是 ENTRYPOINT ["./manager"]

  • 关于“启动容器进程导致:exec:”/bin/bash”:stat /bin/bash:”,似乎基本图像没有 /bin/bash 它可能刚刚 /bin/sh

这应该与 libc 不匹配。

Golang默认使用glibc,而alpine默认使用musl。

你可以试试这些来修复它:

  1. 通过 glibc 使用基本映像
  2. 在你的 alpine 镜像中安装 glibc