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#
Tip
You can find examples of resource limits in the Kubernetes documentation.
The code fragment below limits the Django container to the following.
CPU: 250m (250 milli-cpus or 0.25 of a CPU)
Memory: 512Mi (255 Mebi-bytes \(256 * 2^{20}\) bytes)
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:
resources:
requests:
cpu: 250m
memory: 512Mi
ephemeral-storage: 10Mi
limits:
cpu: 250m
memory: 512Mi
ephemeral-storage: 10Mi
Environment Variables#
Tip
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:
env:
- name: STUDENT_NAME
value: "Your Name Here"
- name: SITE_NAME
value: "*"
Note
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.