Exposing containers without a load balancer

8/3/2017

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!

-- jonlambert
docker
google-kubernetes-engine
kubernetes

2 Answers

8/12/2017

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

-- JonPulsifer
Source: StackOverflow

8/3/2017

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

-- Tarun Lalwani
Source: StackOverflow