【问题标题】:GKE Ambassador http -> https redirect, health check issuesGKE 大使 http -> https 重定向、健康检查问题
【发布时间】:2021-03-29 12:53:14
【问题描述】:
我正在关注本教程 https://www.getambassador.io/docs/latest/topics/running/ambassador-with-gke/,但我在 http -> https 重定向方面遇到了严重问题。
- 我无法在 GKE 上编辑健康检查端口,默认配置为服务端口,无法更改
- 如果我创建新的健康检查,在应用
Host insecure.action: Redirect 后,后端的 hc 会回到默认值。如果默认 hc 被删除,它会被重新创建。如果我以某种方式强制我的自定义 hc,它不会再次工作,在 pod 日志中我看到这个 "GET /ambassador/v0/check_ready HTTP/1.1" 301
- 如果我在主机 http 中设置
insecure.action: Redirect -> https 会在 LB 运行状况检查导致一切崩溃之前工作几秒钟
【问题讨论】:
标签:
google-kubernetes-engine
health-check
google-cloud-load-balancer
ambassador
【解决方案1】:
主机中的insecure.action: Redirect 应该是Route
还需要创建自定义健康检查:
kind: BackendConfig
metadata:
name: my-backendconfig
spec:
healthCheck:
checkIntervalSec: 10
timeoutSec: 10
healthyThreshold: 2
unhealthyThreshold: 2
type: HTTP
requestPath: /ambassador/v0/check_ready
port: 8080
并添加到ambassador.yaml
kind: Service
metadata:
name: ambassador
annotations:
cloud.google.com/backend-config: '{"ports": {"8080":"my-backendconfig"}}'
spec:
type: NodePort
ports:
- name: http
port: 8080
targetPort: 8080
selector:
service: ambassador
Ingress 应该禁用 http:
kind: Ingress
metadata:
name: basic-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "myip"
kubernetes.io/ingress.allow-http: "false"
spec:
tls:
- secretName: my-self-managed-cert
backend:
serviceName: ambassador
servicePort: 8080
这将只创建完美运行的 HTTPS LB,现在我们需要 http -> https 重定向。
只需转到负载平衡屏幕并再创建 1 个负载平衡器(无后端),它只会将 http 重定向到 https。