davsclaus opened a new pull request, #30845: URL: https://github.com/apache/camel/pull/30845
## Description [CAMEL-22104](https://issues.apache.org/jira/browse/CAMEL-22104): a `prometheus` trait for `camel kubernetes run` / `export`, after the Camel K trait of the same name. A kubernetes export always includes `camel-observability-services`, which serves the metrics at `/observe/metrics` on the management port (`9876`). With `--trait prometheus.enabled=true` the trait: - names that port of the container (`management`). A port the container already has for the same number keeps its name, such as `http` for a WAR, which serves the management endpoints on the application port. - creates a `PodMonitor` (`monitoring.coreos.com/v1`, the Prometheus Operator) that selects the pods of the Deployment (`app.kubernetes.io/name`) and scrapes `management` at `/observe/metrics`. Options: `enabled`, `pod-monitor` (default `true`), `pod-monitor-labels` (`key=value`, for the `podMonitorSelector` of Prometheus), `container-port`, `container-port-name`, `path`. A label without `=` is a usage error (exit code 2). The trait applies to a Deployment only: it is skipped, with a note, for a CronJob or a Knative service. The PodMonitor is a `GenericKubernetesResource`, so no fabric8 monitoring model is added to the plugin. The docs of the Jolokia trait now show `kubectl port-forward` to reach Jolokia from outside the cluster. [CAMEL-22105](https://issues.apache.org/jira/browse/CAMEL-22105) asked to expose Jolokia through a Route or an Ingress. Jolokia gives full JMX access, so that is resolved as Won't Fix instead. ## Testing - `KubernetesExportTest`: PodMonitor and port for main, Spring Boot and Quarkus; no PodMonitor with `pod-monitor=false` and a custom port and name; reuse of the existing `http` port; a label without a value is rejected. The whole module passes (187 tests). - End to end: `camel kubernetes run route-service.yaml --output yaml --trait prometheus.enabled=true --trait prometheus.pod-monitor-labels=release=prometheus` runs JKube's `k8s:resource`. The final manifest has the `PodMonitor` (with JKube's labels added) and the `management` container port `9876`, next to the probes on the same port. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
