Kubernetes Guestbook vagrant frontend service EXTERNAL_IP issue

12/18/2015

Could someone explain how to setup the external Ip on the 'frontend' service. I know that Vagrant don't support "type: LoadBalancer" and I don't know how to expose an Ip to my host. Thanks

-- Brett
kubernetes
vagrant

2 Answers

2/2/2016

Try type "NodePort" instead:

https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/services.md#type-nodeport

Then use the IP address(es) of your vagrant VM(s) at the allocated port.

-- briangrant
Source: StackOverflow

3/10/2016

First of all you should change your service type in the guestbook service definition:

diff --git a/guestbook-service.json b/guestbook-service.json
index cc7640e..fadef78 100644
--- a/guestbook-service.json
+++ b/guestbook-service.json
@@ -17,6 +17,6 @@
       "selector":{
          "app":"guestbook"
       },
-      "type": "LoadBalancer"
+      "type": "NodePort"
    }
 }

Then stop and restart the service with:

kubectl delete -f guestbook-service.json
kubectl create -f guestbook-service.json

Look at your node IP address with:

kubectl get nodes

For example, for me this was the result:

$ kubectl get nodes
NAME          LABELS                               STATUS    AGE
172.17.4.99   kubernetes.io/hostname=172.17.4.99   Ready     3h

Finally, you can find out your service nodeport with:

kubectl describe services guestbook

For example, for me this was the result:

$ kubectl describe services guestbook
Name:           guestbook
Namespace:      default
Labels:         app=guestbook
Selector:       app=guestbook
Type:           NodePort
IP:         10.3.0.47
Port:           <unnamed>   3000/TCP
NodePort:       <unnamed>   32757/TCP
Endpoints:      10.2.76.12:3000,10.2.76.8:3000,10.2.76.9:3000
Session Affinity:   None
No events.

At this point, using the node IP you got earlier, and the NodePort you just found, you should be able to connect:

$ curl 172.17.4.99:32757
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <meta charset="utf-8">
    <meta content="width=device-width" name="viewport">
    <link href="/style.css" rel="stylesheet">
    <title>Guestbook</title>
[...]

Note: the NodePort is usually allocated from a flag-configured range, by default it is 30000-32767.

-- bta
Source: StackOverflow