Skip to content

feat(monitoring): add optional PodMonitor and metrics policy - #1

Draft
cooktheryan wants to merge 7 commits into
feat/issue-1302-rollout-operatorfrom
issue-23-monitoring
Draft

cooktheryan wants to merge 7 commits into
feat/issue-1302-rollout-operatorfrom
issue-23-monitoring

Conversation

@cooktheryan

Copy link
Copy Markdown
Owner

Summary

  • add opt-in PodMonitor generation for each managed Praxis data plane
  • add an owner-scoped NetworkPolicy that permits only the configured Prometheus pods to scrape port 9902
  • keep monitoring disabled by default so clusters without the Prometheus Operator CRD continue to reconcile normally
  • add RBAC, deployment configuration, documentation, and resource-builder coverage

Closes praxis-proxy#23

Configuration

Set PRAXIS_MONITORING_ENABLED=true to enable the resources. The monitoring namespace and Prometheus pod label selector are configurable with PRAXIS_MONITORING_NAMESPACE and PRAXIS_MONITORING_POD_SELECTOR.

This PR targets the rollout-contract branch from PR praxis-proxy#24 so the diff is limited to the monitoring follow-up; merge it after that branch lands or retarget it to main once the 9902 metrics contract is available there.

Validation

  • cargo +nightly fmt --check on changed Rust files
  • cargo clippy -p praxis-operator --all-targets -- -D warnings
  • cargo test -p praxis-operator --lib — 477 passed
  • git diff --check

The generated NetworkPolicy intentionally does not restrict the data listener. Clusters whose CNI applies policy to node-originated kubelet probes need a separate node-CIDR allowance.

@cooktheryan
cooktheryan force-pushed the feat/issue-1302-rollout-operator branch 3 times, most recently from 6a11771 to 0dd3490 Compare November 4, 2026 20:35
@cooktheryan
cooktheryan force-pushed the issue-23-monitoring branch 7 times, most recently from 92569c3 to ebb2d68 Compare November 11, 2026 19:53
Monitoring is opt-in through PRAXIS_MONITORING_ENABLED. When enabled,
each managed data plane gets a PodMonitor scraping the reserved admin
port and a NetworkPolicy that admits metrics traffic only from the
configured Prometheus namespace and pods; data ports stay open to
every peer. When disabled, or when no usable listeners remain, owned
monitoring resources are removed, and reconciliation tolerates an
absent Prometheus Operator CRD.

Health, readiness, and metrics move to a reserved admin port (9902)
served through the data plane's admin.metrics_address, so probes and
scrapes no longer need public admin access. Gateway listeners asking
for that port report PortUnavailable without blocking other
listeners.

The metrics contract requires the praxis 0.7.5 data plane, whose
stricter validation rejects several shapes this operator previously
generated, so config generation follows it:

- Routeless listeners terminate with a 404 static response instead
  of an empty router chain, and terminating filters from redirect
  and invalid-reference rules keep answering ahead of that fallback.
- Terminating filters run only on the listeners their routes target,
  so a filter from one listener never answers another listener's
  traffic or overrides its routeless 404 fallback.
- Cluster names use only the characters the data plane accepts.
- Backends without ready endpoints answer 500 instead of blocking
  rollout, weight-0 backendRefs contribute no endpoints, duplicate
  addresses merge with summed weights, and endpoint weights scale
  into the supported 1..=1000 range.

Signed-off-by: Ryan Cook <rcook@redhat.com>
Terminating filters now carry the section names of the route that
produced them, and a listener chain only gets the filters whose route
targets it. A catch-all redirect or invalid-reference 500 on one
listener can no longer answer another listener's traffic or override
its routeless 404 fallback. Add coverage for cross-listener scoping and
mixed listeners.

Signed-off-by: Ryan Cook <rcook@redhat.com>
Signed-off-by: Ryan Cook <rcook@redhat.com>

# Conflicts:
#	Cargo.lock
An HTTPRoute backendRef with an unsupported group or kind is
unresolvable, so the rule must answer the Gateway API 500 instead of
emitting a route to a cluster that never resolves. Treat unsupported
kinds as not servable in both route generation and filter conversion,
and add a regression test for the conformance case.

Signed-off-by: Ryan Cook <rcook@redhat.com>
@cooktheryan
cooktheryan force-pushed the feat/issue-1302-rollout-operator branch from 01a8cf5 to cc2f02b Compare November 13, 2026 19:32
Rejected rules no longer contribute filters, so a POST-only redirect on a
routeless listener cannot answer GET requests after validation drops the
route. A chain that already ends in an unconditional static response is
truncated there instead of appending a 404 the data plane would reject
as unreachable. Add regression tests for both cases.

Signed-off-by: Ryan Cook <rcook@redhat.com>
The unless clauses in a filter's conditions name the sibling rules that
outrank it. Converting one RouteFilters for the whole Gateway let a
higher-priority rule on one listener suppress another listener's 500 or
redirect. Build a RouteFilters per listener from only the routes that
listener targets, and use it when assembling that chain. Add a
regression test where an /api rule on the api listener must not affect a
catch-all response on web.

Signed-off-by: Ryan Cook <rcook@redhat.com>
A weight-0 backendRef is resolvable but must receive no traffic. It was
still claiming the cluster dedup identity for single-backend rules, so a
later positive-weight ref for the same Service was dropped and the
cluster could end up endpointless. Treat weight-0 refs as not servable,
which keeps them out of the cluster name and dedup set, and have such a
rule answer 500 like any other rule with no usable backend.

Signed-off-by: Ryan Cook <rcook@redhat.com>
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.

1 participant