我知道k8s有readynessProbe和httpGet方法来检查服务是否可以工作。是否有像httpPost方法这样的方法来运行POST请求到/api/postService,并检查返回代码?或者用一些棘手的方法在yaml文件中完成。
发布于 2019-05-02 10:43:28
可以通过运行curl作为执行readinessProbe来完成:
readinessProbe:
exec:
command:
- "curl"
- "-X POST"
- "-f"
- "http://localhost/api/postService"当然,您需要确保在打包您的服务的Docker映像中安装curl。
发布于 2020-03-03 11:49:25
我认为这种方式更可靠。
readinessProbe:
exec:
command:
- sh
- -c
- >-
curl -X POST http://localhost/api/postService -H 'Content-Type: application/json' -d '{\"test\": \"OK\"}'https://stackoverflow.com/questions/55949932
复制相似问题