我们为部署到 EKS 的服务有以下配置,但每当我们进行部署时,它都会导致大约 120 秒的停机时间。
当我直接转发到新 pod 时,我可以成功地向它发出请求,因此 pod 本身看起来很好。似乎是没有路由流量的 AWS NLB 或与网络相关的东西,但我不确定,我不知道在哪里进一步调试。
我尝试了几件事无济于事:添加 a readinessProbe
,尝试增加initialDelaySeconds
to 120
,尝试切换到IP
ELB 目标,而不是instance
ELB 目标类型,尝试减少 NLB 的健康检查间隔,但实际上并没有被应用,并且保持为 30 秒。
任何帮助将不胜感激!
---
# Autoscaler for the frontend
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: my-frontend
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-frontend
minReplicas: 3
maxReplicas: 8
targetCPUUtilizationPercentage: 60
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-frontend
labels:
app: my-frontend
spec:
replicas: 3
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
selector:
matchLabels:
app: my-frontend
template:
metadata:
labels:
app: my-frontend
spec:
containers:
- name: my-frontend
image: ${DOCKER_IMAGE}
ports:
- containerPort: 3001
name: web
resources:
requests:
cpu: "300m"
memory: "256Mi"
livenessProbe:
httpGet:
scheme: HTTP
path: /v1/ping
port: 3001
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 10
readinessProbe:
httpGet:
scheme: HTTP
path: /v1/ping
port: 3001
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 10
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: ${SSL_CERTIFICATE_ARN}
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
service.beta.kubernetes.io/aws-load-balancer-healthcheck-interval: "10"
service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled: "true"
service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout: "60"
name: my-frontend
labels:
service: my-frontend
spec:
ports:
- name: http
port: 80
targetPort: 3001
- name: https
port: 443
targetPort: 3001
externalTrafficPolicy: Local
selector:
app: my-frontend
type: LoadBalancer