From d6bc6a856f886f494dc05d5d48f8827367fe6b8b Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Mon, 11 Oct 2021 12:14:54 -0700 Subject: [PATCH 01/28] add resource for controller Signed-off-by: Anton Yurkov --- .../csi-baremetal_v1_deployment.yaml | 1 + charts/csi-baremetal-deployment/values.yaml | 81 +++++++++++++++++++ pkg/controller.go | 1 + 3 files changed, 83 insertions(+) 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..c38afe7a 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -24,6 +24,7 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} + resources: {{ .Values.driver.controller.resources}} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} diff --git a/charts/csi-baremetal-deployment/values.yaml b/charts/csi-baremetal-deployment/values.yaml index 05c0cef9..923525c4 100644 --- a/charts/csi-baremetal-deployment/values.yaml +++ b/charts/csi-baremetal-deployment/values.yaml @@ -38,10 +38,27 @@ driver: image: tag: + resources: + requests: + memory: 200Mi + cpu: 100m + limits: + memory: 200Mi + cpu: 100m + node: image: tag: +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: +# +# drivemgr: type: basemgr image: @@ -53,24 +70,64 @@ driver: amountOfLoopDevices: 3 sizeOfLoopDevices: 101Mi +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: + # 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: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: +# resizer: image: tag: v1.1.0 +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: +# nodeDriverRegistrar: image: tag: v1.3.0 +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: +# livenessProbe: image: tag: v2.1.0 +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: +# # Metrics endpoint metrics: path: /metrics @@ -110,6 +167,14 @@ scheduler: image: tag: +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: + # Logging settings log: format: text @@ -133,6 +198,14 @@ scheduler: image: tag: +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: +# kubeconfig: /etc/kubernetes/scheduler.conf interval: 60 restore_on_shutdown: true @@ -153,6 +226,14 @@ nodeController: image: tag: +# resources: +# requests: +# memory: +# cpu: +# limits: +# memory: +# cpu: + # Logging settings log: format: text diff --git a/pkg/controller.go b/pkg/controller.go index 657e11ef..2916ead6 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: csi.Spec.ChunkManager.Pod.Resources }, { Name: constant.ProvisionerName, From 5e3edf43731bc07c21463b2708ca5b325dea7474 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 02:40:48 -0700 Subject: [PATCH 02/28] drop value of mem/cpu limits Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 11 ++++++++--- pkg/controller.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 450116fb..0050aa2a 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -16,9 +16,14 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // Controller encapsulates logic for CSI controller component type Controller struct { - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/pkg/controller.go b/pkg/controller.go index 2916ead6..7936ac68 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,7 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: csi.Spec.ChunkManager.Pod.Resources + Resources: *c.Resources, }, { Name: constant.ProvisionerName, From 8e74b9ed98056255d126aa79549092509f19f736 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 06:29:22 -0700 Subject: [PATCH 03/28] fix point error Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 2 +- pkg/controller.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 0050aa2a..131c63b8 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -25,5 +25,5 @@ type Controller struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/pkg/controller.go b/pkg/controller.go index 7936ac68..43c65b0d 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,7 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *c.Resources, + Resources: c.Resources, }, { Name: constant.ProvisionerName, From 67b2ab15c701bb00f3ed1dc18e7cf156f9ae100a Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 07:36:32 -0700 Subject: [PATCH 04/28] debug Signed-off-by: Anton Yurkov --- pkg/controller.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/controller.go b/pkg/controller.go index 43c65b0d..fad2b4c8 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -2,6 +2,7 @@ package pkg import ( "context" + "fmt" "strconv" "github.com/go-logr/logr" @@ -43,6 +44,7 @@ type Controller struct { func (c *Controller) Update(ctx context.Context, csi *csibaremetalv1.Deployment, scheme *runtime.Scheme) error { // create deployment expected := createControllerDeployment(csi) + c.Logger.Info("Resources: " + expected.Spec.Template.Spec.Containers[0].Name + " " + fmt.Sprintf("%#v", expected.Spec.Template.Spec.Containers[0].Resources)) if err := controllerutil.SetControllerReference(csi, expected, scheme); err != nil { return err } From f11b93c7f3051f7fa2936dffdabcaccab2cd6afa Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 14:35:02 -0700 Subject: [PATCH 05/28] add debug logs Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 6 +++--- pkg/controller.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 131c63b8..64579bd3 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -22,8 +22,8 @@ import ( // Controller encapsulates logic for CSI controller component type Controller struct { - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` Resources corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/pkg/controller.go b/pkg/controller.go index fad2b4c8..92016ea1 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -44,7 +44,8 @@ type Controller struct { func (c *Controller) Update(ctx context.Context, csi *csibaremetalv1.Deployment, scheme *runtime.Scheme) error { // create deployment expected := createControllerDeployment(csi) - c.Logger.Info("Resources: " + expected.Spec.Template.Spec.Containers[0].Name + " " + fmt.Sprintf("%#v", expected.Spec.Template.Spec.Containers[0].Resources)) + c.Logger.Info("Resources charts: " + fmt.Sprintf("%#v", csi.Spec.Driver.Controller.Resources)) + c.Logger.Info("Resources deployment: " + expected.Spec.Template.Spec.Containers[0].Name + " " + fmt.Sprintf("%#v", expected.Spec.Template.Spec.Containers[0].Resources)) if err := controllerutil.SetControllerReference(csi, expected, scheme); err != nil { return err } From 168464966dd6ffa32e57bae48ee95e72ab49f0e0 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 15:19:45 -0700 Subject: [PATCH 06/28] add debug logs Signed-off-by: Anton Yurkov --- .../templates/csi-baremetal_v1_deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c38afe7a..49bb3b97 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -24,7 +24,7 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} - resources: {{ .Values.driver.controller.resources}} + resources: {{ .Values.driver.controller.resources }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} From a1e87d35d0affae7bbd8c3cbd21a3af145642282 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 17:32:59 -0700 Subject: [PATCH 07/28] add resources to all containers Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 2 +- api/v1/components/drivemgr.go | 1 + api/v1/components/node.go | 1 + api/v1/components/node_controller.go | 1 + api/v1/components/patcher.go | 1 + api/v1/components/scheduler.go | 1 + api/v1/components/sidecar.go | 1 + charts/csi-baremetal-deployment/values.yaml | 149 ++++++++++---------- pkg/controller.go | 5 +- pkg/node/node_daemonset.go | 4 + pkg/node_controller.go | 2 + pkg/patcher/scheduler_patcher_vanilla.go | 1 + pkg/scheduler_extender.go | 1 + 13 files changed, 93 insertions(+), 77 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 64579bd3..6761f312 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -25,5 +25,5 @@ type Controller struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index c347c9f0..267a315c 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -20,4 +20,5 @@ package components type DriveMgr struct { Image *Image `json:"image,omitempty"` Endpoint string `json:"endpoint"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index 3b415c36..2373aa58 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -22,4 +22,5 @@ type Node struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index 91813e15..19654f0a 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -21,4 +21,5 @@ type NodeController struct { Enable bool `json:"enable"` Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index afdbe32f..01d6dc93 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -24,4 +24,5 @@ type Patcher struct { RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` ConfigMapName string `json:"configMapName,omitempty"` ReadinessTimeout int `json:"readinessTimeout,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index f13d77ab..9b72512d 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -25,4 +25,5 @@ type Scheduler struct { Patcher *Patcher `json:"patcher,omitempty"` ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index dbdd0327..de16cd7c 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -19,4 +19,5 @@ package components // Sidecar represent CSI sidecar containers type Sidecar struct { Image *Image `json:"image,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/charts/csi-baremetal-deployment/values.yaml b/charts/csi-baremetal-deployment/values.yaml index 923525c4..6e98c292 100644 --- a/charts/csi-baremetal-deployment/values.yaml +++ b/charts/csi-baremetal-deployment/values.yaml @@ -39,26 +39,25 @@ driver: tag: resources: - requests: - memory: 200Mi - cpu: 100m limits: - memory: 200Mi - cpu: 100m + cpu: + memory: + requests: + cpu: + memory: node: image: tag: -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: -# -# + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + drivemgr: type: basemgr image: @@ -70,13 +69,13 @@ driver: amountOfLoopDevices: 3 sizeOfLoopDevices: 101Mi -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: # Sidecars parameters provisioner: @@ -84,50 +83,50 @@ driver: # if you want to use topology feature (multiple PVCs per pod) you should use v1.2.2 tag: v1.6.0 -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: -# + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + resizer: image: tag: v1.1.0 -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: -# + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + nodeDriverRegistrar: image: tag: v1.3.0 -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: -# + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + livenessProbe: image: tag: v2.1.0 -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: -# + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + # Metrics endpoint metrics: path: /metrics @@ -167,13 +166,13 @@ scheduler: image: tag: -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: # Logging settings log: @@ -198,14 +197,14 @@ scheduler: image: tag: -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: -# + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + kubeconfig: /etc/kubernetes/scheduler.conf interval: 60 restore_on_shutdown: true @@ -226,13 +225,13 @@ nodeController: image: tag: -# resources: -# requests: -# memory: -# cpu: -# limits: -# memory: -# cpu: + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: # Logging settings log: diff --git a/pkg/controller.go b/pkg/controller.go index 92016ea1..a59c465c 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -187,7 +187,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: c.Resources, + Resources: *c.Resources, }, { Name: constant.ProvisionerName, @@ -209,6 +209,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: *provisioner.Resources, }, { Name: constant.ResizerName, @@ -229,6 +230,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: *resizer.Resources, }, { Name: constant.LivenessProbeName, @@ -244,6 +246,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: *liveness.Resources, }, } } diff --git a/pkg/node/node_daemonset.go b/pkg/node/node_daemonset.go index 6e271bb5..0c05771d 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: *lp.Resources, }, { Name: constant.DriverRegistrarName, @@ -227,6 +228,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: *dr.Resources, }, { Name: "node", @@ -285,6 +287,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: nodeMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: *node.Resources, }, { Name: "drivemgr", @@ -301,6 +304,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: driveMgrMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, + Resources: *driveMgr.Resources, }, } } diff --git a/pkg/node_controller.go b/pkg/node_controller.go index bd554c3b..1a4faf23 100644 --- a/pkg/node_controller.go +++ b/pkg/node_controller.go @@ -86,6 +86,7 @@ func createNodeControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Con var ( image = csi.Spec.NodeController.Image log = csi.Spec.NodeController.Log + resources = csi.Spec.NodeController.Resources ns = csi.Spec.NodeSelector ) @@ -112,6 +113,7 @@ func createNodeControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Con TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: []corev1.VolumeMount{constant.CrashMountVolume}, + Resources: *resources, }, } } diff --git a/pkg/patcher/scheduler_patcher_vanilla.go b/pkg/patcher/scheduler_patcher_vanilla.go index 378e6e7a..cd466ba3 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: *p.Resources, }, } } diff --git a/pkg/scheduler_extender.go b/pkg/scheduler_extender.go index 27129ca7..c32da8c6 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: *csi.Spec.Scheduler.Resources, }, } } From 167e83b131a90daecceb15a15ab993fc87d7a847 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 18:06:58 -0700 Subject: [PATCH 08/28] refactoring Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 6 +++--- api/v1/components/drivemgr.go | 8 ++++++-- api/v1/components/node.go | 12 ++++++++---- api/v1/components/node_controller.go | 10 +++++++--- api/v1/components/patcher.go | 18 +++++++++++------- api/v1/components/scheduler.go | 20 ++++++++++++-------- api/v1/components/sidecar.go | 6 +++++- pkg/node_controller.go | 6 +++--- pkg/patcher/patcher_configuration.go | 3 +++ pkg/patcher/scheduler_patcher_vanilla.go | 2 +- 10 files changed, 59 insertions(+), 32 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 6761f312..399588b4 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -22,8 +22,8 @@ import ( // Controller encapsulates logic for CSI controller component type Controller struct { - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index 267a315c..23da3f60 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -16,9 +16,13 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // DriveMgr represents drive manager node component type DriveMgr struct { - Image *Image `json:"image,omitempty"` - Endpoint string `json:"endpoint"` + Image *Image `json:"image,omitempty"` + Endpoint string `json:"endpoint"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index 2373aa58..bbabd375 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -16,11 +16,15 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // Node encapsulates information for CSI node components type Node struct { - DriveMgr *DriveMgr `json:"driveMgr,omitempty"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + DriveMgr *DriveMgr `json:"driveMgr,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index 19654f0a..e1300154 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -16,10 +16,14 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // NodeController represent operator for CSI bare-metal nodes type NodeController struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index 01d6dc93..792455b4 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -16,13 +16,17 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // Patcher represents scheduler patcher container, which tries to patch Kubernetes scheduler type Patcher struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Interval int `json:"interval,omitempty"` - RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` - ConfigMapName string `json:"configMapName,omitempty"` - ReadinessTimeout int `json:"readinessTimeout,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Interval int `json:"interval,omitempty"` + RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` + ConfigMapName string `json:"configMapName,omitempty"` + ReadinessTimeout int `json:"readinessTimeout,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 9b72512d..556246e7 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -16,14 +16,18 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // Scheduler encapsulates information to deploy CSI scheduler type Scheduler struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Metrics *Metrics `json:"metrics,omitempty"` - Patcher *Patcher `json:"patcher,omitempty"` - ExtenderPort string `json:"extenderPort,omitempty"` - StorageProvisioner string `json:"storageProvisioner"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Metrics *Metrics `json:"metrics,omitempty"` + Patcher *Patcher `json:"patcher,omitempty"` + ExtenderPort string `json:"extenderPort,omitempty"` + StorageProvisioner string `json:"storageProvisioner"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index de16cd7c..5d78355a 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -16,8 +16,12 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // Sidecar represent CSI sidecar containers type Sidecar struct { - Image *Image `json:"image,omitempty"` + Image *Image `json:"image,omitempty"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/pkg/node_controller.go b/pkg/node_controller.go index 1a4faf23..ed5e9dbb 100644 --- a/pkg/node_controller.go +++ b/pkg/node_controller.go @@ -84,10 +84,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 + image = csi.Spec.NodeController.Image + log = csi.Spec.NodeController.Log resources = csi.Spec.NodeController.Resources - ns = csi.Spec.NodeSelector + ns = csi.Spec.NodeSelector ) args := []string{ diff --git a/pkg/patcher/patcher_configuration.go b/pkg/patcher/patcher_configuration.go index e772504d..fd19e3fb 100644 --- a/pkg/patcher/patcher_configuration.go +++ b/pkg/patcher/patcher_configuration.go @@ -7,6 +7,7 @@ import ( csibaremetalv1 "github.com/dell/csi-baremetal-operator/api/v1" "github.com/dell/csi-baremetal-operator/api/v1/components" "github.com/dell/csi-baremetal-operator/pkg/constant" + corev1 "k8s.io/api/core/v1" ) const ( @@ -64,6 +65,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 +78,7 @@ type patcherConfiguration struct { loglevel components.Level interval int restoreOnShutdown bool + resources *corev1.ResourceRequirements platform string targetConfig string diff --git a/pkg/patcher/scheduler_patcher_vanilla.go b/pkg/patcher/scheduler_patcher_vanilla.go index cd466ba3..de9fe3f6 100644 --- a/pkg/patcher/scheduler_patcher_vanilla.go +++ b/pkg/patcher/scheduler_patcher_vanilla.go @@ -243,7 +243,7 @@ func (p patcherConfiguration) createPatcherContainers() []corev1.Container { }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *p.Resources, + Resources: *p.resources, }, } } From e458584bfa3217539bcea43af53ae0cb1b431585 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 18:09:12 -0700 Subject: [PATCH 09/28] remove debug logs Signed-off-by: Anton Yurkov --- pkg/controller.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/controller.go b/pkg/controller.go index a59c465c..7579badf 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -44,8 +44,6 @@ type Controller struct { func (c *Controller) Update(ctx context.Context, csi *csibaremetalv1.Deployment, scheme *runtime.Scheme) error { // create deployment expected := createControllerDeployment(csi) - c.Logger.Info("Resources charts: " + fmt.Sprintf("%#v", csi.Spec.Driver.Controller.Resources)) - c.Logger.Info("Resources deployment: " + expected.Spec.Template.Spec.Containers[0].Name + " " + fmt.Sprintf("%#v", expected.Spec.Template.Spec.Containers[0].Resources)) if err := controllerutil.SetControllerReference(csi, expected, scheme); err != nil { return err } From 764394eb4885006252e166baa156fe7641e4be60 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 18:21:59 -0700 Subject: [PATCH 10/28] add resources to deployment Signed-off-by: Anton Yurkov --- .../csi-baremetal_v1_deployment.yaml | 79 ++++++++++++++++++- pkg/controller.go | 1 - 2 files changed, 78 insertions(+), 2 deletions(-) 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 49bb3b97..5bdc236b 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -24,7 +24,13 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} - resources: {{ .Values.driver.controller.resources }} + resources: + requests: + memory: {{ .Values.driver.controller.resources.requests.memory }} + cpu: {{ .Values.driver.controller.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.controller.resources.limits.memory }} + cpu: {{ .Values.driver.controller.resources.requests.cpu }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -33,23 +39,59 @@ spec: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} + resources: + requests: + memory: {{ .Values.driver.livenessProbe.resources.requests.memory }} + cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.livenessProbe.resources.limits.memory }} + cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} + csi-provisioner: image: name: csi-provisioner tag: {{ .Values.driver.provisioner.image.tag }} + resources: + requests: + memory: {{ .Values.driver.provisioner.resources.requests.memory }} + cpu: {{ .Values.driver.provisioner.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.provisioner.resources.limits.memory }} + cpu: {{ .Values.driver.provisioner.resources.requests.cpu }} csi-resizer: image: name: csi-resizer tag: {{ .Values.driver.resizer.image.tag }} + resources: + requests: + memory: {{ .Values.driver.resizer.resources.requests.memory }} + cpu: {{ .Values.driver.resizer.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.resizer.resources.limits.memory }} + cpu: {{ .Values.driver.resizer.resources.requests.cpu }} node: driveMgr: image: name: csi-baremetal-{{ .Values.driver.drivemgr.type }} tag: {{ .Values.driver.drivemgr.image.tag | default .Values.image.tag }} + resources: + requests: + memory: {{ .Values.driver.drivemgr.resources.requests.memory }} + cpu: {{ .Values.driver.drivemgr.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.drivemgr.resources.limits.memory }} + cpu: {{ .Values.driver.drivemgr.resources.requests.cpu }} endpoint: {{ .Values.driver.drivemgr.grpc.server.endpoint }} image: name: csi-baremetal-node tag: {{ .Values.driver.node.image.tag | default .Values.image.tag }} + resources: + requests: + memory: {{ .Values.driver.node.resources.requests.memory }} + cpu: {{ .Values.driver.node.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.node.resources.limits.memory }} + cpu: {{ .Values.driver.node.resources.requests.cpu }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -58,10 +100,24 @@ spec: image: name: csi-node-driver-registrar tag: {{ .Values.driver.nodeDriverRegistrar.image.tag }} + resources: + requests: + memory: {{ .Values.driver.nodeDriverRegistrar.resources.requests.memory }} + cpu: {{ .Values.driver.nodeDriverRegistrar.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.nodeDriverRegistrar.resources.limits.memory }} + cpu: {{ .Values.driver.nodeDriverRegistrar.resources.requests.cpu }} livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} + resources: + requests: + memory: {{ .Values.driver.livenessProbe.resources.requests.memory }} + cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} + limits: + memory: {{ .Values.driver.livenessProbe.resources.limits.memory }} + cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} metrics: path: {{ .Values.driver.metrics.path }} port: {{ .Values.driver.metrics.port }} @@ -75,6 +131,13 @@ spec: image: name: csi-baremetal-scheduler-extender tag: {{ .Values.scheduler.image.tag | default .Values.image.tag }} + resources: + requests: + memory: {{ .Values.scheduler.resources.requests.memory }} + cpu: {{ .Values.scheduler.resources.requests.cpu }} + limits: + memory: {{ .Values.scheduler.resources.limits.memory }} + cpu: {{ .Values.scheduler.resources.requests.cpu }} log: format: {{ .Values.scheduler.log.format }} level: {{ .Values.scheduler.log.level }} @@ -87,6 +150,13 @@ spec: image: name: csi-baremetal-scheduler-patcher tag: {{ .Values.scheduler.patcher.image.tag | default .Values.image.tag }} + resources: + requests: + memory: {{ .Values.scheduler.patcher.resources.requests.memory }} + cpu: {{ .Values.scheduler.patcher.resources.requests.cpu }} + limits: + memory: {{ .Values.scheduler.patcher.resources.limits.memory }} + cpu: {{ .Values.scheduler.patcher.resources.requests.cpu }} interval: {{ .Values.scheduler.patcher.interval }} restoreOnShutdown: {{ .Values.scheduler.patcher.restore_on_shutdown }} configMapName: {{ .Values.scheduler.patcher.config_map_name }} @@ -97,6 +167,13 @@ spec: image: name: csi-baremetal-node-controller tag: {{ .Values.nodeController.image.tag | default .Values.image.tag }} + resources: + requests: + memory: {{ .Values.nodeController.resources.requests.memory }} + cpu: {{ .Values.nodeController.resources.requests.cpu }} + limits: + memory: {{ .Values.nodeController.resources.limits.memory }} + cpu: {{ .Values.nodeController.resources.requests.cpu }} log: format: {{ .Values.nodeController.log.format }} level: {{ .Values.nodeController.log.level }} diff --git a/pkg/controller.go b/pkg/controller.go index 7579badf..50b2449b 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -2,7 +2,6 @@ package pkg import ( "context" - "fmt" "strconv" "github.com/go-logr/logr" From 337e1466d1c6100639a166e7b23e822564d6745a Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Tue, 12 Oct 2021 19:20:36 -0700 Subject: [PATCH 11/28] fix requests to limits Signed-off-by: Anton Yurkov --- .../csi-baremetal_v1_deployment.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 5bdc236b..a06807c6 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -30,7 +30,7 @@ spec: cpu: {{ .Values.driver.controller.resources.requests.cpu }} limits: memory: {{ .Values.driver.controller.resources.limits.memory }} - cpu: {{ .Values.driver.controller.resources.requests.cpu }} + cpu: {{ .Values.driver.controller.resources.limits.cpu }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -45,7 +45,7 @@ spec: cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} limits: memory: {{ .Values.driver.livenessProbe.resources.limits.memory }} - cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} + cpu: {{ .Values.driver.livenessProbe.resources.limits.cpu }} csi-provisioner: image: @@ -57,7 +57,7 @@ spec: cpu: {{ .Values.driver.provisioner.resources.requests.cpu }} limits: memory: {{ .Values.driver.provisioner.resources.limits.memory }} - cpu: {{ .Values.driver.provisioner.resources.requests.cpu }} + cpu: {{ .Values.driver.provisioner.resources.limits.cpu }} csi-resizer: image: name: csi-resizer @@ -68,7 +68,7 @@ spec: cpu: {{ .Values.driver.resizer.resources.requests.cpu }} limits: memory: {{ .Values.driver.resizer.resources.limits.memory }} - cpu: {{ .Values.driver.resizer.resources.requests.cpu }} + cpu: {{ .Values.driver.resizer.resources.limits.cpu }} node: driveMgr: image: @@ -80,7 +80,7 @@ spec: cpu: {{ .Values.driver.drivemgr.resources.requests.cpu }} limits: memory: {{ .Values.driver.drivemgr.resources.limits.memory }} - cpu: {{ .Values.driver.drivemgr.resources.requests.cpu }} + cpu: {{ .Values.driver.drivemgr.resources.limits.cpu }} endpoint: {{ .Values.driver.drivemgr.grpc.server.endpoint }} image: name: csi-baremetal-node @@ -91,7 +91,7 @@ spec: cpu: {{ .Values.driver.node.resources.requests.cpu }} limits: memory: {{ .Values.driver.node.resources.limits.memory }} - cpu: {{ .Values.driver.node.resources.requests.cpu }} + cpu: {{ .Values.driver.node.resources.limits.cpu }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -106,7 +106,7 @@ spec: cpu: {{ .Values.driver.nodeDriverRegistrar.resources.requests.cpu }} limits: memory: {{ .Values.driver.nodeDriverRegistrar.resources.limits.memory }} - cpu: {{ .Values.driver.nodeDriverRegistrar.resources.requests.cpu }} + cpu: {{ .Values.driver.nodeDriverRegistrar.resources.limits.cpu }} livenessprobe: image: name: livenessprobe @@ -117,7 +117,7 @@ spec: cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} limits: memory: {{ .Values.driver.livenessProbe.resources.limits.memory }} - cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} + cpu: {{ .Values.driver.livenessProbe.resources.limits.cpu }} metrics: path: {{ .Values.driver.metrics.path }} port: {{ .Values.driver.metrics.port }} @@ -137,7 +137,7 @@ spec: cpu: {{ .Values.scheduler.resources.requests.cpu }} limits: memory: {{ .Values.scheduler.resources.limits.memory }} - cpu: {{ .Values.scheduler.resources.requests.cpu }} + cpu: {{ .Values.scheduler.resources.limits.cpu }} log: format: {{ .Values.scheduler.log.format }} level: {{ .Values.scheduler.log.level }} @@ -156,7 +156,7 @@ spec: cpu: {{ .Values.scheduler.patcher.resources.requests.cpu }} limits: memory: {{ .Values.scheduler.patcher.resources.limits.memory }} - cpu: {{ .Values.scheduler.patcher.resources.requests.cpu }} + cpu: {{ .Values.scheduler.patcher.resources.limits.cpu }} interval: {{ .Values.scheduler.patcher.interval }} restoreOnShutdown: {{ .Values.scheduler.patcher.restore_on_shutdown }} configMapName: {{ .Values.scheduler.patcher.config_map_name }} @@ -173,7 +173,7 @@ spec: cpu: {{ .Values.nodeController.resources.requests.cpu }} limits: memory: {{ .Values.nodeController.resources.limits.memory }} - cpu: {{ .Values.nodeController.resources.requests.cpu }} + cpu: {{ .Values.nodeController.resources.limits.cpu }} log: format: {{ .Values.nodeController.log.format }} level: {{ .Values.nodeController.log.level }} From 630342bad5cc2208d70ee804f2f6df4489bf09f7 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Wed, 13 Oct 2021 03:54:52 -0700 Subject: [PATCH 12/28] add values for operator Signed-off-by: Anton Yurkov --- charts/csi-baremetal-operator/templates/manager.yaml | 9 ++++----- charts/csi-baremetal-operator/values.yaml | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) 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..c7fec301 100644 --- a/charts/csi-baremetal-operator/values.yaml +++ b/charts/csi-baremetal-operator/values.yaml @@ -8,3 +8,12 @@ image: name: csi-baremetal-operator tag: green pullPolicy: Always + +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 + requests: + cpu: 100m + memory: 20Mi From 37f24ee1a057bb5f0428383ddaa23a9a9dc2aab5 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 14 Oct 2021 01:26:51 -0700 Subject: [PATCH 13/28] update crd Signed-off-by: Anton Yurkov --- .../csi-baremetal.dell.com_deployments.yaml | 176 ++++++++++++++++++ go.mod | 2 +- 2 files changed, 177 insertions(+), 1 deletion(-) 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..c28726c6 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,28 @@ spec: - format - level type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object sidecars: additionalProperties: description: Sidecar represent CSI sidecar containers @@ -80,6 +102,28 @@ spec: - name - tag type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object type: object type: object type: object @@ -136,6 +180,28 @@ spec: - name - tag type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object required: - endpoint type: object @@ -163,6 +229,28 @@ spec: - format - level type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object sidecars: additionalProperties: description: Sidecar represent CSI sidecar containers @@ -178,6 +266,28 @@ spec: - name - tag type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object type: object type: object type: object @@ -214,6 +324,28 @@ spec: - format - level type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object required: - enable type: object @@ -309,11 +441,55 @@ spec: type: integer readinessTimeout: type: integer + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object restoreOnShutdown: type: boolean required: - enable type: object + resources: + description: ResourceRequirements describes the compute resource requirements. + 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object storageProvisioner: type: string required: diff --git a/go.mod b/go.mod index 3e76721d..14fc9d50 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/stretchr/testify v1.5.1 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b k8s.io/api v1.16.4 - k8s.io/apimachinery v0.19.2 + k8s.io/apimachinery v0.20.2 k8s.io/client-go v1.16.4 k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 sigs.k8s.io/controller-runtime v0.7.2 From fbc8312b8cb0b09d0f6a573b036dfe2f49e40b09 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 14 Oct 2021 01:57:13 -0700 Subject: [PATCH 14/28] refactoring Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 2 +- api/v1/components/drivemgr.go | 2 +- api/v1/components/node.go | 2 +- api/v1/components/node_controller.go | 2 +- api/v1/components/patcher.go | 2 +- api/v1/components/scheduler.go | 2 +- api/v1/components/sidecar.go | 2 +- .../crds/csi-baremetal.dell.com_deployments.yaml | 12 ++++++++++++ 8 files changed, 19 insertions(+), 7 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 399588b4..f84cf910 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -25,5 +25,5 @@ type Controller struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index 23da3f60..63c6b8d3 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -24,5 +24,5 @@ import ( type DriveMgr struct { Image *Image `json:"image,omitempty"` Endpoint string `json:"endpoint"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index bbabd375..08cc83e3 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -26,5 +26,5 @@ type Node struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index e1300154..c4dbcc8a 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -25,5 +25,5 @@ type NodeController struct { Enable bool `json:"enable"` Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index 792455b4..dfeae302 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -28,5 +28,5 @@ type Patcher struct { RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` ConfigMapName string `json:"configMapName,omitempty"` ReadinessTimeout int `json:"readinessTimeout,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 556246e7..3504cfc8 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -29,5 +29,5 @@ type Scheduler struct { Patcher *Patcher `json:"patcher,omitempty"` ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index 5d78355a..62e5c682 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -23,5 +23,5 @@ import ( // Sidecar represent CSI sidecar containers type Sidecar struct { Image *Image `json:"image,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,"` } 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 c28726c6..79a9ca91 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 @@ -124,8 +124,12 @@ spec: description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' type: object type: object + required: + - resources type: object type: object + required: + - resources type: object logReceiver: description: LogReceiver encapsulates information needed to establish log receiver for components @@ -204,6 +208,7 @@ spec: type: object required: - endpoint + - resources type: object image: description: Image contain information for components docker images @@ -288,8 +293,12 @@ spec: description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' type: object type: object + required: + - resources type: object type: object + required: + - resources type: object type: object globalRegistry: @@ -348,6 +357,7 @@ spec: type: object required: - enable + - resources type: object nodeIDAnnotation: type: boolean @@ -467,6 +477,7 @@ spec: type: boolean required: - enable + - resources type: object resources: description: ResourceRequirements describes the compute resource requirements. @@ -494,6 +505,7 @@ spec: type: string required: - enable + - resources - storageProvisioner type: object sequentialLVGReservation: From 5e4934629379290ebb6b0e3cc0088f1ab2d657b0 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 14 Oct 2021 01:58:04 -0700 Subject: [PATCH 15/28] refactoring Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 2 +- api/v1/components/drivemgr.go | 2 +- api/v1/components/node.go | 2 +- api/v1/components/node_controller.go | 2 +- api/v1/components/patcher.go | 2 +- api/v1/components/scheduler.go | 2 +- api/v1/components/sidecar.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index f84cf910..3452ac4f 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -25,5 +25,5 @@ type Controller struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index 63c6b8d3..392566f0 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -24,5 +24,5 @@ import ( type DriveMgr struct { Image *Image `json:"image,omitempty"` Endpoint string `json:"endpoint"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index 08cc83e3..d3acbe42 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -26,5 +26,5 @@ type Node struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index c4dbcc8a..f3ca16a2 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -25,5 +25,5 @@ type NodeController struct { Enable bool `json:"enable"` Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index dfeae302..4d670fba 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -28,5 +28,5 @@ type Patcher struct { RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` ConfigMapName string `json:"configMapName,omitempty"` ReadinessTimeout int `json:"readinessTimeout,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 3504cfc8..aee84933 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -29,5 +29,5 @@ type Scheduler struct { Patcher *Patcher `json:"patcher,omitempty"` ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index 62e5c682..e9f5f90f 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -23,5 +23,5 @@ import ( // Sidecar represent CSI sidecar containers type Sidecar struct { Image *Image `json:"image,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources,"` + Resources *corev1.ResourceRequirements `json:"resources"` } From d9b2de00bb043a651e4853a5a5cd3e2b5cdc2692 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Mon, 18 Oct 2021 01:54:48 -0700 Subject: [PATCH 16/28] add custom ResourceRequirements Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 6 ++---- api/v1/components/drivemgr.go | 6 ++---- api/v1/components/node.go | 6 ++---- api/v1/components/node_controller.go | 6 ++---- api/v1/components/patcher.go | 6 ++---- api/v1/components/resources.go | 26 ++++++++++++++++++++++++ api/v1/components/scheduler.go | 6 ++---- api/v1/components/sidecar.go | 6 ++---- pkg/controller.go | 8 ++++---- pkg/node/node_daemonset.go | 8 ++++---- pkg/node_controller.go | 2 +- pkg/patcher/patcher_configuration.go | 3 +-- pkg/patcher/scheduler_patcher_vanilla.go | 2 +- pkg/scheduler_extender.go | 2 +- 14 files changed, 52 insertions(+), 41 deletions(-) create mode 100644 api/v1/components/resources.go diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 3452ac4f..bdc500cf 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -16,14 +16,12 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // Controller encapsulates logic for CSI controller component type Controller struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index 392566f0..cbf340dc 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -16,13 +16,11 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // DriveMgr represents drive manager node component type DriveMgr struct { Image *Image `json:"image,omitempty"` Endpoint string `json:"endpoint"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index d3acbe42..f760790e 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -16,9 +16,7 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // Node encapsulates information for CSI node components type Node struct { @@ -26,5 +24,5 @@ type Node struct { Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index f3ca16a2..5b85e667 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -16,14 +16,12 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // NodeController represent operator for CSI bare-metal nodes type NodeController struct { Enable bool `json:"enable"` Image *Image `json:"image,omitempty"` Log *Log `json:"log,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index 4d670fba..aedc4720 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -16,9 +16,7 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // Patcher represents scheduler patcher container, which tries to patch Kubernetes scheduler type Patcher struct { @@ -28,5 +26,5 @@ type Patcher struct { RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` ConfigMapName string `json:"configMapName,omitempty"` ReadinessTimeout int `json:"readinessTimeout,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/resources.go b/api/v1/components/resources.go new file mode 100644 index 00000000..3e9d3913 --- /dev/null +++ b/api/v1/components/resources.go @@ -0,0 +1,26 @@ +/* +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 { + Limits corev1.ResourceList `json:"limits,omitempty"` + Requests corev1.ResourceList `json:"requests,omitempty"` +} \ No newline at end of file diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index aee84933..dd2f7807 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -16,9 +16,7 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // Scheduler encapsulates information to deploy CSI scheduler type Scheduler struct { @@ -29,5 +27,5 @@ type Scheduler struct { Patcher *Patcher `json:"patcher,omitempty"` ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index e9f5f90f..b70277bc 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -16,12 +16,10 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) + // Sidecar represent CSI sidecar containers type Sidecar struct { Image *Image `json:"image,omitempty"` - Resources *corev1.ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources"` } diff --git a/pkg/controller.go b/pkg/controller.go index 50b2449b..4fb45432 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,7 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *c.Resources, + Resources: corev1.ResourceRequirements(*c.Resources), }, { Name: constant.ProvisionerName, @@ -206,7 +206,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *provisioner.Resources, + Resources: corev1.ResourceRequirements(*provisioner.Resources), }, { Name: constant.ResizerName, @@ -227,7 +227,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *resizer.Resources, + Resources: corev1.ResourceRequirements(*resizer.Resources), }, { Name: constant.LivenessProbeName, @@ -243,7 +243,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *liveness.Resources, + Resources: corev1.ResourceRequirements(*liveness.Resources), }, } } diff --git a/pkg/node/node_daemonset.go b/pkg/node/node_daemonset.go index 0c05771d..12d2fef4 100644 --- a/pkg/node/node_daemonset.go +++ b/pkg/node/node_daemonset.go @@ -204,7 +204,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *lp.Resources, + Resources: corev1.ResourceRequirements(*lp.Resources), }, { Name: constant.DriverRegistrarName, @@ -228,7 +228,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *dr.Resources, + Resources: corev1.ResourceRequirements(*dr.Resources), }, { Name: "node", @@ -287,7 +287,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: nodeMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *node.Resources, + Resources: corev1.ResourceRequirements(*node.Resources), }, { Name: "drivemgr", @@ -304,7 +304,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: driveMgrMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *driveMgr.Resources, + Resources: corev1.ResourceRequirements(*driveMgr.Resources), }, } } diff --git a/pkg/node_controller.go b/pkg/node_controller.go index ed5e9dbb..1b90b2fa 100644 --- a/pkg/node_controller.go +++ b/pkg/node_controller.go @@ -113,7 +113,7 @@ func createNodeControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Con TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: []corev1.VolumeMount{constant.CrashMountVolume}, - Resources: *resources, + Resources: corev1.ResourceRequirements(*resources), }, } } diff --git a/pkg/patcher/patcher_configuration.go b/pkg/patcher/patcher_configuration.go index fd19e3fb..4a49751b 100644 --- a/pkg/patcher/patcher_configuration.go +++ b/pkg/patcher/patcher_configuration.go @@ -7,7 +7,6 @@ import ( csibaremetalv1 "github.com/dell/csi-baremetal-operator/api/v1" "github.com/dell/csi-baremetal-operator/api/v1/components" "github.com/dell/csi-baremetal-operator/pkg/constant" - corev1 "k8s.io/api/core/v1" ) const ( @@ -78,7 +77,7 @@ type patcherConfiguration struct { loglevel components.Level interval int restoreOnShutdown bool - resources *corev1.ResourceRequirements + resources *components.ResourceRequirements platform string targetConfig string diff --git a/pkg/patcher/scheduler_patcher_vanilla.go b/pkg/patcher/scheduler_patcher_vanilla.go index de9fe3f6..a576180f 100644 --- a/pkg/patcher/scheduler_patcher_vanilla.go +++ b/pkg/patcher/scheduler_patcher_vanilla.go @@ -243,7 +243,7 @@ func (p patcherConfiguration) createPatcherContainers() []corev1.Container { }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *p.resources, + Resources: corev1.ResourceRequirements(*p.resources), }, } } diff --git a/pkg/scheduler_extender.go b/pkg/scheduler_extender.go index c32da8c6..293939fd 100644 --- a/pkg/scheduler_extender.go +++ b/pkg/scheduler_extender.go @@ -176,7 +176,7 @@ func createExtenderContainers(csi *csibaremetalv1.Deployment, isPatchingEnabled TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: volumeMounts, - Resources: *csi.Spec.Scheduler.Resources, + Resources: corev1.ResourceRequirements(*csi.Spec.Scheduler.Resources), }, } } From d5d6081533b7c584856ea73014b19becd55525ce Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Mon, 18 Oct 2021 02:46:02 -0700 Subject: [PATCH 17/28] tags resource Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 8 +-- api/v1/components/drivemgr.go | 6 +- api/v1/components/node.go | 10 ++- api/v1/components/node_controller.go | 8 +-- api/v1/components/patcher.go | 14 ++-- api/v1/components/resources.go | 10 ++- api/v1/components/scheduler.go | 16 ++--- api/v1/components/sidecar.go | 4 +- .../csi-baremetal.dell.com_deployments.yaml | 64 ++++++++++++------- 9 files changed, 73 insertions(+), 67 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index bdc500cf..ea7efe12 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -16,12 +16,10 @@ limitations under the License. package components - - // Controller encapsulates logic for CSI controller component type Controller struct { - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index cbf340dc..017bc2d0 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -16,11 +16,9 @@ limitations under the License. package components - - // DriveMgr represents drive manager node component type DriveMgr struct { - Image *Image `json:"image,omitempty"` - Endpoint string `json:"endpoint"` + Image *Image `json:"image,omitempty"` + Endpoint string `json:"endpoint"` Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index f760790e..bd921d29 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -16,13 +16,11 @@ limitations under the License. package components - - // Node encapsulates information for CSI node components type Node struct { - DriveMgr *DriveMgr `json:"driveMgr,omitempty"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + DriveMgr *DriveMgr `json:"driveMgr,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index 5b85e667..cb6392f3 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -16,12 +16,10 @@ limitations under the License. package components - - // NodeController represent operator for CSI bare-metal nodes type NodeController struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index aedc4720..88d8e2ff 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -16,15 +16,13 @@ limitations under the License. package components - - // Patcher represents scheduler patcher container, which tries to patch Kubernetes scheduler type Patcher struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Interval int `json:"interval,omitempty"` - RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` - ConfigMapName string `json:"configMapName,omitempty"` - ReadinessTimeout int `json:"readinessTimeout,omitempty"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Interval int `json:"interval,omitempty"` + RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` + ConfigMapName string `json:"configMapName,omitempty"` + ReadinessTimeout int `json:"readinessTimeout,omitempty"` Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/resources.go b/api/v1/components/resources.go index 3e9d3913..4a98bd50 100644 --- a/api/v1/components/resources.go +++ b/api/v1/components/resources.go @@ -21,6 +21,10 @@ import ( // ResourceRequirements contain information for mem/cpu requirements type ResourceRequirements struct { - Limits corev1.ResourceList `json:"limits,omitempty"` - Requests corev1.ResourceList `json:"requests,omitempty"` -} \ No newline at end of file + // +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 dd2f7807..98ddf25c 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -16,16 +16,14 @@ limitations under the License. package components - - // Scheduler encapsulates information to deploy CSI scheduler type Scheduler struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Metrics *Metrics `json:"metrics,omitempty"` - Patcher *Patcher `json:"patcher,omitempty"` - ExtenderPort string `json:"extenderPort,omitempty"` - StorageProvisioner string `json:"storageProvisioner"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Metrics *Metrics `json:"metrics,omitempty"` + Patcher *Patcher `json:"patcher,omitempty"` + ExtenderPort string `json:"extenderPort,omitempty"` + StorageProvisioner string `json:"storageProvisioner"` Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index b70277bc..695fe6ca 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -16,10 +16,8 @@ limitations under the License. package components - - // Sidecar represent CSI sidecar containers type Sidecar struct { - Image *Image `json:"image,omitempty"` + Image *Image `json:"image,omitempty"` Resources *ResourceRequirements `json:"resources"` } 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 79a9ca91..69771aca 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 @@ -66,7 +66,7 @@ spec: - level type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -75,7 +75,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -84,7 +85,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object sidecars: @@ -103,7 +105,7 @@ spec: - tag type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -112,7 +114,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -121,7 +124,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object required: @@ -185,7 +189,7 @@ spec: - tag type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -194,7 +198,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -203,7 +208,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object required: @@ -235,7 +241,7 @@ spec: - level type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -244,7 +250,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -253,7 +260,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object sidecars: @@ -272,7 +280,7 @@ spec: - tag type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -281,7 +289,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -290,7 +299,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object required: @@ -334,7 +344,7 @@ spec: - level type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -343,7 +353,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -352,7 +363,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object required: @@ -452,7 +464,7 @@ spec: readinessTimeout: type: integer resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -461,7 +473,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -470,7 +483,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object restoreOnShutdown: @@ -480,7 +494,7 @@ spec: - resources type: object resources: - description: ResourceRequirements describes the compute resource requirements. + description: ResourceRequirements contain information for mem/cpu requirements properties: limits: additionalProperties: @@ -489,7 +503,8 @@ spec: - 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: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object requests: additionalProperties: @@ -498,7 +513,8 @@ spec: - 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: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + description: ResourceList is a set of (resource name, quantity) pairs. + nullable: true type: object type: object storageProvisioner: From ef8e70b1a35e110fc901dfb182f76b5f8e0e45ff Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Mon, 18 Oct 2021 03:07:44 -0700 Subject: [PATCH 18/28] tags resource Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 8 +++++--- api/v1/components/drivemgr.go | 6 ++++-- api/v1/components/node.go | 10 ++++++---- api/v1/components/node_controller.go | 8 +++++--- api/v1/components/patcher.go | 16 ++++++++------- api/v1/components/scheduler.go | 18 +++++++++-------- api/v1/components/sidecar.go | 4 +++- .../csi-baremetal.dell.com_deployments.yaml | 20 ++++++++----------- 8 files changed, 50 insertions(+), 40 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index ea7efe12..34e1c50a 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -18,8 +18,10 @@ package components // Controller encapsulates logic for CSI controller component type Controller struct { - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + // +nullable + // +optional Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index 017bc2d0..364d3edd 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -18,7 +18,9 @@ package components // DriveMgr represents drive manager node component type DriveMgr struct { - Image *Image `json:"image,omitempty"` - Endpoint string `json:"endpoint"` + Image *Image `json:"image,omitempty"` + Endpoint string `json:"endpoint"` + // +nullable + // +optional Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index bd921d29..223c2720 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -18,9 +18,11 @@ package components // Node encapsulates information for CSI node components type Node struct { - DriveMgr *DriveMgr `json:"driveMgr,omitempty"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + DriveMgr *DriveMgr `json:"driveMgr,omitempty"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` + // +nullable + // +optional Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index cb6392f3..c872a314 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -18,8 +18,10 @@ package components // NodeController represent operator for CSI bare-metal nodes type NodeController struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + // +nullable + // +optional Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index 88d8e2ff..f6d425fe 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -18,11 +18,13 @@ package components // Patcher represents scheduler patcher container, which tries to patch Kubernetes scheduler type Patcher struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Interval int `json:"interval,omitempty"` - RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` - ConfigMapName string `json:"configMapName,omitempty"` - ReadinessTimeout int `json:"readinessTimeout,omitempty"` - Resources *ResourceRequirements `json:"resources"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Interval int `json:"interval,omitempty"` + RestoreOnShutdown bool `json:"restoreOnShutdown,omitempty"` + ConfigMapName string `json:"configMapName,omitempty"` + ReadinessTimeout int `json:"readinessTimeout,omitempty"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 98ddf25c..0668815b 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -18,12 +18,14 @@ package components // Scheduler encapsulates information to deploy CSI scheduler type Scheduler struct { - Enable bool `json:"enable"` - Image *Image `json:"image,omitempty"` - Log *Log `json:"log,omitempty"` - Metrics *Metrics `json:"metrics,omitempty"` - Patcher *Patcher `json:"patcher,omitempty"` - ExtenderPort string `json:"extenderPort,omitempty"` - StorageProvisioner string `json:"storageProvisioner"` - Resources *ResourceRequirements `json:"resources"` + Enable bool `json:"enable"` + Image *Image `json:"image,omitempty"` + Log *Log `json:"log,omitempty"` + Metrics *Metrics `json:"metrics,omitempty"` + Patcher *Patcher `json:"patcher,omitempty"` + ExtenderPort string `json:"extenderPort,omitempty"` + StorageProvisioner string `json:"storageProvisioner"` + // +nullable + // +optional + Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index 695fe6ca..980f2581 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -18,6 +18,8 @@ package components // Sidecar represent CSI sidecar containers type Sidecar struct { - Image *Image `json:"image,omitempty"` + Image *Image `json:"image,omitempty"` + // +nullable + // +optional Resources *ResourceRequirements `json:"resources"` } 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 69771aca..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 @@ -67,6 +67,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -106,6 +107,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -128,12 +130,8 @@ spec: nullable: true type: object type: object - required: - - resources type: object type: object - required: - - resources type: object logReceiver: description: LogReceiver encapsulates information needed to establish log receiver for components @@ -190,6 +188,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -214,7 +213,6 @@ spec: type: object required: - endpoint - - resources type: object image: description: Image contain information for components docker images @@ -242,6 +240,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -281,6 +280,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -303,12 +303,8 @@ spec: nullable: true type: object type: object - required: - - resources type: object type: object - required: - - resources type: object type: object globalRegistry: @@ -345,6 +341,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -369,7 +366,6 @@ spec: type: object required: - enable - - resources type: object nodeIDAnnotation: type: boolean @@ -465,6 +461,7 @@ spec: type: integer resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -491,10 +488,10 @@ spec: type: boolean required: - enable - - resources type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -521,7 +518,6 @@ spec: type: string required: - enable - - resources - storageProvisioner type: object sequentialLVGReservation: From e2f8f52c2f853c1cb4fece991768327685bce526 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 21 Oct 2021 13:15:57 -0700 Subject: [PATCH 19/28] tags resource Signed-off-by: Anton Yurkov --- api/v1/components/resources.go | 4 ++-- api/v1/components/scheduler.go | 1 - api/v1/components/sidecar.go | 1 - .../crds/csi-baremetal.dell.com_deployments.yaml | 3 --- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/api/v1/components/resources.go b/api/v1/components/resources.go index 4a98bd50..a4c80a6c 100644 --- a/api/v1/components/resources.go +++ b/api/v1/components/resources.go @@ -23,8 +23,8 @@ import ( type ResourceRequirements struct { // +nullable // +optional - Limits corev1.ResourceList `json:"limits,omitempty"` + Limits corev1.ResourceList `json:"limits"` // +nullable // +optional - Requests corev1.ResourceList `json:"requests,omitempty"` + Requests corev1.ResourceList `json:"requests"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 0668815b..38843269 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -25,7 +25,6 @@ type Scheduler struct { Patcher *Patcher `json:"patcher,omitempty"` ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` - // +nullable // +optional Resources *ResourceRequirements `json:"resources"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index 980f2581..cb05a684 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -19,7 +19,6 @@ package components // Sidecar represent CSI sidecar containers type Sidecar struct { Image *Image `json:"image,omitempty"` - // +nullable // +optional Resources *ResourceRequirements `json:"resources"` } 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 f0896054..6098dd99 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 @@ -107,7 +107,6 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements - nullable: true properties: limits: additionalProperties: @@ -280,7 +279,6 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements - nullable: true properties: limits: additionalProperties: @@ -491,7 +489,6 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements - nullable: true properties: limits: additionalProperties: From a95ae92e1df27d6aaeca89a20f648ef637bbff4d Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 21 Oct 2021 15:52:52 -0700 Subject: [PATCH 20/28] tags resource Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 2 +- api/v1/components/drivemgr.go | 2 +- api/v1/components/node.go | 2 +- api/v1/components/node_controller.go | 2 +- api/v1/components/patcher.go | 2 +- api/v1/components/scheduler.go | 2 +- api/v1/components/sidecar.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 34e1c50a..1d7e66f5 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -23,5 +23,5 @@ type Controller struct { Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` // +nullable // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/drivemgr.go b/api/v1/components/drivemgr.go index 364d3edd..fb0261df 100644 --- a/api/v1/components/drivemgr.go +++ b/api/v1/components/drivemgr.go @@ -22,5 +22,5 @@ type DriveMgr struct { Endpoint string `json:"endpoint"` // +nullable // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node.go b/api/v1/components/node.go index 223c2720..8cfb34a7 100644 --- a/api/v1/components/node.go +++ b/api/v1/components/node.go @@ -24,5 +24,5 @@ type Node struct { Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` // +nullable // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/node_controller.go b/api/v1/components/node_controller.go index c872a314..3e17cf3d 100644 --- a/api/v1/components/node_controller.go +++ b/api/v1/components/node_controller.go @@ -23,5 +23,5 @@ type NodeController struct { Log *Log `json:"log,omitempty"` // +nullable // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/patcher.go b/api/v1/components/patcher.go index f6d425fe..3b61999e 100644 --- a/api/v1/components/patcher.go +++ b/api/v1/components/patcher.go @@ -26,5 +26,5 @@ type Patcher struct { ReadinessTimeout int `json:"readinessTimeout,omitempty"` // +nullable // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 38843269..237ea1e3 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -26,5 +26,5 @@ type Scheduler struct { ExtenderPort string `json:"extenderPort,omitempty"` StorageProvisioner string `json:"storageProvisioner"` // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index cb05a684..170d0954 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -20,5 +20,5 @@ package components type Sidecar struct { Image *Image `json:"image,omitempty"` // +optional - Resources *ResourceRequirements `json:"resources"` + Resources *ResourceRequirements `json:"resources,omitempty"` } From 6770b8f5f1ab37f0e7a0b5ab645de7628233fa86 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 21 Oct 2021 17:20:56 -0700 Subject: [PATCH 21/28] omitempty Signed-off-by: Anton Yurkov --- api/v1/components/resources.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/components/resources.go b/api/v1/components/resources.go index a4c80a6c..4a98bd50 100644 --- a/api/v1/components/resources.go +++ b/api/v1/components/resources.go @@ -23,8 +23,8 @@ import ( type ResourceRequirements struct { // +nullable // +optional - Limits corev1.ResourceList `json:"limits"` + Limits corev1.ResourceList `json:"limits,omitempty"` // +nullable // +optional - Requests corev1.ResourceList `json:"requests"` + Requests corev1.ResourceList `json:"requests,omitempty"` } From e4d7a7a0d4a91d37ae116f4fe37e89f6cf6de599 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 21 Oct 2021 18:38:45 -0700 Subject: [PATCH 22/28] experiment Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 6 +++++- api/v1/components/sidecar.go | 1 + .../templates/csi-baremetal_v1_deployment.yaml | 8 +------- pkg/controller.go | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 1d7e66f5..d1e41d1b 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -16,6 +16,10 @@ limitations under the License. package components +import ( + corev1 "k8s.io/api/core/v1" +) + // Controller encapsulates logic for CSI controller component type Controller struct { Image *Image `json:"image,omitempty"` @@ -23,5 +27,5 @@ type Controller struct { Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` // +nullable // +optional - Resources *ResourceRequirements `json:"resources,omitempty"` + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/api/v1/components/sidecar.go b/api/v1/components/sidecar.go index 170d0954..68a66557 100644 --- a/api/v1/components/sidecar.go +++ b/api/v1/components/sidecar.go @@ -19,6 +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/csi-baremetal_v1_deployment.yaml b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml index a06807c6..f4a31ad0 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -24,13 +24,7 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} - resources: - requests: - memory: {{ .Values.driver.controller.resources.requests.memory }} - cpu: {{ .Values.driver.controller.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.controller.resources.limits.memory }} - cpu: {{ .Values.driver.controller.resources.limits.cpu }} + resources: {{- toYaml .Values.driver.controller.resources | nindent 8}} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} diff --git a/pkg/controller.go b/pkg/controller.go index 4fb45432..0a1c2b01 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,7 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*c.Resources), + Resources: *c.Resources, }, { Name: constant.ProvisionerName, From 82c87b1e6d1f35d90522d8bbd44ce1b06297c46b Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 21 Oct 2021 18:40:42 -0700 Subject: [PATCH 23/28] experiment Signed-off-by: Anton Yurkov --- .../crds/csi-baremetal.dell.com_deployments.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 6098dd99..91e974c6 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 @@ -66,7 +66,7 @@ spec: - level type: object resources: - description: ResourceRequirements contain information for mem/cpu requirements + description: ResourceRequirements describes the compute resource requirements. nullable: true properties: limits: @@ -76,8 +76,7 @@ spec: - 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 + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' type: object requests: additionalProperties: @@ -86,8 +85,7 @@ spec: - 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 + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' type: object type: object sidecars: @@ -107,6 +105,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: @@ -279,6 +278,7 @@ spec: type: object resources: description: ResourceRequirements contain information for mem/cpu requirements + nullable: true properties: limits: additionalProperties: From 425816d3fde7a61c2dc0c7460077316b98261559 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Mon, 25 Oct 2021 07:51:29 -0700 Subject: [PATCH 24/28] final Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 5 +- .../templates/_helpers.tpl | 18 +++++ .../csi-baremetal_v1_deployment.yaml | 77 ++++--------------- charts/csi-baremetal-operator/values.yaml | 1 - pkg/controller.go | 2 +- 5 files changed, 33 insertions(+), 70 deletions(-) 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 d1e41d1b..944bd0fd 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -16,9 +16,6 @@ limitations under the License. package components -import ( - corev1 "k8s.io/api/core/v1" -) // Controller encapsulates logic for CSI controller component type Controller struct { @@ -27,5 +24,5 @@ type Controller struct { Sidecars map[string]*Sidecar `json:"sidecars,omitempty"` // +nullable // +optional - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + 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..ee52668a --- /dev/null +++ b/charts/csi-baremetal-deployment/templates/_helpers.tpl @@ -0,0 +1,18 @@ +{{- define "setResources" -}} + +requests: + {{- if .resources.requests.memory }} + memory: {{ .resources.requests.memory }} + {{- end }} + {{- if .resources.requests.cpu }} + cpu: {{ .resources.requests.cpu }} + {{- end }} +limits: + {{- if .resources.limits.memory }} + memory: {{ .resources.limits.memory }} + {{- end }} + {{- if .resources.limits.cpu }} + cpu: {{ .resources.limits.cpu }} + {{- end }} + +{{- end -}} \ No newline at end of file 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 f4a31ad0..0d94c932 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -29,63 +29,37 @@ spec: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} sidecars: - livenessprobe: + livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} resources: - requests: - memory: {{ .Values.driver.livenessProbe.resources.requests.memory }} - cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.livenessProbe.resources.limits.memory }} - cpu: {{ .Values.driver.livenessProbe.resources.limits.cpu }} - - csi-provisioner: + {{- include "setResources" .Values.driver.livenessProbe | nindent 12 }} + csi-provisioner: image: name: csi-provisioner tag: {{ .Values.driver.provisioner.image.tag }} resources: - requests: - memory: {{ .Values.driver.provisioner.resources.requests.memory }} - cpu: {{ .Values.driver.provisioner.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.provisioner.resources.limits.memory }} - cpu: {{ .Values.driver.provisioner.resources.limits.cpu }} - csi-resizer: + {{- include "setResources" .Values.driver.provisioner | nindent 12 }} + csi-resizer: image: name: csi-resizer tag: {{ .Values.driver.resizer.image.tag }} resources: - requests: - memory: {{ .Values.driver.resizer.resources.requests.memory }} - cpu: {{ .Values.driver.resizer.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.resizer.resources.limits.memory }} - cpu: {{ .Values.driver.resizer.resources.limits.cpu }} + {{- include "setResources" .Values.driver.resizer | nindent 12 }} node: driveMgr: image: name: csi-baremetal-{{ .Values.driver.drivemgr.type }} tag: {{ .Values.driver.drivemgr.image.tag | default .Values.image.tag }} resources: - requests: - memory: {{ .Values.driver.drivemgr.resources.requests.memory }} - cpu: {{ .Values.driver.drivemgr.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.drivemgr.resources.limits.memory }} - cpu: {{ .Values.driver.drivemgr.resources.limits.cpu }} + {{- include "setResources" .Values.driver.drivemgr | nindent 10 }} endpoint: {{ .Values.driver.drivemgr.grpc.server.endpoint }} image: name: csi-baremetal-node tag: {{ .Values.driver.node.image.tag | default .Values.image.tag }} resources: - requests: - memory: {{ .Values.driver.node.resources.requests.memory }} - cpu: {{ .Values.driver.node.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.node.resources.limits.memory }} - cpu: {{ .Values.driver.node.resources.limits.cpu }} + {{- include "setResources" .Values.driver.node | nindent 8 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -95,23 +69,13 @@ spec: name: csi-node-driver-registrar tag: {{ .Values.driver.nodeDriverRegistrar.image.tag }} resources: - requests: - memory: {{ .Values.driver.nodeDriverRegistrar.resources.requests.memory }} - cpu: {{ .Values.driver.nodeDriverRegistrar.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.nodeDriverRegistrar.resources.limits.memory }} - cpu: {{ .Values.driver.nodeDriverRegistrar.resources.limits.cpu }} + {{- include "setResources" .Values.driver.nodeDriverRegistrar | nindent 12 }} livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} resources: - requests: - memory: {{ .Values.driver.livenessProbe.resources.requests.memory }} - cpu: {{ .Values.driver.livenessProbe.resources.requests.cpu }} - limits: - memory: {{ .Values.driver.livenessProbe.resources.limits.memory }} - cpu: {{ .Values.driver.livenessProbe.resources.limits.cpu }} + {{- include "setResources" .Values.driver.livenessProbe | nindent 12 }} metrics: path: {{ .Values.driver.metrics.path }} port: {{ .Values.driver.metrics.port }} @@ -126,12 +90,7 @@ spec: name: csi-baremetal-scheduler-extender tag: {{ .Values.scheduler.image.tag | default .Values.image.tag }} resources: - requests: - memory: {{ .Values.scheduler.resources.requests.memory }} - cpu: {{ .Values.scheduler.resources.requests.cpu }} - limits: - memory: {{ .Values.scheduler.resources.limits.memory }} - cpu: {{ .Values.scheduler.resources.limits.cpu }} + {{- include "setResources" .Values.scheduler | nindent 6 }} log: format: {{ .Values.scheduler.log.format }} level: {{ .Values.scheduler.log.level }} @@ -145,12 +104,7 @@ spec: name: csi-baremetal-scheduler-patcher tag: {{ .Values.scheduler.patcher.image.tag | default .Values.image.tag }} resources: - requests: - memory: {{ .Values.scheduler.patcher.resources.requests.memory }} - cpu: {{ .Values.scheduler.patcher.resources.requests.cpu }} - limits: - memory: {{ .Values.scheduler.patcher.resources.limits.memory }} - cpu: {{ .Values.scheduler.patcher.resources.limits.cpu }} + {{- include "setResources" .Values.scheduler.patcher | nindent 8 }} interval: {{ .Values.scheduler.patcher.interval }} restoreOnShutdown: {{ .Values.scheduler.patcher.restore_on_shutdown }} configMapName: {{ .Values.scheduler.patcher.config_map_name }} @@ -162,12 +116,7 @@ spec: name: csi-baremetal-node-controller tag: {{ .Values.nodeController.image.tag | default .Values.image.tag }} resources: - requests: - memory: {{ .Values.nodeController.resources.requests.memory }} - cpu: {{ .Values.nodeController.resources.requests.cpu }} - limits: - memory: {{ .Values.nodeController.resources.limits.memory }} - cpu: {{ .Values.nodeController.resources.limits.cpu }} + {{- include "setResources" .Values.nodeController | nindent 6 }} log: format: {{ .Values.nodeController.log.format }} level: {{ .Values.nodeController.log.level }} diff --git a/charts/csi-baremetal-operator/values.yaml b/charts/csi-baremetal-operator/values.yaml index c7fec301..8c97bd87 100644 --- a/charts/csi-baremetal-operator/values.yaml +++ b/charts/csi-baremetal-operator/values.yaml @@ -10,7 +10,6 @@ image: pullPolicy: Always 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 diff --git a/pkg/controller.go b/pkg/controller.go index 0a1c2b01..4fb45432 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,7 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: *c.Resources, + Resources: corev1.ResourceRequirements(*c.Resources), }, { Name: constant.ProvisionerName, From f62b247124439b237a858b390e1cc5ccf6a096d0 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Mon, 25 Oct 2021 07:55:06 -0700 Subject: [PATCH 25/28] typo Signed-off-by: Anton Yurkov --- api/v1/components/controller.go | 1 - api/v1/components/scheduler.go | 1 + charts/csi-baremetal-deployment/templates/_helpers.tpl | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/components/controller.go b/api/v1/components/controller.go index 944bd0fd..1d7e66f5 100644 --- a/api/v1/components/controller.go +++ b/api/v1/components/controller.go @@ -16,7 +16,6 @@ limitations under the License. package components - // Controller encapsulates logic for CSI controller component type Controller struct { Image *Image `json:"image,omitempty"` diff --git a/api/v1/components/scheduler.go b/api/v1/components/scheduler.go index 237ea1e3..015b62bb 100644 --- a/api/v1/components/scheduler.go +++ b/api/v1/components/scheduler.go @@ -25,6 +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/charts/csi-baremetal-deployment/templates/_helpers.tpl b/charts/csi-baremetal-deployment/templates/_helpers.tpl index ee52668a..b1c09646 100644 --- a/charts/csi-baremetal-deployment/templates/_helpers.tpl +++ b/charts/csi-baremetal-deployment/templates/_helpers.tpl @@ -15,4 +15,4 @@ limits: cpu: {{ .resources.limits.cpu }} {{- end }} -{{- end -}} \ No newline at end of file +{{- end -}} From 3f5b0346e2de6bc78deb2d97ccc431b671772f22 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Thu, 28 Oct 2021 08:07:00 -0700 Subject: [PATCH 26/28] add setResource Signed-off-by: Anton Yurkov --- .../templates/_helpers.tpl | 44 +++++++++++++------ .../csi-baremetal_v1_deployment.yaml | 32 +++++--------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/charts/csi-baremetal-deployment/templates/_helpers.tpl b/charts/csi-baremetal-deployment/templates/_helpers.tpl index b1c09646..cd756b17 100644 --- a/charts/csi-baremetal-deployment/templates/_helpers.tpl +++ b/charts/csi-baremetal-deployment/templates/_helpers.tpl @@ -1,18 +1,34 @@ -{{- define "setResources" -}} +{{- define "setResources" }} -requests: - {{- if .resources.requests.memory }} - memory: {{ .resources.requests.memory }} - {{- end }} - {{- if .resources.requests.cpu }} - cpu: {{ .resources.requests.cpu }} - {{- end }} -limits: - {{- if .resources.limits.memory }} - memory: {{ .resources.limits.memory }} +{{- if .resources }} +{{- if or .resources.requests .resources.limits }} + +{{- $requestsValues := .resources.requests | values | compact }} +{{- $limitsValues := .resources.limits | values | compact }} + +{{- if or $requestsValues $limitsValues -}} +resources: + {{- if .resources.limits }} + limits: + {{- if .resources.limits.memory }} + memory: {{ .resources.limits.memory }} + {{- end }} + {{- if .resources.limits.cpu }} + cpu: {{ .resources.limits.cpu }} + {{- end }} {{- end }} - {{- if .resources.limits.cpu }} - cpu: {{ .resources.limits.cpu }} + + {{- if .resources.requests }} + requests: + {{- if .resources.requests.memory }} + memory: {{ .resources.requests.memory }} + {{- end }} + {{- if .resources.requests.cpu }} + cpu: {{ .resources.requests.cpu }} + {{- end }} {{- end }} +{{- end }} -{{- end -}} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file 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 170f8ece..ec339d34 100644 --- a/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml +++ b/charts/csi-baremetal-deployment/templates/csi-baremetal_v1_deployment.yaml @@ -27,7 +27,7 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} - resources: {{- toYaml .Values.driver.controller.resources | nindent 8}} + {{- include "setResources" .Values.driver.controller | nindent 6 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -36,33 +36,28 @@ spec: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} - resources: - {{- include "setResources" .Values.driver.livenessProbe | nindent 12 }} + {{- include "setResources" .Values.driver.livenessProbe | nindent 10 }} csi-provisioner: image: name: csi-provisioner tag: {{ .Values.driver.provisioner.image.tag }} - resources: - {{- include "setResources" .Values.driver.provisioner | nindent 12 }} + {{- include "setResources" .Values.driver.provisioner | nindent 10 }} csi-resizer: image: name: csi-resizer tag: {{ .Values.driver.resizer.image.tag }} - resources: - {{- include "setResources" .Values.driver.resizer | nindent 12 }} + {{- include "setResources" .Values.driver.resizer | nindent 10 }} 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 | nindent 10 }} + {{- include "setResources" .Values.driver.drivemgr | nindent 8 }} 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 | nindent 8 }} + {{- include "setResources" .Values.driver.node | nindent 6 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -71,14 +66,12 @@ spec: image: name: csi-node-driver-registrar tag: {{ .Values.driver.nodeDriverRegistrar.image.tag }} - resources: - {{- include "setResources" .Values.driver.nodeDriverRegistrar | nindent 12 }} + {{- include "setResources" .Values.driver.nodeDriverRegistrar | nindent 10 }} livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} - resources: - {{- include "setResources" .Values.driver.livenessProbe | nindent 12 }} + {{- include "setResources" .Values.driver.livenessProbe | nindent 10 }} metrics: path: {{ .Values.driver.metrics.path }} port: {{ .Values.driver.metrics.port }} @@ -92,8 +85,7 @@ spec: image: name: csi-baremetal-scheduler-extender tag: {{ .Values.scheduler.image.tag | default .Values.image.tag }} - resources: - {{- include "setResources" .Values.scheduler | nindent 6 }} + {{- include "setResources" .Values.scheduler | nindent 4 }} log: format: {{ .Values.scheduler.log.format }} level: {{ .Values.scheduler.log.level }} @@ -106,8 +98,7 @@ spec: image: name: csi-baremetal-scheduler-patcher tag: {{ .Values.scheduler.patcher.image.tag | default .Values.image.tag }} - resources: - {{- include "setResources" .Values.scheduler.patcher | nindent 8 }} + {{- include "setResources" .Values.scheduler.patcher | nindent 6 }} interval: {{ .Values.scheduler.patcher.interval }} restoreOnShutdown: {{ .Values.scheduler.patcher.restore_on_shutdown }} configMapName: {{ .Values.scheduler.patcher.config_map_name }} @@ -118,8 +109,7 @@ spec: image: name: csi-baremetal-node-controller tag: {{ .Values.nodeController.image.tag | default .Values.image.tag }} - resources: - {{- include "setResources" .Values.nodeController | nindent 6 }} + {{- include "setResources" .Values.nodeController | nindent 4 }} log: format: {{ .Values.nodeController.log.format }} level: {{ .Values.nodeController.log.level }} From c5391d2284a05613191790603aa3df58d712ae31 Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Fri, 29 Oct 2021 01:46:31 -0700 Subject: [PATCH 27/28] add new line Signed-off-by: Anton Yurkov --- charts/csi-baremetal-deployment/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/csi-baremetal-deployment/templates/_helpers.tpl b/charts/csi-baremetal-deployment/templates/_helpers.tpl index cd756b17..204fe3bd 100644 --- a/charts/csi-baremetal-deployment/templates/_helpers.tpl +++ b/charts/csi-baremetal-deployment/templates/_helpers.tpl @@ -31,4 +31,4 @@ resources: {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} From 4b7c5c39742e8e4b7827485b8ce53d080a7a89fe Mon Sep 17 00:00:00 2001 From: Anton Yurkov Date: Fri, 29 Oct 2021 09:46:59 -0700 Subject: [PATCH 28/28] add construct resource requirements Signed-off-by: Anton Yurkov --- .../templates/_helpers.tpl | 34 ++++++++----------- .../csi-baremetal_v1_deployment.yaml | 33 ++++++++++++------ pkg/common/common.go | 8 +++++ pkg/controller.go | 8 ++--- pkg/node/node_daemonset.go | 8 ++--- pkg/node_controller.go | 2 +- pkg/patcher/scheduler_patcher_vanilla.go | 2 +- pkg/scheduler_extender.go | 2 +- 8 files changed, 56 insertions(+), 41 deletions(-) diff --git a/charts/csi-baremetal-deployment/templates/_helpers.tpl b/charts/csi-baremetal-deployment/templates/_helpers.tpl index 204fe3bd..9beae825 100644 --- a/charts/csi-baremetal-deployment/templates/_helpers.tpl +++ b/charts/csi-baremetal-deployment/templates/_helpers.tpl @@ -1,31 +1,27 @@ {{- define "setResources" }} - {{- if .resources }} {{- if or .resources.requests .resources.limits }} {{- $requestsValues := .resources.requests | values | compact }} {{- $limitsValues := .resources.limits | values | compact }} -{{- if or $requestsValues $limitsValues -}} -resources: - {{- if .resources.limits }} - limits: - {{- if .resources.limits.memory }} - memory: {{ .resources.limits.memory }} - {{- end }} - {{- if .resources.limits.cpu }} - cpu: {{ .resources.limits.cpu }} - {{- end }} +{{- if $limitsValues }} +limits: + {{- if .resources.limits.memory }} + memory: {{ .resources.limits.memory }} + {{- end }} + {{- if .resources.limits.cpu }} + cpu: {{ .resources.limits.cpu }} {{- end }} +{{- end }} - {{- if .resources.requests }} - requests: - {{- if .resources.requests.memory }} - memory: {{ .resources.requests.memory }} - {{- end }} - {{- if .resources.requests.cpu }} - cpu: {{ .resources.requests.cpu }} - {{- end }} +{{- if $requestsValues }} +requests: + {{- if .resources.requests.memory }} + memory: {{ .resources.requests.memory }} + {{- end }} + {{- if .resources.requests.cpu }} + cpu: {{ .resources.requests.cpu }} {{- 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 cf1eb971..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,7 +24,8 @@ spec: image: name: csi-baremetal-controller tag: {{ .Values.driver.controller.image.tag | default .Values.image.tag }} - {{- include "setResources" .Values.driver.controller | nindent 6 }} + resources: + {{- include "setResources" .Values.driver.controller | indent 8 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -33,28 +34,33 @@ spec: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} - {{- include "setResources" .Values.driver.livenessProbe | nindent 10 }} + resources: + {{- include "setResources" .Values.driver.livenessProbe | indent 12 }} csi-provisioner: image: name: csi-provisioner tag: {{ .Values.driver.provisioner.image.tag }} - {{- include "setResources" .Values.driver.provisioner | nindent 10 }} + resources: + {{- include "setResources" .Values.driver.provisioner | indent 12 }} csi-resizer: image: name: csi-resizer tag: {{ .Values.driver.resizer.image.tag }} - {{- include "setResources" .Values.driver.resizer | nindent 10 }} + 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 }} - {{- include "setResources" .Values.driver.drivemgr | nindent 8 }} + 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 }} - {{- include "setResources" .Values.driver.node | nindent 6 }} + resources: + {{- include "setResources" .Values.driver.node | indent 8 }} log: format: {{ .Values.driver.log.format }} level: {{ .Values.driver.log.level }} @@ -63,12 +69,14 @@ spec: image: name: csi-node-driver-registrar tag: {{ .Values.driver.nodeDriverRegistrar.image.tag }} - {{- include "setResources" .Values.driver.nodeDriverRegistrar | nindent 10 }} + resources: + {{- include "setResources" .Values.driver.nodeDriverRegistrar | indent 12 }} livenessprobe: image: name: livenessprobe tag: {{ .Values.driver.livenessProbe.image.tag }} - {{- include "setResources" .Values.driver.livenessProbe | nindent 10 }} + resources: + {{- include "setResources" .Values.driver.livenessProbe | indent 12 }} metrics: path: {{ .Values.driver.metrics.path }} port: {{ .Values.driver.metrics.port }} @@ -82,7 +90,8 @@ spec: image: name: csi-baremetal-scheduler-extender tag: {{ .Values.scheduler.image.tag | default .Values.image.tag }} - {{- include "setResources" .Values.scheduler | nindent 4 }} + resources: + {{- include "setResources" .Values.scheduler | indent 6 }} log: format: {{ .Values.scheduler.log.format }} level: {{ .Values.scheduler.log.level }} @@ -95,7 +104,8 @@ spec: image: name: csi-baremetal-scheduler-patcher tag: {{ .Values.scheduler.patcher.image.tag | default .Values.image.tag }} - {{- include "setResources" .Values.scheduler.patcher | nindent 6 }} + 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 }} @@ -106,7 +116,8 @@ spec: image: name: csi-baremetal-node-controller tag: {{ .Values.nodeController.image.tag | default .Values.image.tag }} - {{- include "setResources" .Values.nodeController | nindent 4 }} + resources: + {{- include "setResources" .Values.nodeController | indent 6 }} log: format: {{ .Values.nodeController.log.format }} level: {{ .Values.nodeController.log.level }} 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 cd7357b8..015b6558 100644 --- a/pkg/controller.go +++ b/pkg/controller.go @@ -184,7 +184,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*c.Resources), + Resources: common.ConstructResourceRequirements(c.Resources), }, { Name: constant.ProvisionerName, @@ -206,7 +206,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*provisioner.Resources), + Resources: common.ConstructResourceRequirements(provisioner.Resources), }, { Name: constant.ResizerName, @@ -227,7 +227,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*resizer.Resources), + Resources: common.ConstructResourceRequirements(resizer.Resources), }, { Name: constant.LivenessProbeName, @@ -243,7 +243,7 @@ func createControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Contain }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*liveness.Resources), + Resources: common.ConstructResourceRequirements(liveness.Resources), }, } } diff --git a/pkg/node/node_daemonset.go b/pkg/node/node_daemonset.go index 12d2fef4..0e2d1c1e 100644 --- a/pkg/node/node_daemonset.go +++ b/pkg/node/node_daemonset.go @@ -204,7 +204,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*lp.Resources), + Resources: common.ConstructResourceRequirements(lp.Resources), }, { Name: constant.DriverRegistrarName, @@ -228,7 +228,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*dr.Resources), + Resources: common.ConstructResourceRequirements(dr.Resources), }, { Name: "node", @@ -287,7 +287,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: nodeMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*node.Resources), + Resources: common.ConstructResourceRequirements(node.Resources), }, { Name: "drivemgr", @@ -304,7 +304,7 @@ func createNodeContainers(csi *csibaremetalv1.Deployment, platform *PlatformDesc VolumeMounts: driveMgrMounts, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*driveMgr.Resources), + Resources: common.ConstructResourceRequirements(driveMgr.Resources), }, } } diff --git a/pkg/node_controller.go b/pkg/node_controller.go index 3a683dd6..0818679b 100644 --- a/pkg/node_controller.go +++ b/pkg/node_controller.go @@ -114,7 +114,7 @@ func createNodeControllerContainers(csi *csibaremetalv1.Deployment) []corev1.Con TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: []corev1.VolumeMount{constant.CrashMountVolume}, - Resources: corev1.ResourceRequirements(*resources), + Resources: common.ConstructResourceRequirements(resources), }, } } diff --git a/pkg/patcher/scheduler_patcher_vanilla.go b/pkg/patcher/scheduler_patcher_vanilla.go index c4112730..02e8718b 100644 --- a/pkg/patcher/scheduler_patcher_vanilla.go +++ b/pkg/patcher/scheduler_patcher_vanilla.go @@ -243,7 +243,7 @@ func (p patcherConfiguration) createPatcherContainers() []corev1.Container { }, TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, - Resources: corev1.ResourceRequirements(*p.resources), + Resources: common.ConstructResourceRequirements(p.resources), }, } } diff --git a/pkg/scheduler_extender.go b/pkg/scheduler_extender.go index 5cbfb5f5..6b22f01c 100644 --- a/pkg/scheduler_extender.go +++ b/pkg/scheduler_extender.go @@ -176,7 +176,7 @@ func createExtenderContainers(csi *csibaremetalv1.Deployment, isPatchingEnabled TerminationMessagePath: constant.TerminationMessagePath, TerminationMessagePolicy: constant.TerminationMessagePolicy, VolumeMounts: volumeMounts, - Resources: corev1.ResourceRequirements(*csi.Spec.Scheduler.Resources), + Resources: common.ConstructResourceRequirements(csi.Spec.Scheduler.Resources), }, } }