Skip to content

Commit

Permalink
[ISSUE-572] ability to set mem/cpu for csi containers (#82)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Yurkov <[email protected]>

- 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:
```
  • Loading branch information
yurkov-anton authored Nov 1, 2021
1 parent 5b71659 commit 3af3d6f
Show file tree
Hide file tree
Showing 21 changed files with 423 additions and 11 deletions.
3 changes: 3 additions & 0 deletions api/v1/components/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions api/v1/components/drivemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions api/v1/components/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions api/v1/components/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions api/v1/components/patcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
30 changes: 30 additions & 0 deletions api/v1/components/resources.go
Original file line number Diff line number Diff line change
@@ -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"`
}
3 changes: 3 additions & 0 deletions api/v1/components/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 3 additions & 0 deletions api/v1/components/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
30 changes: 30 additions & 0 deletions charts/csi-baremetal-deployment/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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 }}
80 changes: 80 additions & 0 deletions charts/csi-baremetal-deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -93,6 +149,14 @@ scheduler:
enable: true
image:
tag:
resources:
limits:
cpu:
memory:
requests:
cpu:
memory:

# Logging settings
log:
format: text
Expand All @@ -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
Expand All @@ -126,6 +198,14 @@ nodeController:
enable: true
image:
tag:
resources:
limits:
cpu:
memory:
requests:
cpu:
memory:

# Logging settings
log:
format: text
Expand Down
Loading

0 comments on commit 3af3d6f

Please sign in to comment.