diff --git a/api/v1alpha1/storagenode_types.go b/api/v1alpha1/storagenode_types.go index ccc3fd67..eef5bca8 100644 --- a/api/v1alpha1/storagenode_types.go +++ b/api/v1alpha1/storagenode_types.go @@ -133,6 +133,10 @@ type StorageNodeSpec struct { // Tolerations configures pod tolerations for storage-node pods. Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Image Pull Secrets" + // ImagePullSecrets is the list of image pull secrets for storage-node pods. + ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` + // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Force" // Force enables forced action execution where supported. Force *bool `json:"force,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 3c6bcb6d..ab2f4a2a 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1611,6 +1611,11 @@ func (in *StorageNodeSpec) DeepCopyInto(out *StorageNodeSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]corev1.LocalObjectReference, len(*in)) + copy(*out, *in) + } if in.Force != nil { in, out := &in.Force, &out.Force *out = new(bool) diff --git a/config/crd/bases/storage.simplyblock.io_storagenodes.yaml b/config/crd/bases/storage.simplyblock.io_storagenodes.yaml index 25cd32ff..c9f3e716 100644 --- a/config/crd/bases/storage.simplyblock.io_storagenodes.yaml +++ b/config/crd/bases/storage.simplyblock.io_storagenodes.yaml @@ -170,6 +170,20 @@ spec: When omitted the backend default is used. pattern: ^[0-9]+(G|GI|GB|GiB|M|MI|MB|MiB|g|gi|gb|gib|m|mi|mb|mib)?$ type: string + imagePullSecrets: + description: ImagePullSecrets is the list of image pull secrets for + storage-node pods. + items: + description: LocalObjectReference contains enough information to + let you locate the referenced object inside the same namespace. + properties: + name: + default: "" + description: Name of the referent. + type: string + type: object + x-kubernetes-map-type: atomic + type: array tolerations: description: Tolerations configures pod tolerations for storage-node pods. diff --git a/internal/utils/storage_node_ds.go b/internal/utils/storage_node_ds.go index 78988993..7dfe0a74 100644 --- a/internal/utils/storage_node_ds.go +++ b/internal/utils/storage_node_ds.go @@ -3,6 +3,7 @@ package utils import ( "fmt" "strings" + "encoding/json" simplyblockv1alpha1 "github.com/simplyblock/simplyblock-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" @@ -54,12 +55,24 @@ func BuildStorageNodeDaemonSet(sn *simplyblockv1alpha1.StorageNode, tlsEnabled b initCmd = append(initCmd, "--cores-percentage="+Int32PtrToString(sn.Spec.CorePercentage)) } + imagePullSecretsJSON := "" + if len(sn.Spec.ImagePullSecrets) > 0 { + names := make([]string, len(sn.Spec.ImagePullSecrets)) + for i, ref := range sn.Spec.ImagePullSecrets { + names[i] = ref.Name + } + if data, err := json.Marshal(names); err == nil { + imagePullSecretsJSON = string(data) + } + } + mainEnv := []corev1.EnvVar{ {Name: "UBUNTU_HOST", Value: BoolPtrToString(sn.Spec.UbuntuHost)}, {Name: "OPENSHIFT_CLUSTER", Value: BoolPtrToString(sn.Spec.OpenShiftCluster)}, {Name: "CPU_TOPOLOGY_ENABLED", Value: BoolPtrToString(sn.Spec.EnableCpuTopology)}, {Name: "SKIP_KUBELET_CONFIGURATION", Value: BoolPtrToString(sn.Spec.SkipKubeletConfiguration)}, {Name: "SIMPLY_BLOCK_DOCKER_IMAGE", Value: image}, + {Name: "IMAGE_PULL_SECRETS", Value: imagePullSecretsJSON}, {Name: "HOSTNAME", ValueFrom: &corev1.EnvVarSource{ FieldRef: &corev1.ObjectFieldSelector{FieldPath: "spec.nodeName"}, }}, @@ -206,6 +219,7 @@ func BuildStorageNodeDaemonSet(sn *simplyblockv1alpha1.StorageNode, tlsEnabled b ServiceAccountName: "simplyblock-storage-node-sa", HostNetwork: true, Tolerations: sn.Spec.Tolerations, + ImagePullSecrets: sn.Spec.ImagePullSecrets, NodeSelector: map[string]string{ "io.simplyblock.node-type": "simplyblock-storage-plane-" + sn.Spec.ClusterName, },