我有一个带有两个工作节点的 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 cancelled (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"