增加正在运行的 pod 的内存限制

wil*_*007 2 openshift kubernetes openshift-3

我有一个在 openshift 3.11 中运行的 pod,我希望将 pod 内存限制从 2GB 增加到 4GB。如何通过 Openshift Web Console 或 OC 命令行执行此操作?

当我尝试在 Openshift Web Console 中编辑 yaml 文件时,出现以下异常

原因:Pod“hjaha”无效:规范:禁止:Pod 更新不得更改除spec.containers[*].imagespec.initContainers[*].imagespec.activeDeadlineSeconds或 以外 的字段spec.tolerations(仅对现有容忍度进行添加)...

Dae*_*ark 5

基本上 Pod 是使用 Pod 控制器的容器模板来部署的,例如 DeploymentConfig、Deployment、DaemonSet、StatefulSet 等。首先,您应该验证您的 Pod 部署使用什么控制器,并修改控制器 yaml 上的资源部分,而不是运行 Pod yaml。看下面的示例,如果您使用 oc CLI 或 Web 控制台修改部署控制器 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
Run Code Online (Sandbox Code Playgroud)