10

I'm deploying a Kubernetes cluster on GCE using Gitlab-CI. I'd like to keep the cost to a minimum - here's my current setup:

  • Nodes run on 3 f1-micro instances
  • A system pod running Traefik configured with ServiceType LoadBalancer
  • Wildcard dns configured
  • 1 postgres pod
  • 1 web server pod with ingress configured for Traefik

I would like to reduce the cost of my deployment. Most of the cost resides with the GCE load balancer. Is there a way I can use a public IP address instead of a Load Balancer on GCE? If so, can I utilise the IP address allocated to the cluster (instead of reserving a static IP)?

To put it another way, is there a way to tie an ephemeral ip to a Kubernetes service using GCE without a load balancer?

Is there any other configuration I can do differently that will reduce cost in general on GCE?

  • 1
    You can expose your service by only using NodePort service type, but that will introduce some limitations to your deployment. For more informatio visit this link. – Kamran Aug 12 '17 at 0:45
10

Yes, via ExternalIPs. Be aware that this will mean your service will go down if the node that has said external IP assigned fails, but if you're only running 1 master you probably don't care much about that.

Example service:

apiVersion: v1
kind: Service
metadata:
  name: myapp
spec:
  ports:
    - port: 80
      protocol: TCP
  selector:
    app: myapp
  externalIPs:
    - a.b.c.d

The IP need to be the internal IP of the GCE instance (This is because GCE DNATs the traffic to the internal IPs). The service should then be accessible via the node's assigned external IP.

You will probably want to change the service for your ingress controller, so that you can route all of your apps through one IP.

  • 2
    After learning about the DNAT thing, I realised that I needed to configure a firewall rule to allow traffic on certain ports to the GCE instance. After this I was able to successfully implement your suggestion. I've also successfully tested a NodePort version too – Mitkins Sep 8 '17 at 13:50
2

I prefer not to use the cloud load balancers, until necessary, because of cost and vendor lock-in.

Instead I use this: https://kubernetes.github.io/ingress-nginx/deploy/

It's a pod that runs a load balancer for you. That page has GKE specific installation notes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.