GKE Nginx入口-分配静态ip



我在带有ingress.class:的GKE集群中有一个入口控制器

kubernetes.io/ingress.class: "nginx"

我想给这个入口控制器分配一个静态ip。我遵循了本教程创建和分配静态ip:

https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip

基本上,我保留了一个静态IP,并尝试使用将其分配给入口

kubernetes.io/ingress.global-static-ip-name: "my-ingress-static-ip"

问题

ip地址入口没有更改为新分配的静态ip。

我应该如何将此静态IP分配给入口?

我的配置

控制器部署使用:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.40.2/deploy/static/provider/cloud/deploy.yaml

我的入口山:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: api-ingress
namespace: development
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
kubernetes.io/ingress.class: "nginx"
# Disallow http - Allowed only with gce controller
# kubernetes.io/ingress.allow-http: "false"
# Enable client certificate authentication
nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
# Create the secret containing the trusted ca certificates
nginx.ingress.kubernetes.io/auth-tls-secret: "development/api-ingress-ca-secret"
# Specify the verification depth in the client certificates chain
nginx.ingress.kubernetes.io/auth-tls-verify-depth: "1"
# Automatically redirect http to https
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
# Use regex in paths
nginx.ingress.kubernetes.io/use-regex: "true"
# For notifications we add the proxy headers
nginx.ingress.kubernetes.io/configuration-snippet: |  
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Set a static ip for the ingress
kubernetes.io/ingress.global-static-ip-name: "my-ingress-static-ip"
spec:
tls:
- hosts:
- my-host.com
secretName: api-tls-certificate
rules:
- host: my-host.com
http:
paths:
- path: /(v[0-9]/.*)
backend:
serviceName: my-service
servicePort: 443

删除入口或控制器并没有解决问题。

本教程仅适用于GCE入口控制器。

注意:本教程不适用于NGINX入口控制器。

要设置IP地址,需要在LoadBalancer服务的spec:部分中指定实际的IP地址。

spec:
type: LoadBalancer
externalTrafficPolicy: Local
loadBalancerIP: ACTUAL.IP.ADRESS.HERE
ports:

请注意,请确保您的ip地址是区域静态ip,而不是全局ip。我花了很长时间才弄明白。

最新更新