From 3af3d6f09aa8e24caf6d4810184af4959e800be7 Mon Sep 17 00:00:00 2001 From: yurkov-anton <36742876+yurkov-anton@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:24:56 +0300 Subject: [PATCH] [ISSUE-572] ability to set mem/cpu for csi containers (#82) Signed-off-by: Anton Yurkov - Add `Resources *corev1.ResourceRequirements` to all components `api/v1/components` - Add follow tree to each csi component in csi-baremetal-deployment and value.yaml: ``` resources: requests: memory: cpu: limits: memory: cpu: ``` --- api/v1/components/controller.go | 3 + api/v1/components/drivemgr.go | 3 + api/v1/components/node.go | 3 + api/v1/components/node_controller.go | 3 + api/v1/components/patcher.go | 3 + api/v1/components/resources.go | 30 +++ api/v1/components/scheduler.go | 3 + api/v1/components/sidecar.go | 3 + .../templates/_helpers.tpl | 30 +++ .../csi-baremetal_v1_deployment.yaml | 28 ++- charts/csi-baremetal-deployment/values.yaml | 80 +++++++ .../csi-baremetal.dell.com_deployments.yaml | 200 ++++++++++++++++++ .../templates/manager.yaml | 9 +- charts/csi-baremetal-operator/values.yaml | 8 + pkg/common/common.go | 8 + pkg/controller.go | 4 + pkg/node/node_daemonset.go | 4 + pkg/node_controller.go | 8 +- pkg/patcher/patcher_configuration.go | 2 + pkg/patcher/scheduler_patcher_vanilla.go | 1 + pkg/scheduler_extender.go | 1 + 21 files changed, 423 insertions(+), 11 deletions(-) create mode 100644 api/v1/components/resources.go create mode 100644 charts/csi-baremetal-deployment/templates/_helpers.tpl diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 450116fb..1d7e66f5 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -21,4 +21,7 @@ type Controller struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index c347c9f0..fb0261df 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -20,4 +20,7 @@ package components type DriveMgr struct { Image *Image `json:"image,omitempty"` Endpoint string `json:"endpoint"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index 3b415c36..8cfb34a7 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -22,4 +22,7 @@ type Node struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index 91813e15..3e17cf3d 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -21,4 +21,7 @@ type NodeController struct { Enable bool `json:"enable"` Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index afdbe32f..3b61999e 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -24,4 +24,7 @@ type Patcher struct { RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` ConfigMapName string `json:"configMapName,omitempty"` ReadinessTimeout int `json:"readinessTimeout,omitempty"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/resources.go b/api/v1/components/resources.go new file mode 100644 index 00000000..4a98bd50 --- /dev/null +++ b/api/v1/components/resources.go @@ -0,0 +1,30 @@ +/* +Copyright © 2021 Dell Inc. or its subsidiaries. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package components + +import ( + corev1 "k8s.io/api/core/v1" +) + +// ResourceRequirements contain information for mem/cpu requirements +type ResourceRequirements struct { + // +nullable + // +optional + Limits corev1.ResourceList `json:"limits,omitempty"` + // +nullable + // +optional + Requests corev1.ResourceList `json:"requests,omitempty"` +} diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index f13d77ab..015b62bb 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -25,4 +25,7 @@ type Scheduler struct { Patcher *Patcher `json:"patcher,omitempty"` ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index dbdd0327..68a66557 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -19,4 +19,7 @@ package components // Sidecar represent CSI sidecar containers type Sidecar struct { Image *Image `json:"image,omitempty"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/charts/csi-baremetal-deployment/templates/_helpers.tpl b/charts/csi-baremetal-deployment/templates/_helpers.tpl new file mode 100644 index 00000000..9beae825 --- /dev/null +++ b/charts/csi-baremetal-deployment/templates/_helpers.tpl @@ -0,0 +1,30 @@ +{{- define "setResources" }} +{{- if .resources }} +{{- if or .resources.requests .resources.limits }} + +{{- $requestsValues := .resources.requests | values | compact }} +{{- $limitsValues := .resources.limits | values | compact }} + +{{- if $limitsValues }} +limits: + {{- if .resources.limits.memory }} + memory: {{ .resources.limits.memory }} + {{- end }} + {{- if .resources.limits.cpu }} + cpu: {{ .resources.limits.cpu }} + {{- end }} +{{- end }} + +{{- if $requestsValues }} +requests: + {{- if .resources.requests.memory }} + memory: {{ .resources.requests.memory }} + {{- end }} + {{- if .resources.requests.cpu }} + cpu: {{ .resources.requests.cpu }} + {{- end }} +{{- end }} + +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml index 5e2cc2da..d3b7eafc 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -24,31 +24,43 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} + resources: + {{- include "setResources" .Values.driver.controller | indent 8 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} sidecars: - livenessprobe: + livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} - csi-provisioner: + resources: + {{- include "setResources" .Values.driver.livenessProbe | indent 12 }} + csi-provisioner: image: name: csi-provisioner tag: {{ .Values.driver.provisioner.image.tag }} - csi-resizer: + resources: + {{- include "setResources" .Values.driver.provisioner | indent 12 }} + csi-resizer: image: name: csi-resizer tag: {{ .Values.driver.resizer.image.tag }} + resources: + {{- include "setResources" .Values.driver.resizer | indent 12 }} node: driveMgr: image: name: csi-baremetal-{{ .Values.driver.drivemgr.type }} tag: {{ .Values.driver.drivemgr.image.tag | default .Values.image.tag }} + resources: + {{- include "setResources" .Values.driver.drivemgr | indent 10 }} endpoint: {{ .Values.driver.drivemgr.grpc.server.endpoint }} image: name: csi-baremetal-node tag: {{ .Values.driver.node.image.tag | default .Values.image.tag }} + resources: + {{- include "setResources" .Values.driver.node | indent 8 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -57,10 +69,14 @@ spec: image: name: csi-node-driver-registrar tag: {{ .Values.driver.nodeDriverRegistrar.image.tag }} + resources: + {{- include "setResources" .Values.driver.nodeDriverRegistrar | indent 12 }} livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} + resources: + {{- include "setResources" .Values.driver.livenessProbe | indent 12 }} metrics: path: {{ .Values.driver.metrics.path }} port: {{ .Values.driver.metrics.port }} @@ -74,6 +90,8 @@ spec: image: name: csi-baremetal-scheduler-extender tag: {{ .Values.scheduler.image.tag | default .Values.image.tag }} + resources: + {{- include "setResources" .Values.scheduler | indent 6 }} log: format: {{ .Values.scheduler.log.format }} level: {{ .Values.scheduler.log.level }} @@ -86,6 +104,8 @@ spec: image: name: csi-baremetal-scheduler-patcher tag: {{ .Values.scheduler.patcher.image.tag | default .Values.image.tag }} + resources: + {{- include "setResources" .Values.scheduler.patcher | indent 8 }} interval: {{ .Values.scheduler.patcher.interval }} restoreOnShutdown: {{ .Values.scheduler.patcher.restore_on_shutdown }} configMapName: {{ .Values.scheduler.patcher.config_map_name }} @@ -96,6 +116,8 @@ spec: image: name: csi-baremetal-node-controller tag: {{ .Values.nodeController.image.tag | default .Values.image.tag }} + resources: + {{- include "setResources" .Values.nodeController | indent 6 }} log: format: {{ .Values.nodeController.log.format }} level: {{ .Values.nodeController.log.level }} diff --git a/charts/csi-baremetal-deployment/values.yaml b/charts/csi-baremetal-deployment/values.yaml index 47eccf75..6276aa00 100644 --- a/charts/csi-baremetal-deployment/values.yaml +++ b/charts/csi-baremetal-deployment/values.yaml @@ -36,9 +36,25 @@ driver: controller: image: tag: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + node: image: tag: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + drivemgr: type: basemgr image: @@ -49,20 +65,60 @@ driver: deployConfig: false amountOfLoopDevices: 3 sizeOfLoopDevices: 101Mi + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + # Sidecars parameters provisioner: image: # if you want to use topology feature (multiple PVCs per pod) you should use v1.2.2 tag: v1.6.0 + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + resizer: image: tag: v1.1.0 + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + nodeDriverRegistrar: image: tag: v1.3.0 + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + livenessProbe: image: tag: v2.1.0 + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + # Metrics endpoint metrics: path: /metrics @@ -93,6 +149,14 @@ scheduler: enable: true image: tag: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + # Logging settings log: format: text @@ -111,6 +175,14 @@ scheduler: enable: false image: tag: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + kubeconfig: /etc/kubernetes/scheduler.conf interval: 60 restore_on_shutdown: true @@ -126,6 +198,14 @@ nodeController: enable: true image: tag: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + # Logging settings log: format: text diff --git a/charts/csi-baremetal-operator/crds/csi-baremetal.dell.com_deployments.yaml b/charts/csi-baremetal-operator/crds/csi-baremetal.dell.com_deployments.yaml index 1fa8d585..f0896054 100644 --- a/charts/csi-baremetal-operator/crds/csi-baremetal.dell.com_deployments.yaml +++ b/charts/csi-baremetal-operator/crds/csi-baremetal.dell.com_deployments.yaml @@ -65,6 +65,31 @@ spec: - format - level type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object sidecars: additionalProperties: description: Sidecar represent CSI sidecar containers @@ -80,6 +105,31 @@ spec: - name - tag type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object type: object type: object type: object @@ -136,6 +186,31 @@ spec: - name - tag type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object required: - endpoint type: object @@ -163,6 +238,31 @@ spec: - format - level type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object sidecars: additionalProperties: description: Sidecar represent CSI sidecar containers @@ -178,6 +278,31 @@ spec: - name - tag type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object type: object type: object type: object @@ -214,6 +339,31 @@ spec: - format - level type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object required: - enable type: object @@ -309,11 +459,61 @@ spec: type: integer readinessTimeout: type: integer + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object restoreOnShutdown: type: boolean required: - enable type: object + resources: + description: ResourceRequirements contain information for mem/cpu requirements + nullable: true + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true + type: object + type: object storageProvisioner: type: string required: diff --git a/charts/csi-baremetal-operator/templates/manager.yaml b/charts/csi-baremetal-operator/templates/manager.yaml index 5a64d0cc..67e22a27 100644 --- a/charts/csi-baremetal-operator/templates/manager.yaml +++ b/charts/csi-baremetal-operator/templates/manager.yaml @@ -34,13 +34,12 @@ spec: name: manager imagePullPolicy: {{ .Values.image.pullPolicy }} resources: - # Memory limit is increased due to bug in OpenShift 4.6 - https://bugzilla.redhat.com/show_bug.cgi?id=1904558 limits: - cpu: 100m - memory: 200Mi + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} requests: - cpu: 100m - memory: 20Mi + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} volumeMounts: - mountPath: /crash-dump name: crash-dump diff --git a/charts/csi-baremetal-operator/values.yaml b/charts/csi-baremetal-operator/values.yaml index 99602643..8c97bd87 100644 --- a/charts/csi-baremetal-operator/values.yaml +++ b/charts/csi-baremetal-operator/values.yaml @@ -8,3 +8,11 @@ image: name: csi-baremetal-operator tag: green pullPolicy: Always + +resources: + limits: + cpu: 100m + memory: 200Mi + requests: + cpu: 100m + memory: 20Mi diff --git a/pkg/common/common.go b/pkg/common/common.go index 46796233..71e36b4f 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -158,3 +158,11 @@ func ConstructSelectorMap(appName string) map[string]string { constant.SelectorKey: appName, } } + +// ConstructResourceRequirements creates the ResourceRequirements contains Limits and Requests lists +func ConstructResourceRequirements(resources *components.ResourceRequirements) corev1.ResourceRequirements { + if resources != nil { + return corev1.ResourceRequirements(*resources) + } + return corev1.ResourceRequirements{} +} diff --git a/pkg/controller.go b/pkg/controller.go index 0236b582..015b6558 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,6 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(c.Resources), }, { Name: constant.ProvisionerName, @@ -205,6 +206,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(provisioner.Resources), }, { Name: constant.ResizerName, @@ -225,6 +227,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(resizer.Resources), }, { Name: constant.LivenessProbeName, @@ -240,6 +243,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(liveness.Resources), }, } } diff --git a/pkg/node/node_daemonset.go b/pkg/node/node_daemonset.go index 6e271bb5..0e2d1c1e 100644 --- a/pkg/node/node_daemonset.go +++ b/pkg/node/node_daemonset.go @@ -204,6 +204,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(lp.Resources), }, { Name: constant.DriverRegistrarName, @@ -227,6 +228,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(dr.Resources), }, { Name: "node", @@ -285,6 +287,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: nodeMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(node.Resources), }, { Name: "drivemgr", @@ -301,6 +304,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: driveMgrMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(driveMgr.Resources), }, } } diff --git a/pkg/node_controller.go b/pkg/node_controller.go index f4da5a96..0818679b 100644 --- a/pkg/node_controller.go +++ b/pkg/node_controller.go @@ -85,9 +85,10 @@ func createNodeControllerDeployment(csi *csibaremetalv1.Deployment) *v1.Deployme func createNodeControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Container { var ( - image = csi.Spec.NodeController.Image - log = csi.Spec.NodeController.Log - ns = csi.Spec.NodeSelector + image = csi.Spec.NodeController.Image + log = csi.Spec.NodeController.Log + resources = csi.Spec.NodeController.Resources + ns = csi.Spec.NodeSelector ) args := []string{ @@ -113,6 +114,7 @@ func createNodeControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Con TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: []corev1.VolumeMount{constant.CrashMountVolume}, + Resources: common.ConstructResourceRequirements(resources), }, } } diff --git a/pkg/patcher/patcher_configuration.go b/pkg/patcher/patcher_configuration.go index e772504d..4a49751b 100644 --- a/pkg/patcher/patcher_configuration.go +++ b/pkg/patcher/patcher_configuration.go @@ -64,6 +64,7 @@ func newPatcherConfiguration(csi *csibaremetalv1.Deployment) (*patcherConfigurat config.pullPolicy = csi.Spec.PullPolicy config.loglevel = csi.Spec.Scheduler.Log.Level config.configFolder = configurationPath + config.resources = csi.Spec.Scheduler.Patcher.Resources return &config, nil } @@ -76,6 +77,7 @@ type patcherConfiguration struct { loglevel components.Level interval int restoreOnShutdown bool + resources *components.ResourceRequirements platform string targetConfig string diff --git a/pkg/patcher/scheduler_patcher_vanilla.go b/pkg/patcher/scheduler_patcher_vanilla.go index bc1d7f76..02e8718b 100644 --- a/pkg/patcher/scheduler_patcher_vanilla.go +++ b/pkg/patcher/scheduler_patcher_vanilla.go @@ -243,6 +243,7 @@ func (p patcherConfiguration) createPatcherContainers() []corev1.Container { }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: common.ConstructResourceRequirements(p.resources), }, } } diff --git a/pkg/scheduler_extender.go b/pkg/scheduler_extender.go index a4a31b9e..6b22f01c 100644 --- a/pkg/scheduler_extender.go +++ b/pkg/scheduler_extender.go @@ -176,6 +176,7 @@ func createExtenderContainers(csi *csibaremetalv1.Deployment, isPatchingEnabled TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: volumeMounts, + Resources: common.ConstructResourceRequirements(csi.Spec.Scheduler.Resources), }, } }