What are some examples of LimitRange?

Here are some examples of LimitRange configurations in Kubernetes:

Example 1: Basic LimitRange

This example sets minimum and maximum CPU and memory limits for all pods in a namespace.

apiVersion: v1
kind: LimitRange
metadata:
  name: example-limitrange
spec:
  limits:
  - default:
      cpu: "1"
      memory: "1Gi"
    defaultRequest:
      cpu: "500m"
      memory: "512Mi"
    max:
      cpu: "2"
      memory: "2Gi"
    min:
      cpu: "200m"
      memory: "256Mi"
    type: Container

Example 2: LimitRange with Multiple Limits

This example defines different limits for different types of containers.

apiVersion: v1
kind: LimitRange
metadata:
  name: multi-limitrange
spec:
  limits:
  - type: Container
    max:
      cpu: "1"
      memory: "1Gi"
    min:
      cpu: "100m"
      memory: "256Mi"
  - type: Pod
    max:
      cpu: "4"
      memory: "4Gi"

Example 3: Default Limits Only

This example sets only default resource requests and limits without specifying min/max.

apiVersion: v1
kind: LimitRange
metadata:
  name: default-limits
spec:
  limits:
  - default:
      cpu: "500m"
      memory: "512Mi"
    type: Container

You can apply these YAML manifests to your Kubernetes cluster using the kubectl apply -f <filename>.yaml command. If you have any questions or need further examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!