Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes on google failed to create load balancer ip static

Although I reserved a static IP I got the following warning, while not having load balancer created :

> 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>
like image 234
Thomas Parquier Avatar asked Mar 20 '17 01:03

Thomas Parquier


People also ask

How do I set a static IP address for Kubernetes LoadBalancer?

To create a LoadBalancer service with the static public IP address, add the loadBalancerIP property and the value of the static public IP address to the YAML manifest. Create a file named load-balancer-service. yaml and copy in the following YAML. Provide your own public IP address created in the previous step.

What is Kubernetes IO ingress global static IP name?

The kubernetes.io/ingress.global-static-ip-name annotation specifies the name of the global IP address resource to be associated with the HTTP(S) Load Balancer. Note: Provisioning and configuring the load balancer might take a few minutes.


3 Answers

OK, it seems to work only with regional IPs...

like image 62
Thomas Parquier Avatar answered Oct 20 '22 02:10

Thomas Parquier


As Thomas Parquier said higher, it can be related to the fact that is not a regional ip.

Taking this service as an example:

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.?.?"

First delete your service

kubectl delete svc my-service-name;

Remove loadBalancerIP line (last one) from your Service and apply fixes:

kubectl apply -f my-service-name.yaml

Then, wait that an EXTERNAL_IP ip address has been assigned to your service

kubectl get svc;

Mark this address as static in google console https://console.cloud.google.com/networking/addresses/list

And finally, assign newly ip address to loadBalancerIP line in your Service

like image 27
lionelto Avatar answered Oct 20 '22 01:10

lionelto


Hitting same issue while trying to expose with 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

Not sure how to fix it? GKE k8s cluster is deployed across AZz.

like image 1
ram dhakne Avatar answered Oct 20 '22 02:10

ram dhakne