1

我正在尝试为我的 Traefik 入口负载均衡器分配一个静态 IP 地址,但在 Google Cloud 上总是得到相同的响应:

Error creating load balancer (will retry): failed to ensure load   balancer for service default/traefik-service: requested ip   "35.185.139.44" is neither static nor assigned to the LB
coffee:gke Steven$ glcoud compute addresses list

我确实注意到所有静态都在保留中,而不是在使用中

# Declare Traefik ingress service
kind: Service
apiVersion: v1
metadata:
  name: traefik-service
spec:
  selector:
   app: traefik-gke-demo
   tier: reverse-proxy
  ports:
   - port: 80
     name: http
   - port: 443
     name: https
   - port: 8080
     name: admin
   type: LoadBalancer
   loadBalancerIP:  35.185.xx.xx
4

2 回答 2

0

服务声明正确,运行 Kubernetes v1.1 的 Google Container Engine 支持loadBalancerIP,您只需要事先为您的项目创建静态 IP,即

gcloud compute addresses create traefik-static-lb

gcloud compute addresses list

保留后,创建 LB 服务

升级版:

这是分配静态 IP 的我的 LB 服务的示例:

sukhoversha@sukhoversha:~/GCP$ gcloud compute addresses list
NAME            ADDRESS/RANGE   TYPE      PURPOSE  NETWORK  REGION        SUBNET  STATUS
test-static-ip  35.198.94.139   EXTERNAL                    europe-west3          IN_USE


sukhoversha@sukhoversha:~/GCP$ kk get svc rabbitmq-management
NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)           AGE
rabbitmq-management   LoadBalancer   10.59.241.225   35.198.94.139   15672:31728/TCP   4d


sukhoversha@sukhoversha:~/GCP$ kk get svc rabbitmq-management -oyaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app: rabbitmq
  name: rabbitmq-management
  namespace: default
spec:
  clusterIP: 10.59.241.225
  externalTrafficPolicy: Cluster
  loadBalancerIP: 35.198.94.139
  ports:
  - name: http
    nodePort: 31728
    port: 15672
    protocol: TCP
    targetPort: 15672
  selector:
    app: rabbitmq
  sessionAffinity: None
  type: LoadBalancer
于 2019-06-28T09:30:22.180 回答
-1

Service当您应用规范时,Kubernetes Engine 将使用 Google Cloud Load-Balancer (GCLB) 自动为您提供一个 TCP (!) 负载均衡器type: LoadBalancer

所以,删除它,loadBalancerIP: 35.185.139.44然后kubectl apply --filename=...再等待,然后kubectl get service/traefik-service您应该会看到 LB 为您提供了服务。

或者:

kubectl get services \
--selector=app=traefik-gke-demo,tier=reverse-proxy \
--output=jsonpath="{.status.loadBalancer.ingress[0].ip}"

以及以下的一些变体,以确认负载均衡器已配置:

gcloud compute forwarding-rules list \
--format="value(IPAddress) \
--project=[[YOUR-PROJECT]]

注意使用Service这种方式将提供一个 TCP 负载平衡器。如果您更喜欢 HTTP|L7 负载均衡器,那么您应该使用Ingress.

于 2019-06-27T22:00:26.130 回答