Nick
Nick

Reputation: 295

Very high load balancing costs for minimal Kubernetes Engine setup on Google Cloud Platform

I am trying to determine the most minimal Kubernetes Engine setup for a simple public facing (public load balanced IP) web app.

I have mine setup as follows:

My monthly billing cost is: CA$48.10: half of that being from Compute Engine Network Load Balancing: Forwarding Rule Minimum Service Charge in Americas: 744 Hours CA$23.82

Is there someway to reduce this cost? Or is this truly the cost of a minimal Kubernetes Cluster serving an app with a public domain name?

Upvotes: 25

Views: 7043

Answers (4)

Voy
Voy

Reputation: 6284

You can create a NodePort instead of Load Balancer. See docs for more.


Create a Service

  1. Open the Deployment details page by going to your Workloads and clicking on the name of your deployment.
  2. Click on "Actions" > "Expose."
  3. In the Expose dialog, configure the port mapping:
    • Port: 80
    • Target port: [YOUR_APP_PORT]
    • Protocol: TCP
  4. From the "Service type" dropdown, choose "NodePort."
  5. Click "Expose."
  6. Take note of the 'Node port' once the Service is ready. You'll be able to see it in the service details page under Port section.

gcp-port

Create a Firewall Rule

  1. Go to the Firewall policies.
  2. Click "Create firewall rule."
  3. Enter a name like "test-node-port."
  4. Choose "All instances in the network" from the Targets dropdown.
  5. Set "Source IPv4 ranges" to "0.0.0.0/0."
  6. Under "Protocols and ports," select "Specified protocols and ports."
  7. Check the "tcp" checkbox and input the Node Port value you noted earlier.
  8. Click "Create."

Get a External IP

  1. Obtain the external IP address of one of your nodes:

    kubectl get nodes --output wide
    

    Look for the "EXTERNAL-IP" column in the output.

In my case I saw various nodes there. For some reason using either of them works.

When calling that IP, use the Node Port you noted earlier, eg: curl -X GET "https://12.123.456.789:32112/"

Upvotes: 0

miguelfrancisco85
miguelfrancisco85

Reputation: 542

You can expose you service using other ways, if you do not have to much traffic maybe you don't need a load balancer here is one guide link

Using a NodePort you can use the public IP of one of your nodes, set this IP as static and config your DNS to point at this public IP.

Upvotes: 8

Randy L
Randy L

Reputation: 14746

This sounds like a better match for AppEngine than Kubernetes.

Upvotes: 0

Glenn Vandamme
Glenn Vandamme

Reputation: 1206

In theory you don't need a load balancer. If you work with nodeports you can connect to that port on the ip of any vm in your cluster. And kubernetes will still load balance internally to the right pod. However, you might have a hard time managing your DNS and firewall settings using this approach. Since I don't believe its possible to give static ip's to kubernetes nodes.

Upvotes: 2

Related Questions