Creating a multi node Kubernetes Cluster for a stateless webapp

7/21/2015

I'm trying to understand a good way to handle Kubernetes cluster where there are several nodes and a master. I host the cluster within the cloud of my company, plain Ubuntu boxes (so no Google Cloud or AWS).

Each pod contains the webapp (which is stateless) and I run any number of pods via replication controllers.

I see that with Services, I can declare PublicIPs however this is confusing because after adding ip addresses of my minion nodes, each ip only exposes the pod that it runs and it doesn't do any sort of load balancing. Due to this, if a node doesn't have any active pod running (as created pods are random allocated among nodes), it simply timeouts and I end up some IP addresses that don't response. Am I understanding this wrong?

How can I truly do a proper external load balancing for my web app? Should I do load balancing on Pod level instead of using Service? If so, pods are considered mortal and they may dynamically die and born, how I do track of this?

-- Jason P
cluster-computing
docker
kubernetes

1 Answer

7/21/2015

The PublicIP thing is changing lately and I don't know exactly where it landed. But, services are the ip address and port that you reference in your applications. In other words, if I create a database, I create it as a pod (with or without a replication controller). I don't connect to the pod, however, from another application. I connect to a service which knows about the pod (via a label selector). This is important for a number of reasons.

  1. If the database fails and is recreated on a different host, the application accessing it still references the (stationary) service ip address, and the kubernetes proxies take care of getting the request to the correct pod.
  2. The service address is known by all Kubernetes nodes. Any node can proxy the request appropriately.

I think a variation of the theme applies to your problem. You might consider creating an external load balancer which forwards traffic to all of your nodes for the specific (web) service. You still need to take the node out of the balancer's targets if the node goes down, but, I think that any node will forward the traffic for any service whether or not that service is on that node.

All that said, I haven't had direct experience with external (public) ip addresses load balancing to the cluster, so there are probably better techniques. The main point I was trying to make is the node will proxy the request to the appropriate pod whether or not that node has a pod.

-g

-- Greg
Source: StackOverflow