GKE:入口负载平衡器不使用配置的静态IP

时间:2019-01-29 13:03:11

标签: google-cloud-platform kubernetes-ingress google-kubernetes-engine

我已经在GCP中使用Terraform创建了一个全局静态IP地址。但是,当我尝试将其分配给GKE集群内的入口控制器时,它将被忽略:

这是我的kubernetes配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name: homefully-ingress
    annotations:
        kubernetes.io/ingress.global-static-ip-name: "homefully-ingress-root"   
    labels:
        app: homefully-ingress
spec:
    # ...

此处引用的IP地址如下:

NAME                    REGION        ADDRESS        STATUS
homefully-ingress-root  europe-west3  35.234.83.106  RESERVED

但是,Ingress不会使用该IP地址,而是使用另一个随机IP地址。这是一个很大的问题,因为我没有使用Google的DNS服务,因此我需要依靠静态IP。

相反,这就是我得到的:

Name:             homefully-ingress
Namespace:        default
Address:          35.227.252.112
Default backend:  auth-proxy-staging:4180 (10.4.0.7:4180)
Rules:
  Host                       Path  Backends
  ----                       ----  --------
  adminpanel.homefully.tech
                                homefully-management-frontend-website-staging:80 (10.4.2.7:80)
Annotations:
  kubectl.kubernetes.io/last-applied-configuration:  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.class":"gce","kubernetes.io/ingress.global-static-ip-name":"homefully-ingress-root"},"labels":{"app":"homefully-ingress"},"name":"homefully-ingress","namespace":"default"},"spec":{"backend":{"serviceName":"auth-proxy-staging","servicePort":4180},"rules":[{"host":"adminpanel.homefully.tech","http":{"paths":[{"backend":{"serviceName":"homefully-management-frontend-website-staging","servicePort":80}}]}}]}}

  kubernetes.io/ingress.class:                  gce
  kubernetes.io/ingress.global-static-ip-name:  homefully-ingress-root
  ingress.kubernetes.io/backends:               {"k8s-be-31611--026ed6556721059b":"Unknown","k8s-be-32450--026ed6556721059b":"Unknown"}
  ingress.kubernetes.io/forwarding-rule:        k8s-fw-default-homefully-ingress--026ed6556721059b
  ingress.kubernetes.io/target-proxy:           k8s-tp-default-homefully-ingress--026ed6556721059b
  ingress.kubernetes.io/url-map:                k8s-um-default-homefully-ingress--026ed6556721059b
Events:
  Type    Reason  Age   From                     Message
  ----    ------  ----  ----                     -------
  Normal  ADD     8m    loadbalancer-controller  default/homefully-ingress
  Normal  CREATE  7m    loadbalancer-controller  ip: 35.227.252.112

我在这里找不到错误消息或任何提示。非常感谢一些建议

1 个答案:

答案 0 :(得分:2)

愚蠢的我-这不是全球IP地址。在这种情况下,只会分配一个随机的新