Skip to content

Commit

Permalink
Add configurable configmap config to otelcollector config
Browse files Browse the repository at this point in the history
  • Loading branch information
gburges committed Oct 23, 2024
1 parent a65f217 commit 995d137
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions controllers/cloud.redhat.com/providers/sidecar/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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"
Expand All @@ -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
}

0 comments on commit 995d137

Please sign in to comment.