@@ -19,11 +19,13 @@ package controller
1919import (
2020 "context"
2121 "fmt"
22+ "path"
2223
2324 common_helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
2425 apiv1beta1 "github.com/openstack-lightspeed/operator/api/v1beta1"
2526 corev1 "k8s.io/api/core/v1"
2627 "k8s.io/apimachinery/pkg/api/errors"
28+ "k8s.io/apimachinery/pkg/api/resource"
2729 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2830 "k8s.io/apimachinery/pkg/types"
2931 "k8s.io/apimachinery/pkg/util/intstr"
@@ -86,13 +88,27 @@ func buildLCorePodTemplateSpec(h *common_helper.Helper, ctx context.Context, ins
8688 ImagePullPolicy : corev1 .PullIfNotPresent ,
8789 }
8890
91+ // Data collection volumes (shared folder + exporter config)
92+ dataCollectionEnabled := isDataCollectionEnabled (instance )
93+ if dataCollectionEnabled {
94+ addDataCollectorVolumes (& volumes , VolumeDefaultMode )
95+ }
96+
8997 // Lightspeed Stack container mounts: its config + shared + TLS (only API container needs TLS)
9098 lightspeedStackMounts := []corev1.VolumeMount {lcoreMount }
9199 lightspeedStackMounts = append (lightspeedStackMounts , sharedMounts ... )
92100 tlsMounts := []corev1.VolumeMount {}
93101 addTLSVolumesAndMounts (& volumes , & tlsMounts , VolumeDefaultMode )
94102 lightspeedStackMounts = append (lightspeedStackMounts , tlsMounts ... )
95103
104+ // Mount shared data folder on lightspeed-service-api for feedback/transcripts
105+ if dataCollectionEnabled {
106+ lightspeedStackMounts = append (lightspeedStackMounts , corev1.VolumeMount {
107+ Name : UserDataVolumeName ,
108+ MountPath : LCoreUserDataMountPath ,
109+ })
110+ }
111+
96112 lightspeedStackContainer := corev1.Container {
97113 Name : "lightspeed-service-api" ,
98114 Image : apiv1beta1 .OpenStackLightspeedDefaultValues .LCoreImageURL ,
@@ -107,6 +123,42 @@ func buildLCorePodTemplateSpec(h *common_helper.Helper, ctx context.Context, ins
107123
108124 containers := []corev1.Container {llamaStackContainer , lightspeedStackContainer }
109125
126+ // Add dataverse exporter sidecar when data collection is enabled
127+ if dataCollectionEnabled {
128+ exporterContainer := corev1.Container {
129+ Name : DataverseExporterContainerName ,
130+ Image : apiv1beta1 .OpenStackLightspeedDefaultValues .ExporterImageURL ,
131+ ImagePullPolicy : corev1 .PullAlways ,
132+ Args : []string {
133+ "--mode" , "openshift" ,
134+ "--config" , path .Join (ExporterConfigMountPath , ExporterConfigFilename ),
135+ "--log-level" , "INFO" ,
136+ "--data-dir" , LCoreUserDataMountPath ,
137+ },
138+ VolumeMounts : []corev1.VolumeMount {
139+ {
140+ Name : UserDataVolumeName ,
141+ MountPath : LCoreUserDataMountPath ,
142+ },
143+ {
144+ Name : ExporterConfigVolumeName ,
145+ MountPath : ExporterConfigMountPath ,
146+ ReadOnly : true ,
147+ },
148+ },
149+ Resources : corev1.ResourceRequirements {
150+ Requests : corev1.ResourceList {
151+ corev1 .ResourceCPU : resource .MustParse ("50m" ),
152+ corev1 .ResourceMemory : resource .MustParse ("64Mi" ),
153+ },
154+ Limits : corev1.ResourceList {
155+ corev1 .ResourceMemory : resource .MustParse ("200Mi" ),
156+ },
157+ },
158+ }
159+ containers = append (containers , exporterContainer )
160+ }
161+
110162 // Build configmap resource version annotations for change detection
111163 annotations , err := buildConfigMapAnnotations (h , ctx )
112164 if err != nil {
@@ -248,6 +300,28 @@ func addLlamaCacheVolumesAndMounts(volumes *[]corev1.Volume, mounts *[]corev1.Vo
248300 })
249301}
250302
303+ // addDataCollectorVolumes adds the shared data EmptyDir and exporter config volumes.
304+ func addDataCollectorVolumes (volumes * []corev1.Volume , volumeDefaultMode int32 ) {
305+ * volumes = append (* volumes , corev1.Volume {
306+ Name : UserDataVolumeName ,
307+ VolumeSource : corev1.VolumeSource {
308+ EmptyDir : & corev1.EmptyDirVolumeSource {},
309+ },
310+ })
311+
312+ * volumes = append (* volumes , corev1.Volume {
313+ Name : ExporterConfigVolumeName ,
314+ VolumeSource : corev1.VolumeSource {
315+ ConfigMap : & corev1.ConfigMapVolumeSource {
316+ LocalObjectReference : corev1.LocalObjectReference {
317+ Name : ExporterConfigCmName ,
318+ },
319+ DefaultMode : toPtr (volumeDefaultMode ),
320+ },
321+ },
322+ })
323+ }
324+
251325// addUserCAVolumesAndMounts adds user-provided additional CA certificate volume and mount
252326// if instance.Spec.TLSCACertBundle is set.
253327func addUserCAVolumesAndMounts (volumes * []corev1.Volume , mounts * []corev1.VolumeMount , instance * apiv1beta1.OpenStackLightspeed , volumeDefaultMode int32 ) {
0 commit comments