Will a cluster work automatically on balancing resources?

8/15/2017

I have created a Kubernetes cluster of 2 nodes and one master on CentOS 7. When I use kubectl get nodes, it lists the nodes and everything seems to be working.

My question is: Will the cluster automatically balance the resources now between the nodes? I mean, let's say I installed a nginx web server with WordPress on the master node (which has 512MB of memory), if the memory usage is almost full on the master, will it automatically now depend on the nodes according to its needs? Or should I do something manual?

And does it also balance the CPU load between the nodes?

-- Madno
cluster-computing
kubernetes
nginx
wordpress

2 Answers

8/15/2017

Kubernetes won’t balance the node resources. It will schedule the workload based on available resource in the node. In your case if memory is full on master node, if you want to run another pod kubernetes will schedule them in second node.

-- sfgroups
Source: StackOverflow

8/16/2017

The key point that sfgroups mentioned is that a pod cannot be split between nodes, so there is no "balancing of resources" when resources are exhausted on a node. Your process running in the pod will be OOM killed by the kernel if it hits its memory cgroup limit, and it will be throttled if it hits its CPU cgroup limit.

You need pods that fit onto your nodes with room to spare for the daemons that run on every node (kubelet and kube-proxy).

The only automatic things that kubernetes does (related to your question) are: 1) scheduling pods on nodes where they fit, 2) autoscaling pods (when running a horizontal pod autoscaler), and 3) autoscaling nodes (when running a cluster autoscaler). You might also be interested in the behavior of the replicaset and deployment, which control the number of pods that are present in the cluster for a specific application.

-- nckturner
Source: StackOverflow