diff --git a/cli/k8s_client/types.go b/cli/k8s_client/types.go index 649980d56..3381d0d2f 100644 --- a/cli/k8s_client/types.go +++ b/cli/k8s_client/types.go @@ -16,6 +16,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/version" + netappv1 "github.com/netapp/trident/operator/controllers/orchestrator/apis/netapp/v1" versionutils "github.com/netapp/trident/utils/version" ) @@ -168,27 +169,29 @@ type DeploymentYAMLArguments struct { } type DaemonsetYAMLArguments struct { - DaemonsetName string `json:"daemonsetName"` - TridentImage string `json:"tridentImage"` - ImageRegistry string `json:"imageRegistry"` - KubeletDir string `json:"kubeletDir"` - LogFormat string `json:"logFormat"` - LogLevel string `json:"logLevel"` - LogWorkflows string `json:"logWorkflows"` - LogLayers string `json:"logLayers"` - ProbePort string `json:"probePort"` - ImagePullSecrets []string `json:"imagePullSecrets"` - Labels map[string]string `json:"labels"` - ControllingCRDetails map[string]string `json:"controllingCRDetails"` - EnableForceDetach bool `json:"enableForceDetach"` - DisableAuditLog bool `json:"disableAuditLog"` - Debug bool `json:"debug"` - Version *versionutils.Version `json:"version"` - HTTPRequestTimeout string `json:"httpRequestTimeout"` - NodeSelector map[string]string `json:"nodeSelector"` - Tolerations []map[string]string `json:"tolerations"` - ServiceAccountName string `json:"serviceAccountName"` - ImagePullPolicy string `json:"imagePullPolicy"` + DaemonsetName string `json:"daemonsetName"` + TridentImage string `json:"tridentImage"` + ImageRegistry string `json:"imageRegistry"` + KubeletDir string `json:"kubeletDir"` + LogFormat string `json:"logFormat"` + LogLevel string `json:"logLevel"` + LogWorkflows string `json:"logWorkflows"` + LogLayers string `json:"logLayers"` + ProbePort string `json:"probePort"` + ImagePullSecrets []string `json:"imagePullSecrets"` + Labels map[string]string `json:"labels"` + ControllingCRDetails map[string]string `json:"controllingCRDetails"` + EnableForceDetach bool `json:"enableForceDetach"` + DisableAuditLog bool `json:"disableAuditLog"` + Debug bool `json:"debug"` + Version *versionutils.Version `json:"version"` + HTTPRequestTimeout string `json:"httpRequestTimeout"` + NodeSelector map[string]string `json:"nodeSelector"` + Tolerations []map[string]string `json:"tolerations"` + TridentResourceSpec netappv1.ResourceSpec `json:"tridentResourceSpec"` + RegistrarResourceSpec netappv1.ResourceSpec `json:"registrarSpec"` + ServiceAccountName string `json:"serviceAccountName"` + ImagePullPolicy string `json:"imagePullPolicy"` } type TridentVersionPodYAMLArguments struct { diff --git a/cli/k8s_client/yaml_factory.go b/cli/k8s_client/yaml_factory.go index 1ef9c783a..7da420e33 100644 --- a/cli/k8s_client/yaml_factory.go +++ b/cli/k8s_client/yaml_factory.go @@ -9,7 +9,11 @@ import ( commonconfig "github.com/netapp/trident/config" . "github.com/netapp/trident/logging" + netappv1 "github.com/netapp/trident/operator/controllers/orchestrator/apis/netapp/v1" "github.com/netapp/trident/utils" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + k8syaml "sigs.k8s.io/yaml" ) const ( @@ -726,6 +730,25 @@ func GetCSIDaemonSetYAMLWindows(args *DaemonsetYAMLArguments) string { } } + defaultRegistrarResourceSpec := netappv1.ResourceSpec{Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceMemory: resource.MustParse("100Mi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("10m"), + v1.ResourceMemory: resource.MustParse("40Mi"), + }, + }} + defaultTridentResourceSpec := netappv1.ResourceSpec{Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceMemory: resource.MustParse("400Mi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("10m"), + v1.ResourceMemory: resource.MustParse("20Mi"), + }, + }} + kubeletDir := strings.TrimRight(args.KubeletDir, "/") daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{TRIDENT_IMAGE}", args.TridentImage) daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{DAEMONSET_NAME}", args.DaemonsetName) @@ -745,6 +768,10 @@ func GetCSIDaemonSetYAMLWindows(args *DaemonsetYAMLArguments) string { daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{IMAGE_PULL_POLICY}", args.ImagePullPolicy) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector)) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "NODE_TOLERATIONS", constructTolerations(tolerations)) + daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "REGISTRAR_RESOURCE_CLAIMS", constructResourceClaim( + "DsRegistrar", args.RegistrarResourceSpec, defaultRegistrarResourceSpec)) + daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "TRIDENT_RESOURCE_CLAIMS", constructResourceClaim( + "DsTrident", args.TridentResourceSpec, defaultTridentResourceSpec)) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "LABELS", constructLabels(args.Labels)) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails)) // Log before secrets are inserted into YAML. @@ -799,6 +826,13 @@ func GetCSIDaemonSetYAMLLinux(args *DaemonsetYAMLArguments) string { } } + defaultRegistrarResourceSpec := netappv1.ResourceSpec{Resources: v1.ResourceRequirements{ + Requests: v1.ResourceList{}, + }} + defaultTridentResourceSpec := netappv1.ResourceSpec{Resources: v1.ResourceRequirements{ + Requests: v1.ResourceList{}, + }} + kubeletDir := strings.TrimRight(args.KubeletDir, "/") daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{TRIDENT_IMAGE}", args.TridentImage) daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{DAEMONSET_NAME}", args.DaemonsetName) @@ -819,6 +853,10 @@ func GetCSIDaemonSetYAMLLinux(args *DaemonsetYAMLArguments) string { daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{IMAGE_PULL_POLICY}", args.ImagePullPolicy) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector)) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "NODE_TOLERATIONS", constructTolerations(tolerations)) + daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "REGISTRAR_RESOURCE_CLAIMS", constructResourceClaim( + "DsRegistrar", args.RegistrarResourceSpec, defaultRegistrarResourceSpec)) + daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "TRIDENT_RESOURCE_CLAIMS", constructResourceClaim( + "DsTrident", args.TridentResourceSpec, defaultTridentResourceSpec)) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "LABELS", constructLabels(args.Labels)) daemonSetYAML = replaceMultilineYAMLTag(daemonSetYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails)) @@ -907,6 +945,7 @@ spec: failureThreshold: 5 initialDelaySeconds: 10 periodSeconds: 10 + {TRIDENT_RESOURCE_CLAIMS} env: - name: KUBE_NODE_NAME valueFrom: @@ -948,6 +987,7 @@ spec: - "--v={SIDECAR_LOG_LEVEL}" - "--csi-address=$(ADDRESS)" - "--kubelet-registration-path=$(REGISTRATION_PATH)" + {REGISTRAR_RESOURCE_CLAIMS} env: - name: ADDRESS value: /plugin/csi.sock @@ -1137,12 +1177,7 @@ spec: mountPath: \\.\pipe\csi-proxy-filesystem-v1beta1 - name: csi-proxy-smb-pipe-v1beta1 mountPath: \\.\pipe\csi-proxy-smb-v1beta1 - resources: - limits: - memory: 400Mi - requests: - cpu: 10m - memory: 20Mi + {TRIDENT_RESOURCE_CLAIMS} - name: node-driver-registrar image: {CSI_SIDECAR_REGISTRY}/csi-node-driver-registrar:v2.8.0 imagePullPolicy: {IMAGE_PULL_POLICY} @@ -1174,12 +1209,7 @@ spec: mountPath: C:\csi - name: registration-dir mountPath: C:\registration - resources: - limits: - memory: 200Mi - requests: - cpu: 10m - memory: 20Mi + {REGISTRAR_RESOURCE_CLAIMS} - name: liveness-probe volumeMounts: - mountPath: C:\csi @@ -1193,12 +1223,6 @@ spec: env: - name: CSI_ENDPOINT value: unix:///csi/csi.sock - resources: - limits: - memory: 100Mi - requests: - cpu: 10m - memory: 40Mi affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -2509,6 +2533,31 @@ func constructNodeSelector(nodeLabels map[string]string) string { return nodeSelector } +func constructResourceClaim( + containerName string, resourceClaim netappv1.ResourceSpec, defaultResourceClaim netappv1.ResourceSpec, +) string { + userData, err := k8syaml.Marshal(resourceClaim) + if err != nil { + Log().WithField("container", containerName).Errorf("Cannot marshal resource claim: %s", err) + return "" + } + + if err := k8syaml.Unmarshal(userData, &defaultResourceClaim); err != nil { + Log().WithField("container", containerName).Errorf( + "Cannot unmarshal provided resource claim into default resource claim: %s", err, + ) + return "" + } + mergedData, err := k8syaml.Marshal(defaultResourceClaim) + + if err != nil { + Log().WithField("container", containerName).Errorf("Cannot marshal resource claim: %s", err) + return "" + } + + return string(mergedData) +} + func constructTolerations(tolerations []map[string]string) string { var tolerationsString string diff --git a/cli/k8s_client/yaml_factory_test.go b/cli/k8s_client/yaml_factory_test.go index 1c0f90d4e..9efab5949 100644 --- a/cli/k8s_client/yaml_factory_test.go +++ b/cli/k8s_client/yaml_factory_test.go @@ -15,9 +15,11 @@ import ( pspv1beta1 "k8s.io/api/policy/v1beta1" csiv1 "k8s.io/api/storage/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/netapp/trident/config" + netappv1 "github.com/netapp/trident/operator/controllers/orchestrator/apis/netapp/v1" versionutils "github.com/netapp/trident/utils/version" ) @@ -652,6 +654,43 @@ func TestGetCSIDaemonSetYAMLLinux_NodeSelectors(t *testing.T) { fmt.Sprintf("expected nodeSelector in final YAML: %s", yamlData)) } +func TestGetCSIDaemonSetYAMLLinux_ResourceClaims(t *testing.T) { + daemonsetArgs := &DaemonsetYAMLArguments{ + RegistrarResourceSpec: netappv1.ResourceSpec{}, + TridentResourceSpec: netappv1.ResourceSpec{ + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceMemory: resource.MustParse("125Mi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("50m"), + v1.ResourceMemory: resource.MustParse("50Mi"), + }, + }, + }, + } + expectedRegistrarResourceClaimString := "resources: {}\n" + expectedTridentResourceClaimString := ` + resources: + limits: + memory: 125Mi + requests: + cpu: 50m + memory: 50Mi +` + + yamlData := GetCSIDaemonSetYAMLLinux(daemonsetArgs) + _, err := yaml.YAMLToJSON([]byte(yamlData)) + if err != nil { + t.Fatalf("expected valid YAML, got %s", yamlData) + } + assert.Contains(t, yamlData, expectedRegistrarResourceClaimString, + fmt.Sprintf("expected empty registrar resource claims in final YAML: %s", yamlData)) + + assert.Contains(t, yamlData, expectedTridentResourceClaimString, + fmt.Sprintf("expected trident resource claims in final YAML: %s", yamlData)) +} + func TestGetCSIDaemonSetYAMLLinux_Tolerations(t *testing.T) { daemonsetArgs := &DaemonsetYAMLArguments{ Tolerations: []map[string]string{ @@ -800,6 +839,56 @@ func TestGetCSIDaemonSetYAMLWindowsImagePullPolicy(t *testing.T) { } } +func TestGetCSIDaemonSetYAMWindows_ResourceClaims(t *testing.T) { + versions := []string{"1.26.0"} + registrarResourceSpec := netappv1.ResourceSpec{} + tridentResourceSpec := netappv1.ResourceSpec{ + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceMemory: resource.MustParse("125Mi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("50m"), + }, + }, + } + + expectedRegistrarResourceClaimString := ` + resources: + limits: + memory: 100Mi + requests: + cpu: 10m + memory: 40Mi +` + expectedTridentResourceClaimString := ` + resources: + limits: + memory: 125Mi + requests: + cpu: 50m + memory: 20Mi +` + for _, versionString := range versions { + version := versionutils.MustParseSemantic(versionString) + daemonsetArgs := &DaemonsetYAMLArguments{ + Version: version, + RegistrarResourceSpec: registrarResourceSpec, + TridentResourceSpec: tridentResourceSpec, + } + yamlData := GetCSIDaemonSetYAMLWindows(daemonsetArgs) + _, err := yaml.YAMLToJSON([]byte(yamlData)) + if err != nil { + t.Fatalf("expected valid YAML, got %s", yamlData) + } + assert.Contains(t, yamlData, expectedRegistrarResourceClaimString, + fmt.Sprintf("expected empty registrar resource claims in final YAML: %s", yamlData)) + + assert.Contains(t, yamlData, expectedTridentResourceClaimString, + fmt.Sprintf("expected trident resource claims in final YAML: %s", yamlData)) + } +} + func TestConstructNodeSelector(t *testing.T) { nodeSelMap := map[string]string{"node-label-name": "master"} @@ -809,6 +898,54 @@ func TestConstructNodeSelector(t *testing.T) { assert.Equal(t, expectedNodeSelString, result) } +func TestConstructResourceClaim(t *testing.T) { + defaultResourceClaim := netappv1.ResourceSpec{ + Resources: v1.ResourceRequirements{}, + } + resourceClaim := netappv1.ResourceSpec{ + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("100m"), + v1.ResourceMemory: resource.MustParse("50Mi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("20m"), + v1.ResourceMemory: resource.MustParse("20Mi"), + }, + }, + } + + expectedResourceClaimString := `resources: + limits: + cpu: 100m + memory: 50Mi + requests: + cpu: 20m + memory: 20Mi +` + + result := constructResourceClaim("test", resourceClaim, defaultResourceClaim) + assert.Equal(t, expectedResourceClaimString, result) + + resourceClaim = netappv1.ResourceSpec{ + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("100m"), + }, + }, + } + + expectedResourceClaimString = "resources:\n limits:\n cpu: 100m\n" + result = constructResourceClaim("test", resourceClaim, defaultResourceClaim) + assert.Equal(t, expectedResourceClaimString, result) + + resourceClaim = netappv1.ResourceSpec{} + + expectedResourceClaimString = "resources: {}\n" + result = constructResourceClaim("test", resourceClaim, defaultResourceClaim) + assert.Equal(t, expectedResourceClaimString, result) +} + func TestGetNamespaceYAML(t *testing.T) { expected := v1.Namespace{ TypeMeta: metav1.TypeMeta{ diff --git a/go.mod b/go.mod index b17afed7e..dfbefa65b 100755 --- a/go.mod +++ b/go.mod @@ -55,6 +55,7 @@ require ( k8s.io/apimachinery v0.27.3 // github.com/kubernetes/apimachinery k8s.io/client-go v0.27.3 // github.com/kubernetes/client-go k8s.io/mount-utils v0.27.3 // github.com/kubernetes/mount-utils + sigs.k8s.io/yaml v1.3.0 ) require ( @@ -132,5 +133,4 @@ require ( k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/operator/controllers/orchestrator/apis/netapp/v1/types.go b/operator/controllers/orchestrator/apis/netapp/v1/types.go index ddb29ad6c..364f3d2c9 100644 --- a/operator/controllers/orchestrator/apis/netapp/v1/types.go +++ b/operator/controllers/orchestrator/apis/netapp/v1/types.go @@ -5,6 +5,7 @@ package v1 import ( "fmt" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -33,35 +34,41 @@ type TridentOrchestratorList struct { // TridentOrchestratorSpec defines the desired state of TridentOrchestrator type TridentOrchestratorSpec struct { - EnableForceDetach bool `json:"enableForceDetach"` - DisableAuditLog *bool `json:"disableAuditLog"` - Namespace string `json:"namespace"` - IPv6 bool `json:"IPv6,omitempty"` - K8sTimeout int `json:"k8sTimeout,omitempty"` - HTTPRequestTimeout string `json:"httpRequestTimeout,omitempty"` - SilenceAutosupport bool `json:"silenceAutosupport,omitempty"` - AutosupportImage string `json:"autosupportImage,omitempty"` - AutosupportProxy string `json:"autosupportProxy,omitempty"` - AutosupportSerialNumber string `json:"autosupportSerialNumber,omitempty"` - AutosupportHostname string `json:"autosupportHostname,omitempty"` - Uninstall bool `json:"uninstall,omitempty"` - LogFormat string `json:"logFormat,omitempty"` - LogLevel string `json:"logLevel,omitempty"` - Debug bool `json:"debug,omitempty"` - LogWorkflows string `json:"logWorkflows,omitempty"` - LogLayers string `json:"logLayers,omitempty"` - ProbePort *int64 `json:"probePort,omitempty"` - TridentImage string `json:"tridentImage,omitempty"` - ImageRegistry string `json:"imageRegistry,omitempty"` - KubeletDir string `json:"kubeletDir,omitempty"` - Wipeout []string `json:"wipeout,omitempty"` - ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` - ControllerPluginNodeSelector map[string]string `json:"controllerPluginNodeSelector,omitempty"` - ControllerPluginTolerations []Toleration `json:"controllerPluginTolerations,omitempty"` - NodePluginNodeSelector map[string]string `json:"nodePluginNodeSelector,omitempty"` - NodePluginTolerations []Toleration `json:"nodePluginTolerations,omitempty"` - Windows bool `json:"windows,omitempty"` - ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + EnableForceDetach bool `json:"enableForceDetach"` + DisableAuditLog *bool `json:"disableAuditLog"` + Namespace string `json:"namespace"` + IPv6 bool `json:"IPv6,omitempty"` + K8sTimeout int `json:"k8sTimeout,omitempty"` + HTTPRequestTimeout string `json:"httpRequestTimeout,omitempty"` + SilenceAutosupport bool `json:"silenceAutosupport,omitempty"` + AutosupportImage string `json:"autosupportImage,omitempty"` + AutosupportProxy string `json:"autosupportProxy,omitempty"` + AutosupportSerialNumber string `json:"autosupportSerialNumber,omitempty"` + AutosupportHostname string `json:"autosupportHostname,omitempty"` + Uninstall bool `json:"uninstall,omitempty"` + LogFormat string `json:"logFormat,omitempty"` + LogLevel string `json:"logLevel,omitempty"` + Debug bool `json:"debug,omitempty"` + LogWorkflows string `json:"logWorkflows,omitempty"` + LogLayers string `json:"logLayers,omitempty"` + ProbePort *int64 `json:"probePort,omitempty"` + TridentImage string `json:"tridentImage,omitempty"` + ImageRegistry string `json:"imageRegistry,omitempty"` + KubeletDir string `json:"kubeletDir,omitempty"` + Wipeout []string `json:"wipeout,omitempty"` + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + ControllerPluginNodeSelector map[string]string `json:"controllerPluginNodeSelector,omitempty"` + ControllerPluginTolerations []Toleration `json:"controllerPluginTolerations,omitempty"` + NodePluginNodeSelector map[string]string `json:"nodePluginNodeSelector,omitempty"` + NodePluginTolerations []Toleration `json:"nodePluginTolerations,omitempty"` + DsTridentResources v1.ResourceRequirements `json:"dsTridentResources,omitempty"` + DsRegistrarResources v1.ResourceRequirements `json:"dsRegistrarResources,omitempty"` + Windows bool `json:"windows,omitempty"` + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` +} + +type ResourceSpec struct { + Resources v1.ResourceRequirements `json:"resources,omitempty"` } // Toleration @@ -109,27 +116,29 @@ type TridentOrchestratorStatus struct { } type TridentOrchestratorSpecValues struct { - EnableForceDetach string `json:"enableForceDetach"` - DisableAuditLog string `json:"disableAuditLog"` - IPv6 string `json:"IPv6"` - SilenceAutosupport string `json:"silenceAutosupport"` - AutosupportImage string `json:"autosupportImage"` - AutosupportProxy string `json:"autosupportProxy"` - AutosupportSerialNumber string `json:"autosupportSerialNumber"` - AutosupportHostname string `json:"autosupportHostname"` - K8sTimeout string `json:"k8sTimeout"` - HTTPRequestTimeout string `json:"httpRequestTimeout"` - LogFormat string `json:"logFormat"` - LogLevel string `json:"logLevel"` - Debug string `json:"debug"` - LogWorkflows string `json:"logWorkflows"` - LogLayers string `json:"logLayers"` - ProbePort string `json:"probePort"` - TridentImage string `json:"tridentImage"` - ImageRegistry string `json:"imageRegistry"` - KubeletDir string `json:"kubeletDir"` - ImagePullSecrets []string `json:"imagePullSecrets"` - NodePluginNodeSelector map[string]string `json:"nodePluginNodeSelector,omitempty"` - NodePluginTolerations []Toleration `json:"nodePluginTolerations,omitempty"` - ImagePullPolicy string `json:"imagePullPolicy"` + EnableForceDetach string `json:"enableForceDetach"` + DisableAuditLog string `json:"disableAuditLog"` + IPv6 string `json:"IPv6"` + SilenceAutosupport string `json:"silenceAutosupport"` + AutosupportImage string `json:"autosupportImage"` + AutosupportProxy string `json:"autosupportProxy"` + AutosupportSerialNumber string `json:"autosupportSerialNumber"` + AutosupportHostname string `json:"autosupportHostname"` + K8sTimeout string `json:"k8sTimeout"` + HTTPRequestTimeout string `json:"httpRequestTimeout"` + LogFormat string `json:"logFormat"` + LogLevel string `json:"logLevel"` + Debug string `json:"debug"` + LogWorkflows string `json:"logWorkflows"` + LogLayers string `json:"logLayers"` + ProbePort string `json:"probePort"` + TridentImage string `json:"tridentImage"` + ImageRegistry string `json:"imageRegistry"` + KubeletDir string `json:"kubeletDir"` + ImagePullSecrets []string `json:"imagePullSecrets"` + NodePluginNodeSelector map[string]string `json:"nodePluginNodeSelector,omitempty"` + NodePluginTolerations []Toleration `json:"nodePluginTolerations,omitempty"` + DsRegistrarResources v1.ResourceRequirements `json:"dsRegistrarResources,omitempty"` + DsTridentResources v1.ResourceRequirements `json:"dsTridentResources,omitempty"` + ImagePullPolicy string `json:"imagePullPolicy"` } diff --git a/operator/controllers/orchestrator/installer/installer.go b/operator/controllers/orchestrator/installer/installer.go index 9ce293f4a..a3b392c37 100644 --- a/operator/controllers/orchestrator/installer/installer.go +++ b/operator/controllers/orchestrator/installer/installer.go @@ -86,6 +86,8 @@ var ( controllerPluginTolerations []netappv1.Toleration nodePluginNodeSelector map[string]string nodePluginTolerations []netappv1.Toleration + tridentResourceSpec netappv1.ResourceSpec + registrarResourceSpec netappv1.ResourceSpec CRDnames = []string{ ActionMirrorUpdateCRDName, @@ -373,6 +375,8 @@ func (i *Installer) setInstallationParams( appLabel = TridentCSILabel appLabelKey = TridentCSILabelKey appLabelValue = TridentCSILabelValue + tridentResourceSpec = netappv1.ResourceSpec{Resources: cr.Spec.DsTridentResources} + registrarResourceSpec = netappv1.ResourceSpec{Resources: cr.Spec.DsRegistrarResources} if cr.Spec.ControllerPluginNodeSelector != nil { controllerPluginNodeSelector = cr.Spec.ControllerPluginNodeSelector @@ -610,6 +614,8 @@ func (i *Installer) InstallOrPatchTrident( ImagePullSecrets: imagePullSecrets, NodePluginNodeSelector: nodePluginNodeSelector, NodePluginTolerations: nodePluginTolerations, + DsRegistrarResources: registrarResourceSpec.Resources, + DsTridentResources: tridentResourceSpec.Resources, ImagePullPolicy: imagePullPolicy, } @@ -1458,27 +1464,29 @@ func (i *Installer) createOrPatchTridentDaemonSet( } daemonSetArgs := &k8sclient.DaemonsetYAMLArguments{ - DaemonsetName: getDaemonSetName(isWindows), - TridentImage: tridentImage, - ImageRegistry: imageRegistry, - KubeletDir: kubeletDir, - LogFormat: logFormat, - DisableAuditLog: disableAuditLog, - Debug: debug, - LogLevel: determineLogLevel(), - LogWorkflows: logWorkflows, - LogLayers: logLayers, - ProbePort: probePort, - ImagePullSecrets: imagePullSecrets, - Labels: labels, - ControllingCRDetails: controllingCRDetails, - EnableForceDetach: enableForceDetach, - Version: i.client.ServerVersion(), - HTTPRequestTimeout: httpTimeout, - NodeSelector: nodePluginNodeSelector, - Tolerations: tolerations, - ServiceAccountName: serviceAccountName, - ImagePullPolicy: imagePullPolicy, + DaemonsetName: getDaemonSetName(isWindows), + TridentImage: tridentImage, + ImageRegistry: imageRegistry, + KubeletDir: kubeletDir, + LogFormat: logFormat, + DisableAuditLog: disableAuditLog, + Debug: debug, + LogLevel: determineLogLevel(), + LogWorkflows: logWorkflows, + LogLayers: logLayers, + ProbePort: probePort, + ImagePullSecrets: imagePullSecrets, + Labels: labels, + ControllingCRDetails: controllingCRDetails, + EnableForceDetach: enableForceDetach, + Version: i.client.ServerVersion(), + HTTPRequestTimeout: httpTimeout, + NodeSelector: nodePluginNodeSelector, + RegistrarResourceSpec: registrarResourceSpec, + TridentResourceSpec: tridentResourceSpec, + Tolerations: tolerations, + ServiceAccountName: serviceAccountName, + ImagePullPolicy: imagePullPolicy, } var newDaemonSetYAML string