我正在尝试在GCE中的Kubernetes(服务器1.6.4)中部署grafana实例 . 我使用以下清单:
Deployment (full version):
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: grafana
spec:
replicas: 1
template:
metadata:
labels:
name: grafana
spec:
initContainers:
…
containers:
- name: grafana
image: grafana/grafana
readinessProbe:
httpGet:
path: /login
port: 3000
…
Service :
apiVersion: v1
kind: Service
metadata:
name: grafana
spec:
selector:
name: grafana
ports:
- protocol: TCP
port: 3000
type: NodePort
Ingress :
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: grafana
spec:
tls:
- secretName: grafana.example.com
backend:
serviceName: grafana
servicePort: 3000
事实证明,grafana服务于 /
上的302,但默认的GCE入口 Health 检查预计在 /
(source)上有200 . 如您所见,Deployment(第22行)中有一个自定义的readinessProbe .
一旦我将这些资源发布到kube-apiserver,一切都会毫无错误地创建 . 具体来说,Ingress得到一个公共ip4地址,但 the healtcheck is set up with the default / path instead of the custom one configured in the readinessProbe . 因此,如果我是Ingress的公共ip4地址,我会获得502 .
通过在GCE控制台中手动将探测路径更改为 /login
,可以解决此问题 .
2 回答
引自here:
解决方案是在
ports
中声明用于运行状况检查的端口,除了添加自定义readinessProbe
:自定义 Health 检查
使用GLBC插件
你的问题并不十分清楚,但如果你使用GCE Load-Balancer Controller (GLBC) Cluster Addon,你可以customize the health check path .
GLBC插件页面在_2762652中提及:
没有GLBC插件
如果您没有使用插件,目前Kubernetes确实要求您在
/
路径上为GET
请求提供成功的运行状况检查,否则后端将不会获得任何流量 .在这个bug中有一些关于此的背景知识 .
Google容器引擎(GKE)
如果您使用的是Google容器引擎(GKE),则 Health 检查的默认Kubernetes要求相同apply there too .
回答您的真实问题
说完所有这些,正如你(@mmoya)在你的答案中指出的那样,将用于准备探测的相同端口添加为pod中的一个端口可以解决你的情况问题,因为端口本身没有暴露在外面否则就是吊舱 . 这导致Kubernetes依赖于
/
的 Health 检查 .