8.1. Configure Pods#

In this lab you will build on the pod definition from the last lab by adding a resource definition. Every pod should ask for the resources it needs to ensure the Kubernetes scheduler works properly.

Resource Limits#


You can find examples of resource limits in the Kubernetes documentation.

The code fragment below limits the Django container to the following.

  1. CPU: 250m (250 milli-cpus or 0.25 of a CPU)

  2. Memory: 512Mi (255 Mebi-bytes \(256 * 2^{20}\) bytes)

  3. Storage: 10Mi (10 Mebi-bytes of disk sapce \(10 * 2^{20}\) byts)

Add this to the container definition in deployment/pod.yaml inside of the container spec.containers[0] key:

    cpu: 250m 
    memory: 512Mi
    ephemeral-storage: 10Mi
    cpu: 250m 
    memory: 512Mi
    ephemeral-storage: 10Mi

Environment Variables#


You can find examples of environment variables in the Kubernetes documentation.

If you want to set environment variables you can do that in the spec.containers[0] too:

  value: "Your Name Here"
- name: SITE_NAME
  value: "*"


Setting the SITE_NAME to "*" makes Django happy to run on any random IP address. You will fix this when you have a real DNS name.