PO to GMP Migration Tool: ServiceMonitor Spec Migration - #2022
PO to GMP Migration Tool: ServiceMonitor Spec Migration#2022karthunni wants to merge 19 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a ServiceMonitorConverter to translate Prometheus Operator ServiceMonitor resources into Google Managed Prometheus (GMP) PodMonitoring or ClusterPodMonitoring resources, sharing common spec logic with the existing PodMonitorConverter. The review feedback highlights several critical resilience issues where non-fatal configuration discrepancies—such as missing backing Services, Services without selectors, or unresolvable ports—incorrectly trigger fatal migration failures instead of logging warnings and using placeholders. Additionally, the reviewer noted that static target labels mapped from Services must be checked against GMP's protected labels to prevent validation failures.
6a70cc9 to
a3739f7
Compare
689bf20 to
ce8e70d
Compare
2345f55 to
1e751d0
Compare
ab63a0f to
562ad65
Compare
562ad65 to
54e1f01
Compare
65db1fe to
cdb154c
Compare
95e2854 to
5d2d85b
Compare
ServiceMonitorConverterin pkg/migrate/servicemonitor.go and registers it in the CLI entrypoint (cmd/gmp-migrate/main.go).Serviceresources from theResourceCachematchingspec.selector. Groups Services by configuration compatibility (selectors, port mappings, labels) and automatically splits conflicting Services into distinct, uniquely-namedPodMonitoringresources.spec.namespaceSelectorto generate either namespace-scopedPodMonitoringresources (cloned across all targeted namespaces) or cluster-scopedClusterPodMonitoringresources whenany: trueis specified.spec.targetLabels), Pod target labels (spec.podTargetLabels),spec.jobLabel, and pre-scrape relabeling rules into GMP scrape endpoints and label selectors.