我们正在测试谷歌新的容器原生负载平衡功能。我们成功地遵循了本教程,并且正在尝试将其推广到 GKE 上的三个服务中。
据我所知,NEG 功能和旧版 GCLB 入口对象之间的唯一区别是每个服务中的注释,因此 URL 映射应该工作相同。
我们已更新所有服务以使用此注释,但三分之二的服务Unhealthy
被认为是健康的。服务 yaml 的唯一区别是名称和选择器。
所有部署都有健康检查,当我们手动检查时都是健康的,但 LB 说后端不健康。
我们缺少什么?
Ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: fanout-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "neg-ip"
spec:
backend:
serviceName: frontend-svc
servicePort: 8080
rules:
- host: testneg.test.com
http:
paths:
- path: /*
backend:
serviceName: frontend-svc # Healthy service
servicePort: 8080
- path: /backend/*
backend:
serviceName: backend-svc # Unhealthy service
servicePort: 8080
- path: /notifications/*
backend:
serviceName: notifications-svc # Unhealthy service
servicePort: 8080
--
frontend-svc.yaml
- 除了名称和选择器之外,后端/通知是相同的
apiVersion: v1
kind: Service
metadata:
name: frontend-svc
annotations:
cloud.google.com/neg: '{"ingress": true}' # Creates an NEG after an Ingress is created
spec:
selector:
app: frontend
ports:
- port: 8080
protocol: TCP
targetPort: 8080
--
backend-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: backend
spec:
replicas: 1
minReadySeconds: 60
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
spec:
containers:
image: us.gcr.io/<OUR_DJANGO_IMAGE>
imagePullPolicy: Always
name: backend
ports:
- containerPort: 8080
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 60
periodSeconds: 30
timeoutSeconds: 3
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 60
periodSeconds: 30
timeoutSeconds: 3
terminationGracePeriodSeconds: 60