Search code examples
kuberneteskubectlkubernetes-pod

Is there flag to specify memory limit for kubernetes pods using kubectl run?


I'm trying to create a pod and pass in memory limit without creating a yaml file. Or is there a way to modify the memory limit on a pod which is already running?


Solution

  • I can't really think of a way of how to enforce a limit of memory from kubectl run but it can be enforced by applying the resource below.

    apiVersion: v1
    kind: LimitRange
    metadata:
      name: mem-limit-range
    spec:
      limits:
      - default:
          memory: 512Mi
        defaultRequest:
          memory: 256Mi
        type: Container