Google Kubernetes Engine Ingress 后端服务不健康
Google Kubernetes Engine Ingress UNHEALTHY backend service
Kind Note: I have googled a lot and take a look too many questions related to this issue at Whosebug also but couldn't solve my issue, that's why don't mark this as duplicate, please!
我正在尝试在 Google Kubernetes Engine 上部署 2 个服务(一个是 Python flask,另一个是 NodeJS)。我已经为每个服务创建了两个 Kubernetes 部署,为每个 NodePort
类型的服务创建了两个 Kubernetes 服务。然后,我创建了一个 Ingress 并提到了我的 endpoints
但 Ingress 说一个后端服务是 UNHEALTHY
.
这是我的部署 YAML 定义:
# Pyservice deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: pyservice
labels:
app: pyservice
namespace: default
spec:
selector:
matchLabels:
app: pyservice
template:
metadata:
labels:
app: pyservice
spec:
containers:
- name: pyservice
image: docker.io/arycloud/docker_web_app:pyservice
ports:
- containerPort: 5000
imagePullSecrets:
- name: docksecret
# # Nodeservice deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nodeservice
labels:
app: nodeservice
namespace: default
spec:
selector:
matchLabels:
app: nodeservice
template:
metadata:
labels:
app: nodeservice
tier: web
spec:
containers:
- name: nodeservice
image: docker.io/arycloud/docker_web_app:nodeservice
ports:
- containerPort: 8080
imagePullSecrets:
- name: docksecret
而且,这是我的服务和 Ingress YAML 定义:
# pyservcie service
kind: Service
apiVersion: v1
metadata:
name: pyservice
spec:
type: NodePort
selector:
app: pyservice
ports:
- protocol: TCP
port: 5000
nodePort: 30001
---
# nodeservcie service
kind: Service
apiVersion: v1
metadata:
name: nodeservcie
spec:
type: NodePort
selector:
app: nodeservcie
ports:
- protocol: TCP
port: 8080
nodePort: 30002
---
# Ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: "gce"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: pyservice
servicePort: 5000
- path: /*
backend:
serviceName: pyservice
servicePort: 5000
- path: /node/svc/
backend:
serviceName: nodeservcie
servicePort: 8080
pyservice
工作正常,但 nodeservice
显示为 UNHEALTHY
后端。这是一个截图:
即使我已经为所有 gke-....
编辑了 Firewall Rules
并允许所有端口只是为了解决这个问题,但它仍然显示 nodeservice
的 UNHEALTHY
状态].
这是怎么回事?
提前致谢!
为什么要使用 GCE 入口 class 然后指定 nginx 重写注释?如果您还没有意识到,注解不会对 GCE 入口执行任何操作。
您还选择了 'nodeservcie' 而不是 'nodeservice'。
Kind Note: I have googled a lot and take a look too many questions related to this issue at Whosebug also but couldn't solve my issue, that's why don't mark this as duplicate, please!
我正在尝试在 Google Kubernetes Engine 上部署 2 个服务(一个是 Python flask,另一个是 NodeJS)。我已经为每个服务创建了两个 Kubernetes 部署,为每个 NodePort
类型的服务创建了两个 Kubernetes 服务。然后,我创建了一个 Ingress 并提到了我的 endpoints
但 Ingress 说一个后端服务是 UNHEALTHY
.
这是我的部署 YAML 定义:
# Pyservice deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: pyservice
labels:
app: pyservice
namespace: default
spec:
selector:
matchLabels:
app: pyservice
template:
metadata:
labels:
app: pyservice
spec:
containers:
- name: pyservice
image: docker.io/arycloud/docker_web_app:pyservice
ports:
- containerPort: 5000
imagePullSecrets:
- name: docksecret
# # Nodeservice deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nodeservice
labels:
app: nodeservice
namespace: default
spec:
selector:
matchLabels:
app: nodeservice
template:
metadata:
labels:
app: nodeservice
tier: web
spec:
containers:
- name: nodeservice
image: docker.io/arycloud/docker_web_app:nodeservice
ports:
- containerPort: 8080
imagePullSecrets:
- name: docksecret
而且,这是我的服务和 Ingress YAML 定义:
# pyservcie service
kind: Service
apiVersion: v1
metadata:
name: pyservice
spec:
type: NodePort
selector:
app: pyservice
ports:
- protocol: TCP
port: 5000
nodePort: 30001
---
# nodeservcie service
kind: Service
apiVersion: v1
metadata:
name: nodeservcie
spec:
type: NodePort
selector:
app: nodeservcie
ports:
- protocol: TCP
port: 8080
nodePort: 30002
---
# Ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: "gce"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: pyservice
servicePort: 5000
- path: /*
backend:
serviceName: pyservice
servicePort: 5000
- path: /node/svc/
backend:
serviceName: nodeservcie
servicePort: 8080
pyservice
工作正常,但 nodeservice
显示为 UNHEALTHY
后端。这是一个截图:
即使我已经为所有 gke-....
编辑了 Firewall Rules
并允许所有端口只是为了解决这个问题,但它仍然显示 nodeservice
的 UNHEALTHY
状态].
这是怎么回事?
提前致谢!
为什么要使用 GCE 入口 class 然后指定 nginx 重写注释?如果您还没有意识到,注解不会对 GCE 入口执行任何操作。
您还选择了 'nodeservcie' 而不是 'nodeservice'。