diff --git a/deploy/crds/noobaa.io_noobaas.yaml b/deploy/crds/noobaa.io_noobaas.yaml index 6eb1b66ab..078903a26 100644 --- a/deploy/crds/noobaa.io_noobaas.yaml +++ b/deploy/crds/noobaa.io_noobaas.yaml @@ -1706,6 +1706,11 @@ spec: update the admin account with new BackingStore/NamespaceStore in order to delete the DefaultBackingStore/DefaultNamespaceStore nullable: true type: boolean + notificationsPVC: + description: |- + NotificationsPVC (optional) specifies the name of the Persistent Volume Claim (PVC) to be used + for notifications persistent files. + type: string pvPoolDefaultStorageClass: description: |- PVPoolDefaultStorageClass (optional) overrides the default cluster StorageClass for the pv-pool volumes. diff --git a/pkg/apis/noobaa/v1alpha1/noobaa_types.go b/pkg/apis/noobaa/v1alpha1/noobaa_types.go index 0d7f4ac79..d2fab583d 100644 --- a/pkg/apis/noobaa/v1alpha1/noobaa_types.go +++ b/pkg/apis/noobaa/v1alpha1/noobaa_types.go @@ -227,6 +227,11 @@ type NooBaaSpec struct { // BucketLogging sets the configuration for bucket logging // +optional BucketLogging BucketLoggingSpec `json:"bucketLogging,omitempty"` + + // NotificationsPVC (optional) specifies the name of the Persistent Volume Claim (PVC) to be used + // for notifications persistent files. + // +optional + NotificationsPVC *string `json:"notificationsPVC,omitempty"` } // AutoscalerSpec defines different actoscaling spec such as autoscaler type and prometheus namespace diff --git a/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go index ab86a614c..db8601e0b 100644 --- a/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go @@ -1227,6 +1227,11 @@ func (in *NooBaaSpec) DeepCopyInto(out *NooBaaSpec) { in.LoadBalancerSourceSubnets.DeepCopyInto(&out.LoadBalancerSourceSubnets) out.Autoscaler = in.Autoscaler in.BucketLogging.DeepCopyInto(&out.BucketLogging) + if in.NotificationsPVC != nil { + in, out := &in.NotificationsPVC, &out.NotificationsPVC + *out = new(string) + **out = **in + } return } diff --git a/pkg/bundle/deploy.go b/pkg/bundle/deploy.go index 03b2b6803..b36914e04 100644 --- a/pkg/bundle/deploy.go +++ b/pkg/bundle/deploy.go @@ -1415,7 +1415,7 @@ spec: status: {} ` -const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "3f88c800238f25e5dd26f3f1bf19028571cc646e3aea0f868bfd2ff600ee3ed1" +const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "0f61ab9eecb4ccd392e5e5e7932baa0fa12ba035b56c4d610a8eaaebb98c8188" const File_deploy_crds_noobaa_io_noobaas_yaml = `--- apiVersion: apiextensions.k8s.io/v1 @@ -3125,6 +3125,11 @@ spec: update the admin account with new BackingStore/NamespaceStore in order to delete the DefaultBackingStore/DefaultNamespaceStore nullable: true type: boolean + notificationsPVC: + description: |- + NotificationsPVC (optional) specifies the name of the Persistent Volume Claim (PVC) to be used + for notifications persistent files. + type: string pvPoolDefaultStorageClass: description: |- PVPoolDefaultStorageClass (optional) overrides the default cluster StorageClass for the pv-pool volumes. diff --git a/pkg/system/phase2_creating.go b/pkg/system/phase2_creating.go index a2680069c..77f411093 100644 --- a/pkg/system/phase2_creating.go +++ b/pkg/system/phase2_creating.go @@ -450,6 +450,16 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) { } } } + + if r.NooBaa.Spec.NotificationsPVC != nil { + envVar := corev1.EnvVar{ + Name: "NOTIFICATION_LOG_DIR", + Value: "/var/logs/notifications", + } + + util.MergeEnvArrays(&c.Env, &[]corev1.EnvVar{envVar}); + } + } // SetDesiredCoreApp updates the CoreApp as desired for reconciling @@ -519,6 +529,51 @@ func (r *Reconciler) SetDesiredCoreApp() error { }} util.MergeVolumeMountList(&c.VolumeMounts, &bucketLogVolumeMounts) } + + if r.NooBaa.Spec.NotificationsPVC != nil { + notificationVolumeMounts := []corev1.VolumeMount{{ + Name: "notif-vol", + MountPath: "/var/logs/notifications", + }} + util.MergeVolumeMountList(&c.VolumeMounts, ¬ificationVolumeMounts) + + notificationVolumes := []corev1.Volume {{ + Name: "notif-vol", + VolumeSource: corev1.VolumeSource { + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource { + ClaimName: *r.NooBaa.Spec.NotificationsPVC, + }, + }, + }} + util.MergeVolumeList(&podSpec.Volumes, ¬ificationVolumes) + + //find secrets that tell us how to connect to remote notifications servers, + //mount them so core can read them + notificatoinSecrets := &corev1.SecretList{} + noobaaNotifSelector, _ := labels.Parse("app=noobaa,noobaa=notifications") + util.KubeList(notificatoinSecrets, &client.ListOptions{Namespace: options.Namespace, LabelSelector: noobaaNotifSelector}) + + for _, notificationSecret := range notificatoinSecrets.Items { + + secretVolumeMounts := []corev1.VolumeMount{{ + Name: notificationSecret.Name, + MountPath: "/etc/notif_connect/" + notificationSecret.Name, + ReadOnly: true, + }} + util.MergeVolumeMountList(&c.VolumeMounts, &secretVolumeMounts) + + secretVolumes := []corev1.Volume{{ + Name: notificationSecret.Name, + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: notificationSecret.Name, + }, + }, + }} + util.MergeVolumeList(&podSpec.Volumes, &secretVolumes) + } + } + case "noobaa-log-processor": if c.Image != r.NooBaa.Status.ActualImage { coreImageChanged = true @@ -624,6 +679,7 @@ func (r *Reconciler) SetDesiredCoreApp() error { }} util.MergeVolumeList(&podSpec.Volumes, &bucketLogVolumes) } + return nil } diff --git a/pkg/system/phase4_configuring.go b/pkg/system/phase4_configuring.go index e6f839869..14f81b430 100644 --- a/pkg/system/phase4_configuring.go +++ b/pkg/system/phase4_configuring.go @@ -415,6 +415,15 @@ func (r *Reconciler) SetDesiredDeploymentEndpoint() error { } } + if r.NooBaa.Spec.NotificationsPVC != nil { + envVar := corev1.EnvVar{ + Name: "NOTIFICATION_LOG_DIR", + Value: "/var/logs/notifications", + } + + util.MergeEnvArrays(&c.Env, &[]corev1.EnvVar{envVar}); + } + c.SecurityContext = &corev1.SecurityContext{ Capabilities: &corev1.Capabilities{ Add: []corev1.Capability{"SETUID", "SETGID"}, @@ -533,6 +542,24 @@ func (r *Reconciler) setDesiredEndpointMounts(podSpec *corev1.PodSpec, container util.MergeVolumeMountList(&container.VolumeMounts, &bucketLogVolumeMounts) } + if r.NooBaa.Spec.NotificationsPVC != nil { + notificationVolumes := []corev1.Volume{{ + Name: "notif-vol", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: *r.NooBaa.Spec.NotificationsPVC, + }, + }, + }} + util.MergeVolumeList(&podSpec.Volumes, ¬ificationVolumes) + + notificationVolumeMounts := []corev1.VolumeMount{{ + Name: "notif-vol", + MountPath: "/var/logs/notifications", + }} + util.MergeVolumeMountList(&container.VolumeMounts, ¬ificationVolumeMounts) + } + r.setDesiredRootMasterKeyMounts(podSpec, container) for _, nsStore := range namespaceStoreList.Items {