我已经使用 Google Cloud Kubernetes 上的 helm 安装了 nginx ingress。服务、控制器和默认后端均已启动并运行,我可以在 /healthz 端点上执行 GET 请求。但是,当我尝试设置我的 Ingress 时,它显示的负载均衡器 IP 与控制器不同。在我的情况下,控制器显示 35.246.249.9(端口 80 和 443),而 Ingress 显示 35.246.171.243。当我尝试连接到第二个 IP 时,连接被拒绝。
这是我的 Ingress yaml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-nginx-integration
namespace: integration
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/ingress.global-static-ip-name: website-com
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: website.com
http:
paths:
- backend:
serviceName: website
servicePort: 4000
入口描述:
Name: ingress-nginx-integration
Namespace: integration
Address: 35.246.171.243
Default backend: default-http-backend:80 (10.20.2.8:8080)
Rules:
Host Path Backends
---- ---- --------
website.com
website:4000 (<none>)
Annotations:
kubernetes.io/ingress.global-static-ip-name: website-com
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: false
kubectl.kubernetes.io/last-applied-configuration: ....
kubernetes.io/ingress.class: nginx
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal UPDATE 18m (x9 over 58m) nginx-ingress-controller Ingress integration/ingress-nginx-integration
Normal DELETE 6m34s nginx-ingress-controller Ingress integration/ingress-nginx-integration
Normal CREATE 2m16s (x2 over 59m) nginx-ingress-controller Ingress integration/ingress-nginx-integration
控制器描述:
Name: nginx-ingress-controller
Namespace: integration
Labels: app=nginx-ingress
chart=nginx-ingress-1.1.5
component=controller
heritage=Tiller
release=nginx-ingress
Annotations: <none>
Selector: app=nginx-ingress,component=controller,release=nginx-ingress
Type: LoadBalancer
IP: 10.23.243.186
LoadBalancer Ingress: 35.246.249.9
Port: http 80/TCP
TargetPort: http/TCP
NodePort: http 30996/TCP
Endpoints: 10.20.2.62:80
Port: https 443/TCP
TargetPort: https/TCP
NodePort: https 32752/TCP
Endpoints: 10.20.2.62:443
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Ingress 和控制器都在“integration”命名空间内运行。我大部分内容都遵循了本教程:https://cloud.google.com/community/tutorials/nginx-ingress-gke当我使用默认的 gce 入口控制器时,一切正常,但我需要 http -> https 重定向。
为什么它显示不同的负载均衡器 IP,对吗?如果对,为什么它拒绝连接?
如果您需要更多信息,请与我们联系。
答案1
好的,我的设置是正确的。看起来需要一段时间才能解决所有问题。等待 12 小时后,现在一切运行正常。