Difficulty: Beginner
Estimated Time: 10 - 15 minutes

This scenario demonstrates the Predictable Demands pattern from Kubernetes Patterns.

This pattern is about how you should declare application requirements, whether they are hard runtime dependencies or resource requirements. Declaring your requirements is essential for Kubernetes to find the right place for your application within the cluster.

After this scenario you know

  • how to detect that a hard runtime requirement like a ConfigMap is missing
  • how define resources limits for CPU and Memory
  • what happens when these limits are selected too low

In this scenario you learned about two ways how you can communicate application requirements to Kubernetes:

  • By specifying your runtime dependencies like a ConfigMap reference. Another example would be the dependency on a PersistentVolume (which we do not have shown here)
  • By setting CPU and Memory requests and limits.

Much more information for this and other patterns can be found in the Kubernetes Patterns book. Also don't forget to check out the examples at the books' example GitHub repository.

Predictable Demands

Step 1 of 5

Create a Pod with runtime requirements

While you are reading this we are starting a simple single node Kubernetes cluster for you. Please be patient and wait until the launch.sh script has finished.

Let's create a simple Pod which references a non-existing ConfigMap random-generator-config. The Pod itself is a simple REST service which just returns a freshly generated random number each time it is called.

In pod.yml you find the definition of a bare Pod which references a ConfigMap for being used as environment variables.

Check the content of this declaration with

bat pod.yml

Let's create now that Pod with

kubectl create -f pod.yml

and watch how it starts up:

kubectl get pods -w

(you can stop this with CTRL-C). Eventually you will see how the Pod goes into the status CreateContainerConfigError.

This is also reported with

kubectl describe pod random-generator

As you can see, that Pod won't start because the hard runtime requirement of a ConfigMap is missing.

In the next step we will add this missing requirement.