Skip to content

Commit

Permalink
Notifications
Browse files Browse the repository at this point in the history
-New field notificationsPVC in noobaa that is mounted to endpoints and core
-Secrets containing info on how to connect to remote server are mounted to core

Signed-off-by: Amit Prinz Setter <[email protected]>
  • Loading branch information
alphaprinz committed Oct 31, 2024
1 parent 2118852 commit aa397a3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deploy/crds/noobaa.io_noobaas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,9 @@ spec:
- guaranteed - much more reliable but need to provide a storage class that supports RWX PVs
type: string
type: object
notificationsPVC:
description: Name of PVC used for notification persistent files.
type: string
cleanupPolicy:
description: CleanupPolicy (optional) Indicates user's policy for
deletion
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/noobaa/v1alpha1/noobaa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/bundle/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,9 @@ spec:
- guaranteed - much more reliable but need to provide a storage class that supports RWX PVs
type: string
type: object
notificationsPVC:
description: Name of PVC used for notification persistent files.
type: string
cleanupPolicy:
description: CleanupPolicy (optional) Indicates user's policy for
deletion
Expand Down
56 changes: 56 additions & 0 deletions pkg/system/phase2_creating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, &notificationVolumeMounts)

notificationVolumes := []corev1.Volume {{
Name: "notif-vol",
VolumeSource: corev1.VolumeSource {
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource {
ClaimName: *r.NooBaa.Spec.NotificationsPVC,
},
},
}}
util.MergeVolumeList(&podSpec.Volumes, &notificationVolumes)

//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
Expand Down Expand Up @@ -624,6 +679,7 @@ func (r *Reconciler) SetDesiredCoreApp() error {
}}
util.MergeVolumeList(&podSpec.Volumes, &bucketLogVolumes)
}

return nil
}

Expand Down
27 changes: 27 additions & 0 deletions pkg/system/phase4_configuring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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, &notificationVolumes)

notificationVolumeMounts := []corev1.VolumeMount{{
Name: "notif-vol",
MountPath: "/var/logs/notifications",
}}
util.MergeVolumeMountList(&container.VolumeMounts, &notificationVolumeMounts)
}

r.setDesiredRootMasterKeyMounts(podSpec, container)

for _, nsStore := range namespaceStoreList.Items {
Expand Down

0 comments on commit aa397a3

Please sign in to comment.