5.10.3. 手动为节点分配资源
OpenShift Container Platform 支持对 CPU 和内存资源类型执行分配。ephemeral-resource 资源类型也被支持。对于 cpu 类型,资源数量以内核数为单位来指定,例如 200m、0.5 或 1。对于 memory 和 ephemeral-storage,则以字节数为单位来指定,例如 200Ki、50Mi 或 5Gi。默认情况下,system-reserved CPU 为 500m,system-reserved 内存为 1Gi。
作为管理员,您可以通过一组 <resource_type>=<resource_quantity> 对(如 cpu=200m,memory=512Mi)来利用自定义资源 (CR) 进行设置。
有关推荐的 system-reserved 值的详情,请参考推荐的 system-reserved 值。
先决条件
输入以下命令为您要配置的节点类型获取与静态
MachineConfigPoolCRD 关联的标签:$ oc edit machineconfigpool <name>例如:
$ oc edit machineconfigpool worker输出示例
apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfigPool metadata: creationTimestamp: "2022-11-16T15:34:25Z" generation: 4 labels: pools.operator.machineconfiguration.openshift.io/worker: ""1 name: worker- 1
- 标签会出现在 Labels 下。
提示如果标签不存在,请添加键/值对,例如:
$ oc label machineconfigpool worker custom-kubelet=small-pods
流程
为配置更改创建自定义资源 (CR)。
资源分配 CR 的示例配置
apiVersion: machineconfiguration.openshift.io/v1 kind: KubeletConfig metadata: name: set-allocatable1 spec: machineConfigPoolSelector: matchLabels: pools.operator.machineconfiguration.openshift.io/worker: ""2 kubeletConfig: systemReserved:3 cpu: 1000m memory: 1Gi运行以下命令来创建 CR:
$ oc create -f <file_name>.yaml