We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Limits - RAM

We've successfully throttled the CPU usage of our testcpu pod, but what about RAM?

Create a new file called testram-deployment.yaml with the following:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: synergychat-testram
  name: synergychat-testram
spec:
  replicas: 1
  selector:
    matchLabels:
      app: synergychat-testram
  template:
    metadata:
      labels:
        app: synergychat-testram
    spec:
      containers:
        - image: bootdotdev/synergychat-testram:latest
          name: synergychat-testram

Add a memory limit of 256Mi (256 Megabytes) to the deployment. Remember, this is the syntax to do so:

spec:
  containers:
    - name: <container-name>
      image: <image-name>
      resources:
        limits:
          memory: <max-memory>
          cpu: <max-cpu>

Additionally, create a ConfigMap called testram-configmap.yaml with the name "synergychat-testram-configmap" for this deployment that specifies a single environment variable:

  • MEGABYTES: "200"

That will tell the application to allocate 200 megabytes of memory. Update the deployment to use the config map, then apply both.

Make sure the pod is healthy:

kubectl get pods

After a minute or so, you should be able to see the memory usage of the pod:

kubectl top pods

The memory usage should be a little over 200 megabytes, but not more than 256 megabytes.