Skip to content

PO to GMP Migration Tool: ServiceMonitor Spec Migration - #2022

Open
karthunni wants to merge 19 commits into
karthunni/po-migrate-service-resolutionfrom
karthunni/po-migrate-servicemonitor-spec
Open

PO to GMP Migration Tool: ServiceMonitor Spec Migration#2022
karthunni wants to merge 19 commits into
karthunni/po-migrate-service-resolutionfrom
karthunni/po-migrate-servicemonitor-spec

Conversation

@karthunni

Copy link
Copy Markdown
Collaborator
  • ServiceMonitor Conversion & Registration: Implements ServiceMonitorConverter in pkg/migrate/servicemonitor.go and registers it in the CLI entrypoint (cmd/gmp-migrate/main.go).
  • Conflict-Aware Resource Splitting: Resolves backing Kubernetes Service resources from the ResourceCache matching spec.selector. Groups Services by configuration compatibility (selectors, port mappings, labels) and automatically splits conflicting Services into distinct, uniquely-named PodMonitoring resources.
  • Namespace & Scoping Resolution: Evaluates spec.namespaceSelector to generate either namespace-scoped PodMonitoring resources (cloned across all targeted namespaces) or cluster-scoped ClusterPodMonitoring resources when any: true is specified.
  • Endpoint & Label Translation: Translates endpoint ports, paths, schemes, intervals, timeouts, and authentication configurations. Merges Service target labels (spec.targetLabels), Pod target labels (spec.podTargetLabels), spec.jobLabel, and pre-scrape relabeling rules into GMP scrape endpoints and label selectors.
  • Namespace-Scoped Secret Generation: Ensures generated authentication secrets (bearer tokens, basic auth, TLS certificates) are properly scoped and cloned per target namespace (pkg/migrate/helpers.go).
  • Testing: Adds table-driven unit tests in pkg/migrate/servicemonitor_test.go covering multi-service conversion, conflict splitting, cluster-scoped monitoring, multi-namespace cloning, and secret generation.

@karthunni
karthunni changed the base branch from main to karthunni/po-migrate-service-resolution July 29, 2026 20:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go
Comment thread pkg/migrate/servicemonitor.go
@karthunni karthunni self-assigned this Jul 29, 2026
@karthunni
karthunni marked this pull request as ready for review July 29, 2026 20:46
@karthunni
karthunni force-pushed the karthunni/po-migrate-servicemonitor-spec branch from 6a70cc9 to a3739f7 Compare July 29, 2026 21:09
@karthunni
karthunni requested a review from bernot-dev July 29, 2026 21:53
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go
Comment thread pkg/migrate/servicemonitor_test.go Outdated
@karthunni
karthunni force-pushed the karthunni/po-migrate-servicemonitor-spec branch 2 times, most recently from 689bf20 to ce8e70d Compare August 3, 2026 19:04
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor_test.go
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go
Comment thread pkg/migrate/servicemonitor.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-servicemonitor-spec branch from ab63a0f to 562ad65 Compare August 5, 2026 18:55
@karthunni
karthunni force-pushed the karthunni/po-migrate-servicemonitor-spec branch from 562ad65 to 54e1f01 Compare August 6, 2026 03:02
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go
Comment thread pkg/migrate/servicemonitor.go Outdated
Comment thread pkg/migrate/servicemonitor.go
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/servicemonitor.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-servicemonitor-spec branch from 65db1fe to cdb154c Compare August 6, 2026 15:35
@karthunni
karthunni force-pushed the karthunni/po-migrate-servicemonitor-spec branch from 95e2854 to 5d2d85b Compare August 6, 2026 18:10
@karthunni karthunni changed the title PO to GMP Migration Tool; ServiceMonitor Spec Migration PO to GMP Migration Tool: ServiceMonitor Spec Migration Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants