The Predictable Demands pattern is about declaring application requirements, whether they are resource requirements or hard runtime dependencies. Declaring resources is core for Kubernetes and enables correct placement in the cluster.

How do we understand demands

Estimating the sizing of resources for a container to function optimally has many inputs and understanding the true resourcing requirements for an application is normally discovered through testing. Some services have stable CPU and memory needs, and some change due to user load. Some services require persistent storage to store data and may have specific networking requirements.

Defining these application resources so the managing platform can make the correct placement decision is a prerequisite for a healthy and well functioning system.

Patterns to address dependencies and resources

Understanding the runtime requirements for a container is important for two main reasons.

  • First, with all the runtime dependencies defined and potential resource demands planned for, Kubernetes can make intelligent decisions for where to place a container on the cluster for most stable and efficient hardware utilisation. In an environment with shared resources among a large number of processes with different priorities, the only way for a successful coexistence is to know the demands of every process in advance. However, intelligent placement is only one side of the coin.
  • The second reason container resource profiles are essential is capacity planning. Based on the particular service demands and the total number of services, we can do some capacity planning for the different environments and come up with the most cost-effective host profiles to satisfy the entire cluster demand. Service resource profiles and capacity planning go hand-to-hand for successful cluster management in the long term.

Runtime Dependencies

File Storage  – One of the most common runtime dependencies is file storage for saving application state. Container filesystems are ephemeral and lost when a container is shut down. Kubernetes offers volume as a Pod-level storage utility that survives container restarts.
ConfigMaps – Configurations are another form of dependency. Most applications need some configuration information, and the standard solution is to use ConfigMaps.
Secrets – Similar to ConfigMaps are Secrets, offering a more secure way of distributing sensitive configurations to a container.

Resource Profiles

Compute resources in the context of Kubernetes are defined as something that can be requested by, allocated to, and consumed from a container. The resources are also categorised as;

  • compressible (can be throttled, such as CPU, or network bandwidth) 
  • incompressible (cannot be throttled, such as memory)

Understanding compressible and incompressible resources are necessary because if your containers consume too many compressible resources such as CPU, they get throttled. However, if containers use too many incompressible resources (such as memory), an Out of memory (OOM) is created the container is killed (as its the job of the Linux ‘oom killer’ to sacrifice one or more processes to free up memory for the system when all else fails). 

A containers definition can specify the amount of CPU and memory it needs in the form of a request and limit. By specifying the minimum amount of resources that are needed (called requests) and the maximum amount, it can grow up to (the limits) we can control the behaviour and the desired outcome. 

0
0

Jump to Section