Settings Memory and CPU for container

The Brown BoxThe Brown Box
1 min read

Desc:

  • Basic setting for memory and CPU in container

  • How basic knowledge is very important

Measurement Unit

The most important thing is that we have to know the unit of each one:

  • CPU: is measure by CPU unit

  • Memory: Mebibyte, Gibibyte,...

How to setting them

With CPU:

  • It's a float: cpu: "0.5" or cpu: "1"

  • "0.5" can represent like "500m"

With Memory:

  • Mebibyte: Mi

  • Gibibyte: Gi

apiVersion: v1
kind: Pod
metadata:
  name: example-pod
spec:
  containers:
  - name: example-container
    image: example-image
    resources:
      requests:
        memory: "512Mi"  # Memory request
        cpu: "250m"      # CPU request (0.25 CPU units)
      limits:
        memory: "1Gi"    # Memory limit
        cpu: "500m"      # CPU limit (0.5 CPU units)
    ports:
    - containerPort: 8080  # Specify your socket's port here

What is important here

I spend so much time on how to setting them just because of misunderstood the measurement unit and setting them incorrectly.

0
Subscribe to my newsletter

Read articles from The Brown Box directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

The Brown Box
The Brown Box