google-cloud-platform - 后端的readinessProbe路径是否需要在Endpoint openapi.yaml文件中声明?
问题描述
我正在部署一个作为 GKE 容器后端的项目,前端有一个 Cloud Endpoints API。它通过一个 Ingress 和 NodePort 服务。我已经在 ESP 容器上声明了一个就绪探测:
readinessProbe:
httpGet:
path: /ping
port: 8080
但是我观察到 /ping 路径必须在没有任何安全性的情况下在 openapi.yaml 中声明,否则它返回 404,如果声明了一些安全性定义,则返回 401。
这是预期的吗?我在 Endpoints Samples 存储库中看不到任何相关内容:
https://github.com/GoogleCloudPlatform/endpoints-samples/tree/master/k8s
解决方案
我遇到了同样的问题,但似乎可以对 GCE 边车和最终的后端(例如您实际构建的 api)进行健康检查。
诀窍是,您的 api 的运行状况检查必须配置为云端点容器(而不是您的 api 容器)上的就绪探针。您检查的端点也必须没有针对它的安全性,因此它是可公开访问的(尽管您似乎也可以使用 api 密钥配置运行状况检查)。
我遵循了之前的建议,并将“healthz”参数添加到 esp 容器中。我的 API 在端口 80 上运行,其状态端点为未受保护/api/status
spec:
containers:
- name: esp
image: gcr.io/endpoints-release/endpoints-runtime:1
args: [
"--http_port=8081",
"--backend=127.0.0.1:80",
"--service=MY SERVICE",
"--rollout_strategy=managed",
"-z", "healthz",
]
ports:
- containerPort: 8081
readinessProbe:
httpGet:
path: /api/status/
port: 8081
- name: api
image: MY IMAGE
ports:
- containerPort: 80
这行得通,因此检查现在正在验证两个容器都在运行一个readinessProbe
. 有趣的是,当我检查 LoadBalancer 时,它还配置了一个反对/healthz
. 这对于诊断端点容器正在工作的情况很有用,但该 api 不是
推荐阅读
- ssl - 如何在 pfsense 中使用 squid 记录 https 内容?
- python - 如何在 ffill 或 bfill 等浮点列中填充 0.00 值?
- gradle - gradle checkstyle 错误:预期的文件集合只包含一个文件,但是,它包含 14 个文件
- java - 如何从用户界面获取字符串将其放入方法中并将其作为函数返回?
- c - Lwip tcp_write payload pbuf 使用 memcpy 给出不一致的值
- java - 我们可以在默认目录之外的 ftp 服务器上上传文件吗?
- android - Firebase In App Messaging 不断删除显示事件侦听器
- python - 使用线程时如何将变量传递给 Flask 函数?
- mysql - 如何制作等待导入sql文件?
- c - 为什么其他部分被执行3次?