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 Nov 13, 2024
1 parent b62bb7e commit 7309d19
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 1 deletion.
5 changes: 5 additions & 0 deletions deploy/crds/noobaa.io_noobaas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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
5 changes: 5 additions & 0 deletions pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pkg/bundle/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
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 7309d19

Please sign in to comment.