Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v1alpha1/ibmobjectcsi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ type IBMObjectCSINodeSpec struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

Resources ResourcesSpec `json:"resources,omitempty"`

// +kubebuilder:validation:Optional
MaxVolumesPerNode string `json:"maxVolumesPerNode,omitempty"`
}

// IBMObjectCSIControllerSpec defines the desired state of IBMObjectCSIController
Expand Down
14 changes: 10 additions & 4 deletions controllers/ibmobjectcsi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,15 @@ func (r *IBMObjectCSIReconciler) handleConfigMapReconcile(ctx context.Context, r
CSINodeMemoryRequest := configMap.Data["CSINodeMemoryRequest"]
CSINodeCPULimit := configMap.Data["CSINodeCPULimit"]
CSINodeMemoryLimit := configMap.Data["CSINodeMemoryLimit"]
CSINodeMaxVolumesPerNode := configMap.Data["CSINodeMaxVolumesPerNode"]

reqLogger.Info("The resource requests and limits fetched from configmap",
"CSINodeCPURequest", CSINodeCPURequest, "CSINodeMemoryRequest", CSINodeMemoryRequest,
"CSINodeCPULimit", CSINodeCPULimit, "CSINodeMemoryLimit", CSINodeMemoryLimit)
reqLogger.Info("Configruration fetched from configmap",
"CSINodeCPURequest", CSINodeCPURequest,
"CSINodeMemoryRequest", CSINodeMemoryRequest,
"CSINodeCPULimit", CSINodeCPULimit,
"CSINodeMemoryLimit", CSINodeMemoryLimit,
"CSINodeMaxVolumesPerNode", CSINodeMaxVolumesPerNode,
)

// Fetch the IBMObjectCSI instance
instance := &objectdriverv1alpha1.IBMObjectCSI{}
Expand All @@ -245,9 +250,10 @@ func (r *IBMObjectCSIReconciler) handleConfigMapReconcile(ctx context.Context, r
instance.Spec.Node.Resources.Requests.Memory = CSINodeMemoryRequest
instance.Spec.Node.Resources.Limits.CPU = CSINodeCPULimit
instance.Spec.Node.Resources.Limits.Memory = CSINodeMemoryLimit
instance.Spec.Node.MaxVolumesPerNode = CSINodeMaxVolumesPerNode

// Update the instance in the Kubernetes API server
reqLogger.Info("Updating IBMObjectCSI CR with resource requests and limits for Node pods")
reqLogger.Info("Updating IBMObjectCSI CR with ConfigMap values")
err = r.Update(ctx, instance)
if err != nil {
reqLogger.Error(err, "Failed to update IBMObjectCSI instance with ConfigMap values")
Expand Down
11 changes: 10 additions & 1 deletion controllers/syncer/csi_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,23 @@ func envVarFromField(name, fieldPath string) corev1.EnvVar {
func (s *csiNodeSyncer) getEnvFor(name string) []corev1.EnvVar {
switch name {
case constants.NodeContainerName:
return []corev1.EnvVar{
envVars := []corev1.EnvVar{
{
Name: "CSI_ENDPOINT",
Value: constants.CSINodeEndpoint,
},
envVarFromField("KUBE_NODE_NAME", "spec.nodeName"),
}

if s.driver.Spec.Node.MaxVolumesPerNode != "" {
envVars = append(envVars, corev1.EnvVar{
Name: "MAX_VOLUMES_PER_NODE",
Value: s.driver.Spec.Node.MaxVolumesPerNode,
})
}

return envVars

case constants.CSINodeDriverRegistrar:
return []corev1.EnvVar{
{
Expand Down