diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e04d9ef131..12469ae91d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -143,6 +143,7 @@ jobs: --env 'RELATED_IMAGE_POSTGRES_17=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-17.2-2' \ --env 'RELATED_IMAGE_POSTGRES_17_GIS_3.4=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi8-17.2-3.4-2' \ --env 'RELATED_IMAGE_STANDALONE_PGADMIN=registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi8-8.14-1' \ + --env 'RELATED_IMAGE_COLLECTOR=ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.119.0' \ --env 'PGO_FEATURE_GATES=TablespaceVolumes=true' \ --name 'postgres-operator' ubuntu \ postgres-operator diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 8fb6bcf007..98a771bb32 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -44,6 +44,8 @@ spec: value: "registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:latest" - name: RELATED_IMAGE_STANDALONE_PGADMIN value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi8-8.14-1" + - name: RELATED_IMAGE_COLLECTOR + value: "ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.119.0" securityContext: allowPrivilegeEscalation: false capabilities: { drop: [ALL] } diff --git a/internal/collector/instance.go b/internal/collector/instance.go index 8cb90be32a..a3ddc1ae8a 100644 --- a/internal/collector/instance.go +++ b/internal/collector/instance.go @@ -9,6 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" + "github.com/crunchydata/postgres-operator/internal/config" "github.com/crunchydata/postgres-operator/internal/feature" "github.com/crunchydata/postgres-operator/internal/initialize" "github.com/crunchydata/postgres-operator/internal/naming" @@ -72,7 +73,7 @@ func AddToPod( container := corev1.Container{ Name: naming.ContainerCollector, - Image: "ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.117.0", + Image: config.CollectorContainerImage(spec), ImagePullPolicy: pullPolicy, Command: []string{"/otelcol-contrib", "--config", "/etc/otel-collector/config.yaml"}, Env: []corev1.EnvVar{ diff --git a/internal/config/config.go b/internal/config/config.go index ff3c6507d0..2c5f1bf769 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -99,6 +99,17 @@ func PGExporterContainerImage(cluster *v1beta1.PostgresCluster) string { return defaultFromEnv(image, "RELATED_IMAGE_PGEXPORTER") } +// CollectorContainerImage returns the container image to use for the +// collector container. +func CollectorContainerImage(instrumentation *v1beta1.InstrumentationSpec) string { + var image string + if instrumentation != nil { + image = instrumentation.Image + } + + return defaultFromEnv(image, "RELATED_IMAGE_COLLECTOR") +} + // PostgresContainerImage returns the container image to use for PostgreSQL. func PostgresContainerImage(cluster *v1beta1.PostgresCluster) string { image := cluster.Spec.Image @@ -143,6 +154,10 @@ func VerifyImageValues(cluster *v1beta1.PostgresCluster) error { cluster.Spec.Monitoring.PGMonitor.Exporter != nil { images = append(images, "crunchy-postgres-exporter") } + if CollectorContainerImage(cluster.Spec.Instrumentation) == "" && + cluster.Spec.Instrumentation != nil { + images = append(images, "crunchy-collector") + } if PostgresContainerImage(cluster) == "" { if cluster.Spec.PostGISVersion != "" { images = append(images, "crunchy-postgres-gis")