简体   繁体   中英

How to add memory resources to the running pods in kubernetes

I have created 2 replicas of pods using the deployment declarative method in kubernetes by using the following command

$ kubectl create -f app-deployment.yaml

It created 2 pods of my java web application in one of the node. I want to specify memory resources for those pods. I know that we can specify memory resources to the pods by running the below script.

apiVersion: v1
kind: Pod
metadata:
  name: app1
spec:
  containers:
  - image: app:v1
    name: app1
    resources:
      limits:
        memory: 300Mi
      requests:
        memory: 200Mi
    ports:
    - containerPort: 8080
      hostPort: 8082

When i run the above script, a new pod with the name app1 gets created with the memory specified.

But how do i specify the memory resources for the pods created using the deployment script which i ran initially ?

Any help on this would be appreciable.

Specify the same spec in the containers section of your deployment.yaml . The pods will get restarted with the new resource limits.

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