谷歌上的kubernetes无法创建负载均衡器ip静态

时间:2017-03-20 01:18:24

标签: kubernetes load-balancing google-kubernetes-engine static-ip-address

虽然我保留了一个静态IP,但是我没有创建负载均衡器,因此收到了以下警告:

> kubectl describe svc --namespace=api-1dt-dc
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason              Message
  --------- --------    -----   ----            -------------   --------    ------              -------
  48m       2m      15  {service-controller }           Normal      CreatingLoadBalancer        Creating load balancer
  48m       2m      15  {service-controller }           Warning     CreatingLoadBalancerFailed  Error creating load balancer (will retry): Failed to create load balancer for service api-1dt-dc/review-k8s-4yl6zk: requested ip 35.186.202.220 is neither static nor assigned to LB ad3c982840d0311e7b45942010a84004(api-1dt-dc/review-k8s-4yl6zk): <nil>

3 个答案:

答案 0 :(得分:12)

好的,它似乎只适用于区域IP ......

答案 1 :(得分:1)

正如托马斯·帕奎尔(Thomas Parquier)所说的那样,这可能与非区域IP有关。

以此服务为例:

apiVersion: v1
kind: Service
metadata:
  name: my-service-name
  annotations:
spec:
  selector:
    app: deployment-name
  clusterIP: 10.0.5.890
  externalTrafficPolicy: Cluster
  ports:
    - name: https
      port: 443
      protocol: TCP
      targetPort: 443
  sessionAffinity: None
  type: LoadBalancer
  loadBalancerIP: "72.229.?.?"

首先删除您的服务

kubectl delete svc my-service-name;

从您的服务中删除loadBalancerIP行(最后一条)并应用修复程序:

kubectl apply -f my-service-name.yaml

然后,等待EXTERNAL_IP IP地址已分配给您的服务

kubectl get svc;

在Google控制台中将此地址标记为静态 https://console.cloud.google.com/networking/addresses/list

最后,为您的服务中的loadBalancerIP行分配新的IP地址

答案 2 :(得分:0)

在尝试使用LoadBalancer公开时遇到相同的问题。

  Normal   EnsuredLoadBalancer         2m (x2 over 1h)  service-controller  Ensured load balancer
  Warning  CreatingLoadBalancerFailed  2m (x2 over 1h)  service-controller  Error creating load balancer (will retry): not persisting update to service 'default/cb-gke-demo-ui' that has been changed since we received it: Operation cannot be fulfilled on services "cb-gke-demo-ui": the object has been modified; please apply your changes to the latest version and try again

不确定如何解决? GKE k8s集群跨AZz部署。