Sobes.tech
Middle

How to calculate the size of a node in cubes?

sobes.tech AI

Answer from AI

The size of a node in Kubernetes is determined not by a single parameter, but by the total resources it provides for running pods. The main resources to consider when calculating the size of a node:

  • CPU: Measured in "cores". 1000m (millicores) is equivalent to 1 core.
  • RAM: Measured in bytes (most often in gigabytes or terabytes).
  • System resources for kubelet, operating system, and other system processes: Require reservation of CPU and RAM.
  • Resources for pods: This is the main part of the node's resources, which are distributed among the pods.

For calculation, consider:

  1. Application requirements: Determine how much CPU and RAM each application pod needs.
  2. Expected load: Consider peak load and scaling of applications.
  3. Overhead: Reserve resources for system processes and kubelet.
  4. Planned number of pods per node: Assess pod density.

Example calculation:

Suppose we need nodes to host pods with the following requirements:

  • Pods of type A: 500m CPU, 1Gi RAM
  • Pods of type B: 250m CPU, 512Mi RAM

Plan to place 10 pods of type A and 20 pods of type B on a node.

Total resource requirements for pods:

  • CPU: (10 * 500m) + (20 * 250m) = 5000m + 5000m = 10000m = 10 cores
  • RAM: (10 * 1Gi) + (20 * 512Mi) = 10Gi + 10Gi = 20Gi

Add overhead for system processes (e.g., 10% of total pod consumption):

  • CPU overhead: 10 * 10% = 1 core
  • RAM overhead: 20Gi * 10% = 2Gi

Final minimum node requirements:

  • CPU: 10 cores + 1 core (overhead) = 11 cores
  • RAM: 20Gi + 2Gi (overhead) = 22Gi

To ensure stable operation and scalability, it is recommended to have some resource buffer. For example, add another 10-20% to the calculated requirements.

Thus, for this example, a node would require at least 11-13 cores of CPU and 22-26Gi RAM.

The calculation may vary depending on the specifics of applications, technologies used, and SLA requirements. Monitoring tools (e.g., Prometheus + Grafana) play an important role in collecting telemetry and refining resource requirements.

It is also important to consider resource limits and requests in pod specifications (resources.limits and resources.requests) - they influence planning and resource allocation by the Kubernetes scheduler.