我尝试让 postStart 钩子在容器中工作,但总是失败。我收到的错误如下:
kubelet[1057]: E0212 11:07:20.205922 1057 handlers.go:78] "Exec lifecycle hook for Container in Pod failed" err=<
kubelet[1057]: command 'curl -H 'Content-Type: application/json' -d '{ \"restarted\": True}' -X POST http://localhost:5000/restarted' exited with 2: curl: (2) no URL specified
kubelet[1057]: curl: try 'curl --help' or 'curl --manual' for more information
kubelet[1057]: > execCommand=[curl -H 'Content-Type: application/json' -d '{ \"restarted\": True}' -X POST http://localhost:5000/restarted] containerName="srsran-cu-du" pod="srsran/srsran-project-cudu-chart-78f658b865-pjvt2" message=<
kubelet[1057]: curl: (2) no URL specified
kubelet[1057]: curl: try 'curl --help' or 'curl --manual' for more information
kubelet[1057]: >
我的清单中的钩子如下所示:
lifecycle:
postStart:
exec:
command: [ "curl", "-H", "'Content-Type: application/json'", "-d", "'{ \"restarted\": True}'", "-X", "POST http://localhost:5000/restarted" ]
其呈现为curl -H 'Content-Type: application/json' -d '{ \"restarted\": True}' -X POST http://localhost:5000/restarted
。
如果我直接在容器中运行 curl 命令,它会正常工作。但是当通过 posStart 钩子运行它时,它不起作用。我做错了什么?
我尝试过用 替换'
但\\\"
也没有用。