Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose a Kubernetes service externally using NodePort

Tags:

kubernetes

I run the CoreOS k8s cluster on Mac OSX, which means it's running inside VirtualBox + Vagrant

I have in my service.yaml file:

spec:
  type: NodePort

When I type:

kubectl get services

I see:

NAME             CLUSTER_IP       EXTERNAL_IP   PORT(S)    SELECTOR                                
kubernetes       10.100.0.1       <none>        443/TCP    <none>                             
my-frontend      10.100.250.90    nodes         8000/TCP   name=my-app

What is the "nodes" external IP? How do I access my-frontend externally?

like image 626
Pyramid Newbie Avatar asked Nov 28 '15 10:11

Pyramid Newbie


1 Answers

In addition to "NodePort" types of services there are some additional ways to be able to interact with kubernetes services from outside of cluster:

  • Use service type "LoadBalancer". It works only for some cloud providers and will not work for virtualbox, but I think it will be good to know about that feature. Link to the documentation
  • Use one of the latest features called "ingress". Here is description from manual "An Ingress is a collection of rules that allow inbound connections to reach the cluster services. It can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.". Link to the documentation
  • If kubernetes is not strict requirements and you can switch to latest openshift origin (which is "kubernetes on steroids") you can use origin feature called "router".
    • Information about openshift origin.
    • Information about openshift origin routes
like image 151
Vyacheslav Enis Avatar answered Oct 26 '22 20:10

Vyacheslav Enis