简体   繁体   中英

how to modify pod memory limit of a running pod

I am using YML to create pod and have specified the resource request and limit. Now I am not aware of how to modify the resource limits of a running pod. For example

memory-demo.yml

apiVersion: v1
kind: Pod
metadata:
  name: memory-demo
  namespace: mem-example
spec:
  containers:
  - name: memory-demo-ctr
    image: polinux/stress
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"
    command: ["stress"]
    args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]

Then I run the command oc create -f memory-demo.yml and a pod name memory-demo get created.

My Question is what should I do to modify the memory limits from 200Mi --> 600 Mi , Do I need to delete the existing pod and recreate the pod using the modified YML file?

I am a total newbie. Need help.

First and for most, it is very unlikely that you really want to be (re)creating Pods directly. Dig into what Deployment is and how it works. Then you can simply apply the change to the spec template in deployment and kubernetes will upgrade all the pods in that deployment to match new spec in a hands free rolling update.

Live change of the memory limit for a running container is certainly possible but not by means of kubernetes (and will not be reflected in kube state if you do so). Look at docker update .

You can use replace command to modify an existing object based on the contents of the specified configuration file ( documentation )

oc replace -f memory-demo.yml

EDIT: However, some spec can not be update. The only way is delete and re-create the pod.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM