增加 运行 个 pod 的内存限制
Increase memory limit of a running pod
我在 openshift 3.11 中有一个 pod 运行,我希望将 pod 内存限制从 2GB 增加到 4GB。如何通过 Openshift Web 控制台或通过 OC 命令行执行此操作?
当我尝试在 Openshift Web 控制台中编辑 yaml 文件时,出现以下异常
Reason: Pod "hjaha" is invalid: spec: Forbidden: pod updates may not
change fields other than spec.containers[*].image
,
spec.initContainers[*].image
, spec.activeDeadlineSeconds
or
spec.tolerations
(only additions to existing tolerations)...
您必须编辑 yaml 文件并在您的容器部分下添加此 resources
部分
containers:
- image: nginx
imagePullPolicy: Always
name: default-mem-demo-ctr
resources:
limits:
memory: 4Gi #<--------------This is limit
requests:
memory: 2Gi #<--------------Your applictaion will use memory in between 2Gb to upto 4GB
基本上Pods都是使用Pods的controller的容器模板部署的,比如DeploymentConfig、Deployment、DaemonSet、StatefulSet等等。首先,您应该验证您的 Pod 部署使用了哪个控制器,并修改控制器 yaml 上的资源部分,而不是 运行 Pod yaml。看下面的例子,如果你使用 oc CLI 或 web console 修改 deployment controller yaml 的内存限制,那么它会在之后使用新的配置部署新的 pod。
// List some deployment controller resources as follows.
// Then you can see one which is similar name with running pod name.
$ oc get deploymentconfig,deployment,statefulset,daemonset -n <your project name>
$ oc edit <deployment controller type> <the resource name>
:
kind: <deployment controller type>
metadata:
name: <the resource name>
spec:
:
template:
:
spec:
containers:
- name: <the container name>
resources:
limits:
// modify the memory size from 2Gi to 4Gi.
memory: 4Gi
我在 openshift 3.11 中有一个 pod 运行,我希望将 pod 内存限制从 2GB 增加到 4GB。如何通过 Openshift Web 控制台或通过 OC 命令行执行此操作?
当我尝试在 Openshift Web 控制台中编辑 yaml 文件时,出现以下异常
Reason: Pod "hjaha" is invalid: spec: Forbidden: pod updates may not change fields other than
spec.containers[*].image
,spec.initContainers[*].image
,spec.activeDeadlineSeconds
orspec.tolerations
(only additions to existing tolerations)...
您必须编辑 yaml 文件并在您的容器部分下添加此 resources
部分
containers:
- image: nginx
imagePullPolicy: Always
name: default-mem-demo-ctr
resources:
limits:
memory: 4Gi #<--------------This is limit
requests:
memory: 2Gi #<--------------Your applictaion will use memory in between 2Gb to upto 4GB
基本上Pods都是使用Pods的controller的容器模板部署的,比如DeploymentConfig、Deployment、DaemonSet、StatefulSet等等。首先,您应该验证您的 Pod 部署使用了哪个控制器,并修改控制器 yaml 上的资源部分,而不是 运行 Pod yaml。看下面的例子,如果你使用 oc CLI 或 web console 修改 deployment controller yaml 的内存限制,那么它会在之后使用新的配置部署新的 pod。
// List some deployment controller resources as follows.
// Then you can see one which is similar name with running pod name.
$ oc get deploymentconfig,deployment,statefulset,daemonset -n <your project name>
$ oc edit <deployment controller type> <the resource name>
:
kind: <deployment controller type>
metadata:
name: <the resource name>
spec:
:
template:
:
spec:
containers:
- name: <the container name>
resources:
limits:
// modify the memory size from 2Gi to 4Gi.
memory: 4Gi