【问题标题】:Errors form my k8s CornJob: Pod errors: Error with exit code 127我的 k8s CornJob 出现错误:Pod 错误:退出代码 127 出错
【发布时间】:2021-02-17 05:13:23
【问题描述】:

我在私有 GKE 集群上部署了后端服务,我想执行这个 Corn 作业,但每次我收到以下错误:Pod errors: Error with exit code 127

   apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: call-callendar-api-demo
spec:
  
  schedule: "*/15 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          nodeSelector:
            env: demo
          containers:
          - name: call-callendar-api-demo
            image: busybox
            command: ["/bin/sh"]
            args: ["-c", 'curl -X POST "curl -X POST "https://x.x.x/api/v1/cal/add_link" -H  "accept: application/json" -d "" >/dev/null 2>&1" -H  "accept: application/json" -d "" >/dev/null 2>&1']
          restartPolicy: Never

有什么建议为什么这个 CornJob 与我的后端服务部署在同一个命名空间上给我这个错误?容器中也没有日志:(顺便说一句,我有基本的身份验证,这可能是原因吗?

编辑:删除 >/dev/null/ 后来自 pod 的日志:

textPayload: "curl: (3) URL using bad/illegal format or missing URL  

textPayload: "
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: application
"

【问题讨论】:

  • BusyBox 不包含 curl 重新实现。删除命令末尾抑制所有输出的部分可能会为您提供一些更有用的诊断。
  • @DavidMaze 我用实现curl 的图像更改了它,现在我有了Pod errors: Error with exit code 6
  • 请编辑您的问题以包含 pod 日志的实际输出(同样,删除命令的 >/dev/null 部分)。错误代码本身不足以提供任何特定更改的建议。
  • @DavidMaze 根据这个可能是命令写错了?
  • 退出状态127 基本上意味着command not found 所以肯定有问题。 “是的,命令是错误的,我有两个 curl” - 这是否意味着您已经设法解决了它?如果是这样,请考虑分享确切的问题作为答案。

标签: docker kubernetes google-kubernetes-engine


【解决方案1】:

命令错误,我将图片更改为实现curl 的图片,它应该看起来像这样。

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: demo
spec:
  
  schedule: "*/15 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          nodeSelector:
            env: demo
          containers:
          - name: -demo
            image: curlimages/curl #changed the picture 
            command: ["/bin/sh"]
            args: ["-c", 'curl -X POST "https://x.x.x/api/v1/cal/addy_link" -H  "accept: application/json" -d "" >/dev/null 2>&1']
          restartPolicy: Never

它解决了我的问题。

【讨论】:

    猜你喜欢
    • 2013-09-28
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2022-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多