Pods 处于 CrashLoopBackOff 状态并且基于 C 的应用程序的就绪探测失败

Pods is in CrashLoopBackOff and readiness probe failed for C based app

我有一个带有两个工作节点的 knative 设置。 helloworld-go示例程序测试成功后。我试图编写一个简单的 C 程序,它只打印环境变量 "REQUEST_METHOD" 和 "QUERY_STRING"。然而 pod 状态是 "CrashLoopBackOff" 并且 kubectl describe 显示:“Readiness probe failed: Get http://192.168.203.181:8022/health: net/http: request canceled (Client.Timeout exceeded while waiting headers)”。我怀疑我的代码有问题。如果可能的话,请建议我的代码有什么问题。 我使用的Dockerfile是这样的:

FROM gcc:4.9
COPY . /usr/src/test-c
WORKDIR /usr/src/test-c
RUN gcc -o test-c main.c
CMD ["./test-c"]

我的 C 代码是:

#include <stdio.h>
#include <stdlib.h>

int main() {
   char* len_ = getenv("REQUEST_METHOD");
   printf("METHOD = %s, %s\n", len_, getenv("QUERY_STRING"));
}

我的 yaml 文件是:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: helloworld-c
  namespace: default
spec:
  template:
    spec:
      containers:
        - image: docker.io/avinashkrc/helloworld-c:latest
          env:
            - name: TARGET
              value: "Go Sample"

我能够使用 pistache for REST 解决问题 api(我想任何框架都应该有效)。