【发布时间】:2026-01-22 04:15:01
【问题描述】:
从市场上安装了 Prometheus 和 Grafana。想让 Grafana 可以从外部访问。
创建了以下服务:
apiVersion: v1
kind: Service
metadata:
name: grafana-service
namespace: prometheus-grafana
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
type: NodePort
externalTrafficPolicy: Cluster
sessionAffinity: None
selector:
k8s-app: grafana
ports:
- name: http
port: 80
protocol: TCP
targetPort: 3000
接下来,创建 Ingress,如下所示:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.global-static-ip-name: "my-sample-app"
name: grafana-ingress
namespace: prometheus-grafana
spec:
backend:
serviceName: grafana-service
servicePort: 80
应用 Ingress(使用 kubectl apply)后,我转到 GKE Web UI 中的 Ingress 详细信息视图,查看创建进度,这就是错误消息的位置:
Error during sync: error running backend syncing routine: error ensuring health check: googleapi: Error 400: Invalid value for field 'resource.timeoutSec': '30'. TimeoutSec should be less than checkIntervalSec., invalid
我做错了什么以及如何解决?有没有更好、更正确的方式让 Grafana 公开访问?
【问题讨论】:
-
如果您从 Google 市场使用它们,您已经获得了一个 url,因为它已经为您生成了服务,或者您是否使用其他方式进行部署?
-
@tarunkhosla 刚从市场。自动生成的服务是 ClusterIP 类型,似乎不适合入口的目标。当我尝试定位现有服务时,我收到错误:
error while evaluating the ingress spec: service "prometheus-grafana/prometheus-1-grafana" is type "ClusterIP", expected "NodePort" or "LoadBalancer" -
github.com/GoogleCloudPlatform/click-to-deploy/tree/master/k8s/… 从这里尝试,它解释了如何公开它。
-
@tarunkhosla 这似乎确实是正确的方法,并且有效,谢谢!我不知何故错过了文档中的那部分。您可以将其作为官方答案。虽然原始错误消息的原因仍然是个谜。
标签: kubernetes google-kubernetes-engine kubernetes-ingress