Skip to content

Commit 3602c70

Browse files
authored
Add configurable collector (#4092)
* Add configurable collector * Add RELATED_IMAGE_ var * Add func to pull image from spec or env * verify image update Issues: [PGO-2167]
1 parent 38fc33a commit 3602c70

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ jobs:
143143
--env 'RELATED_IMAGE_POSTGRES_17=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-17.2-2' \
144144
--env 'RELATED_IMAGE_POSTGRES_17_GIS_3.4=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi8-17.2-3.4-2' \
145145
--env 'RELATED_IMAGE_STANDALONE_PGADMIN=registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi8-8.14-1' \
146+
--env 'RELATED_IMAGE_COLLECTOR=ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.119.0' \
146147
--env 'PGO_FEATURE_GATES=TablespaceVolumes=true' \
147148
--name 'postgres-operator' ubuntu \
148149
postgres-operator

config/manager/manager.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ spec:
4444
value: "registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:latest"
4545
- name: RELATED_IMAGE_STANDALONE_PGADMIN
4646
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi8-8.14-1"
47+
- name: RELATED_IMAGE_COLLECTOR
48+
value: "ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.119.0"
4749
securityContext:
4850
allowPrivilegeEscalation: false
4951
capabilities: { drop: [ALL] }

internal/collector/instance.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
corev1 "k8s.io/api/core/v1"
1111

12+
"github.com/crunchydata/postgres-operator/internal/config"
1213
"github.com/crunchydata/postgres-operator/internal/feature"
1314
"github.com/crunchydata/postgres-operator/internal/initialize"
1415
"github.com/crunchydata/postgres-operator/internal/naming"
@@ -72,7 +73,7 @@ func AddToPod(
7273

7374
container := corev1.Container{
7475
Name: naming.ContainerCollector,
75-
Image: "ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.117.0",
76+
Image: config.CollectorContainerImage(spec),
7677
ImagePullPolicy: pullPolicy,
7778
Command: []string{"/otelcol-contrib", "--config", "/etc/otel-collector/config.yaml"},
7879
Env: []corev1.EnvVar{

internal/config/config.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ func PGExporterContainerImage(cluster *v1beta1.PostgresCluster) string {
9999
return defaultFromEnv(image, "RELATED_IMAGE_PGEXPORTER")
100100
}
101101

102+
// CollectorContainerImage returns the container image to use for the
103+
// collector container.
104+
func CollectorContainerImage(instrumentation *v1beta1.InstrumentationSpec) string {
105+
var image string
106+
if instrumentation != nil {
107+
image = instrumentation.Image
108+
}
109+
110+
return defaultFromEnv(image, "RELATED_IMAGE_COLLECTOR")
111+
}
112+
102113
// PostgresContainerImage returns the container image to use for PostgreSQL.
103114
func PostgresContainerImage(cluster *v1beta1.PostgresCluster) string {
104115
image := cluster.Spec.Image
@@ -143,6 +154,10 @@ func VerifyImageValues(cluster *v1beta1.PostgresCluster) error {
143154
cluster.Spec.Monitoring.PGMonitor.Exporter != nil {
144155
images = append(images, "crunchy-postgres-exporter")
145156
}
157+
if CollectorContainerImage(cluster.Spec.Instrumentation) == "" &&
158+
cluster.Spec.Instrumentation != nil {
159+
images = append(images, "crunchy-collector")
160+
}
146161
if PostgresContainerImage(cluster) == "" {
147162
if cluster.Spec.PostGISVersion != "" {
148163
images = append(images, "crunchy-postgres-gis")

0 commit comments

Comments
 (0)