diff --git a/controllers/cloud.redhat.com/providers/sidecar/default.go b/controllers/cloud.redhat.com/providers/sidecar/default.go index 45ac13c2d..a55eead90 100644 --- a/controllers/cloud.redhat.com/providers/sidecar/default.go +++ b/controllers/cloud.redhat.com/providers/sidecar/default.go @@ -47,9 +47,21 @@ func (sc *sidecarProvider) Provide(app *crd.ClowdApp) error { } case "otel-collector": if sidecar.Enabled && sc.Env.Spec.Providers.Sidecars.OtelCollector.Enabled { - cont := getOtelCollector() + cont := getOtelCollector(app.Name) + optional := true if cont != nil { d.Spec.Template.Spec.Containers = append(d.Spec.Template.Spec.Containers, *cont) + innerDeployment.PodSpec.Volumes = append(innerDeployment.PodSpec.Volumes, core.Volume{ + Name: fmt.Sprintf("%s-otel-config", app.Name), + VolumeSource: core.VolumeSource{ + ConfigMap: &core.ConfigMapVolumeSource{ + LocalObjectReference: core.LocalObjectReference{ + Name: fmt.Sprintf("%s-otel-config", app.Name), + }, + Optional: &optional, + }, + }, + }) } } default: @@ -84,7 +96,7 @@ func (sc *sidecarProvider) Provide(app *crd.ClowdApp) error { } case "otel-collector": if sidecar.Enabled && sc.Env.Spec.Providers.Sidecars.OtelCollector.Enabled { - cont := getOtelCollector() + cont := getOtelCollector(app.Name) if cont != nil { cj.Spec.JobTemplate.Spec.Template.Spec.Containers = append(cj.Spec.JobTemplate.Spec.Template.Spec.Containers, *cont) } @@ -145,7 +157,7 @@ func getTokenRefresher(appName string) *core.Container { return &cont } -func getOtelCollector() *core.Container { +func getOtelCollector(appName string) *core.Container { cont := core.Container{} cont.Name = "otel-collector" @@ -164,5 +176,9 @@ func getOtelCollector() *core.Container { "memory": resource.MustParse("1024Mi"), }, } + cont.VolumeMounts = []core.VolumeMount{{ + Name: fmt.Sprintf("%s-otel-config", appName), + MountPath: "/etc/otelcol/config", + }} return &cont }