2

I'm new in Kubernetes and there are some doubts I have. I have setup a Kubernetes cluster that consists of one master/node and one node. I have deployed a very simple NodeJS-based app, using Deployment kind with 2 replicas. Then, I have exposed it as a service by kubectl expose deployment my-app --port=80.

Now, my services looks like:

root@sw-kubernetes01:~# kubectl get services
NAME             CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE
my-app           192.168.100.167   <none>        80/TCP    10m
kubernetes       192.168.100.1     <none>        443/TCP   1h

Is it supposed that I should access to my app navigating to http://192.168.100.167:? I'm getting a timeout error. Otherwise, how can I get the external IP to access to the service externally?

I know that if I declare the service as type: NodePort, I can access my app using nodes IP, doesn't exist a way to auto-balance the load between pods?

1

If you are working on local cluster you could use the --type=NodePort

kubectl expose deployment my-app --port=80 --type=NodePort

and then grep for the port

kubectl get svc my-service -o yaml | grep nodePort

and you could browse that using the cluster ip and the port which is output from the previous grep result.

  • This actually solved my problem some days ago. Thanks :) – Héctor May 18 '16 at 15:35
1

If you're running on GCE, EC2, or OpenStack, it typically takes a minute or two for a load balancer to be created and for the EXTERNAL_IP field to get populated. The IP in that field is the one you should use to access your service.

If you aren't running on GCE, EC2, or OpenStack, the external load balancer feature isn't going to work for you, since Kubernetes won't know how to create one in your environment.

  • Thanks. I have setup an external nginx in my cluster and it is working now – Héctor Apr 28 '16 at 6:33
0

As already suggested in the question, you can access the NodePort service using the port provided by

kubectl get svc my-service -o yaml | grep nodePort

and any of the public node IPs. These requests however don't need to end up on the node with the IP you used for the request. Actually, these requests get routed within the cluster to any of the pods associated with the service. So there is some load balancing present here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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