jonlambert
jonlambert

Reputation: 432

Exposing containers without a load balancer

I'm aiming to deploy a small test application to GCE. Every guide I've read seems to point to using a LoadBalancer service to expose the pod to the internet. Unfortunately, this comes with a high associated cost and I'd like to be able to expose the containers without creating a load balancer (or using HAProxy / nginx to roll our own).

Is it possible to do so? If so, what are the steps I need to take and possible other associated costs?

Thanks!

Upvotes: 0

Views: 78

Answers (2)

JonPulsifer
JonPulsifer

Reputation: 26

The NGINX ingress controller found at https://github.com/kubernetes/ingress/tree/master/controllers/nginx should satisfy your cost saving requirement. I would not consider this "rolling your own" as this lives beside the GLBC ingress controller.

There should be sufficient documentation to satisfy your installation requirements and if there's not please open an issue on https://github.com/kubernetes/ingress

Upvotes: 1

Tarun Lalwani
Tarun Lalwani

Reputation: 146510

You can do that by choosing a NodePort as the service type.

apiVersion: v1
kind: Service
metadata: 
  name: myapp-servoce
  labels: 
    name: myapp
    context: mycontext
spec: 
  type: NodePort
  ports:
    # the port that this service should serve on
    - port: 8080
  # label keys and values that must match in order to receive traffic for this service
  selector: 
    name: myapp
    context: mycontext

This would expose that service on port 8080 of each node of the cluster. Now all of your nodes would have externally accessible IP address and you can use the same for testing

Upvotes: 1

Related Questions