Skip to content

Commit efcb699

Browse files
authored
PodMonitors: use port (name) and portNumber properly (#599)
* use port (name) and portNumber properly * Refactor * Add targetPort as well
1 parent 0966c25 commit efcb699

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

controllers/postgres_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const (
6868
podMonitorName string = "patroni"
6969
walGExporterName string = "wal-g-exporter"
7070
walGExporterPort int32 = 9351
71-
podMonitorPort string = "8008"
71+
podMonitorPort int32 = 8008
7272
initDBName string = "postgres-initdb"
7373
initDBSQLDummy string = `SELECT 'NOOP';`
7474
debugLogLevel int = 1
@@ -1688,7 +1688,8 @@ func (r *PostgresReconciler) createOrUpdatePatroniPodMonitor(ctx context.Context
16881688

16891689
pm.Spec.PodMetricsEndpoints = []coreosv1.PodMetricsEndpoint{
16901690
{
1691-
Port: ptr.To(podMonitorPort),
1691+
PortNumber: ptr.To(podMonitorPort),
1692+
TargetPort: ptr.To(intstr.FromInt32(podMonitorPort)),
16921693
},
16931694
}
16941695
pm.Spec.NamespaceSelector = coreosv1.NamespaceSelector{
@@ -2241,7 +2242,7 @@ func (r *PostgresReconciler) createOrUpdateWalGExporterPodMonitor(log logr.Logge
22412242

22422243
s.Spec.PodMetricsEndpoints = []coreosv1.PodMetricsEndpoint{
22432244
{
2244-
Port: ptr.To(strconv.Itoa(int(walGExporterPort))),
2245+
Port: ptr.To(walGExporterName),
22452246
},
22462247
}
22472248
selector := map[string]string{

0 commit comments

Comments
 (0)