Set static external IP for my load balancer on GKE
I am trying to set up a static external IP for my load balancer on GKE but having no luck. Here is my Kubernetes service config file:
kind: Service apiVersion: v1 metadata: name: myAppService spec: selector: app: myApp ports: - protocol: TCP port: 3001 targetPort: 3001 type: LoadBalancer loadBalancerIP: *********
This doesn't work. I expect to see my external IP as ********* but it just says pending:
➜ git:(master) kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ********* <none> 443/TCP 5m myAppService ********* <pending> 3001:30126/TCP 5m
➜ git:(master) kubectl describe services Name: kubernetes Namespace: default Labels: component=apiserver provider=kubernetes Annotations: <none> Selector: <none> Type: ClusterIP IP: ********* Port: https 443/TCP Endpoints: ********* Session Affinity: ClientIP Events: <none> Name: myAppService Namespace: default Labels: <none> Annotations: <none> Selector: app=myApp Type: LoadBalancer IP: ********* Port: <unset> 3001/TCP NodePort: <unset> 30126/TCP Endpoints: Session Affinity: None Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 5m 20s 7 service-controller Normal CreatingLoadBalancer Creating load balancer 5m 19s 7 service-controller Warning CreatingLoadBalancerFailed Error creating load balancer (will retry): Failed to create load balancer for service default/myAppService: Cannot EnsureLoadBalancer() with no hosts
I've encountered the same problem, but after reading the docs carefully, it turned out that I was just reserving the static IP incorrectly.
A service of type
LoadBalancer creates a network load balancer, which is regional. Therefore, also the static IP address you reserve needs to be regional also (in the regoin of your cluster).
When I changed to this solution, everything worked fine for me...
Setting up HTTP(S) Load Balancing with Ingress, How do I assign a static IP address to a domain? I've encountered the same problem, but after reading the docs carefully, it turned out that I was just reserving the static IP incorrectly. A service of type LoadBalancer creates a network load balancer, which is regional. Therefore, also the static IP address you reserve needs to be regional also (in the regoin of your cluster).
This got me stuck as well, I hope someone finds this helpful.
In addition to what Dirk said, if you happen to reserve a global static IP address as oppose to a regional one; you need to use Ingres as describe here in documentation: Configuring Domain Names with Static IP Addresses specifically step 2b.
So basically you reserve the static ip
gcloud compute addresses create helloweb-ip --global
and add an Ingres:
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: helloweb # this is where you you add your reserved ip annotations: kubernetes.io/ingress.global-static-ip-name: helloweb-ip labels: app: hello spec: backend: serviceName: helloweb-backend servicePort: 8080 --- apiVersion: v1 kind: Service metadata: name: helloweb-backend labels: app: hello spec: type: NodePort selector: app: hello tier: web ports: - port: 8080 targetPort: 8080
The doc also describe how to assign a static ip if you choose type "LoadBalancer" under step 2a.
How to specify static IP address for Kubernetes load balancer , This got me stuck as well, I hope someone finds this helpful. In addition to what Dirk said, if you happen to reserve a global static IP address as Click Add frontend IP and port. Set the Name to l7-ilb-gke-forwarding-rule. Set the Protocol to HTTP. Set the Subnetwork to backend-subnet. Under Internal IP, select Reserve a static internal IP address. In the panel that appears provide the following details: Name: l7-ilb-gke-ip; In the Static IP address section, select Let me choose.
After a time consuming search through unnecessarily complicated and long documentation, this simple blog solved my problem: http://terrenceryan.com/blog/index.php/making-kubernetes-ip-addresses-static-on-google-container-engine/
static IP address, First create a new static External IP address on GCP Console VPC Network -> External IP addresses. if you want to change the loadbalancer IP address of the existing service, go to the Kubernetes Engine -> Services , click on your service name and Edit YAML and add loadBalancerIP: in spec section. (External network load balancers using target pools do not require health checks.) When GKE creates an internal TCP/UDP load balancer, it creates a health check for the load balancer's backend service based on the readiness probe settings of the workload referenced by the GKE Service. For more information, see to Internal TCP/UDP Load Balancing.
Set static external IP for my load balancer on GKE, What is sure is that this IP must first be one of your pre-allocated static IPs. but it's still useful especially the part "Configure the load balancing service". If you just create a Kubernetes LoadBalancer on GCE, it will create a network you've an external IP allocated when you run kubectl get svc , and look up that IP in the list For more information about creating a static external IP address for an Ingress, see Configuring a static IP address. Setting up HTTPS (TLS) between client and load balancer An HTTP(S) load balancer acts as a proxy between your clients and your application.
How to assign External IP address(static) to a GCP Kubernetes , Documentation · Serving Component · Assigning static IPs - GKE The IP address to access the gateway is the external IP address of the Therefore, in order to set a static IP for the gateway you must to set the external IP address of the CLUSTER-IP EXTERNAL-IP PORT(S) AGE xxxxxxx-ingressgateway LoadBalancer Delete the load balancing resources: kubectl delete ingress,service -l app=hello. Release the reserved static IP. After the load balancer is deleted, the unused but reserved IP address is no longer free of charge and is billed per unused IP address pricing. Run the following commands to release the static IP resource: If you followed Step 2(a):
How to choose the external IP address of a Kubernetes load , Configure static IP addresses on GKE; Configure static IP addresses for Anthos GKE By default, the IP addresses for these load balancers are ephemeral. Follow the instructions in Reserving a static external IP address to Create a Service to expose your Deployment. In the Deployment details page, click Expose. In the New port mapping box, set Port to 80, and set Target port to 8080. Leave Protocol set to TCP. Click Done. From the Service type drop-down menu, select Cluster IP. For Service name, enter my-cip-service. Click Expose.