1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 15:46:31 +01:00

200 Commits

Author SHA1 Message Date
Arpit Srivastava
a57c10d6b7 Merge pull request #8350 from Arpit529Srivastava/kubelet-cmd-flag
feat: add flag to disable insecure kubelet metrics port
2026-02-04 11:16:48 +01:00
Arpit Srivastava
b877445c6d Add crd print subcommand to output embedded CRDs (#8251)
* feat: embed CRD manifests in operator

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>

* replace sort with slices package

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>

* refactor: use flag.NArg() for crds and start commands

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>

* refactor: move crds to cmd/crds and add --help info

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>

* feat: add full-crds command

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>

---------

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
2026-01-13 20:49:03 +01:00
Simon Pasquier
c96c4978b5 Merge remote-tracking branch 'origin/release-0.86' into merge-release-0.86
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2025-11-07 14:56:04 +01:00
Simon Pasquier
ce2b016682 Fix operator's permissions on events
Pull requests #7867 and #7953 switched from the core Events API to the
new `events.k8s.io` API group but we forgot to update the RBAC
permissions of the prometheus-operator Service Account and the
verification which happens during the startup.

Closes #8076

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2025-11-06 15:47:55 +01:00
Simon Pasquier
2c160ddd69 chore: check operator's permissions on status
This commit ensures that the operator's Service Account has the expected
permissions to manage status subresources when the
`StatusForConfigurationResources` feature gate is enabled.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2025-10-15 11:04:12 +02:00
Jayapriya Pai
cc19d0e3fc feat: add support for UTF8 labels and rules (#7637)
for admission webhook default is legacy validation

Assissted-By: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2025-10-06 15:03:21 +05:30
dongheeJeong
40f4ebf50f feat: add configurable sync period for kubelet endpoints controller (#7762)
* feat: add configurable sync period for kubelet endpoints controller

Add --kubelet-sync-period flag to allow customization of how often
the kubelet endpoints controller syncs with the Kubernetes API.
Default remains 3 minutes to maintain backward compatibility.

---------

Co-authored-by: Donghee Jeong <danny253@naver.com>
Co-authored-by: 정동희 <danny253@neowiz.com>
2025-08-04 09:49:06 +02:00
Simon Pasquier
5fb77b48b2 Add --watch-referenced-objects-in-all-namespaces CLI argument
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2025-08-01 10:26:44 +02:00
Marek Slabicki
adf64aaa6e feat: add startupProbe to config-reloader
This is for GitHub issue #7494.

Adds startup probe to the config-reloader sidecar for Prometheus containers.

Only takes affect if the --enable-config-reloader-probes flag is set on the
prometheus-operator pod for the config-reloader container.
2025-06-04 03:10:34 -07:00
dongjiang
408e8ebd6e chore: Optimize go runtime metrics (#7081)
* optimize go runtime metrics


---------

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
2024-11-08 10:53:37 +01:00
Pranshu Srivastava
f5218e1620 enhancement: allow toggling custom config deprecation behaviour (#6955)
* enhancement: allow toggling custom config deprecation behaviour

---------

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2024-11-07 16:26:31 +00:00
Simon Pasquier
6c4545572a chore: refactor pkg/prometheus/promcfg.go
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-10-30 09:00:48 +01:00
Simon Pasquier
8518981b50 feat: support EndpointSlice for the kubelet controller (#6882)
* feat: support EndpointSlice for the kubelet controller

This change adds support for managing `EndpointSlice` objects for the
kubelet service. The controller can manage either one of `Endpoints` and
`EndpointSlice` or both.

The migration path can be:
1. Configure the operator to manage both objects in the kubelet
   controller.
2. Verify that the generated `EndpointSlice` objects are correct.
3. Configure the Prometheus object to use the `EndpointSlice` role
   instead of `Endpoints`.
1. Configure the operator to manage only `Endpoints` objects in the
   kubelet controller.

The removal of the legacy `Endpoints` object is left to the user.

---------

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-09-17 08:53:31 +02:00
Simon Pasquier
5ce21508d6 chore: redirect klog to slog
PR #6890 removed the final bits from go-kit/log in the operator code
base but forgot to redirect the klog logs to the new slog logger.
`ResourceReconciler` has a dependency on klog because it uses
`utilruntime.HandleError()` when it fails to sync a resource. As a
consequence, the operator didn't log reconciliation failures anymore.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-09-03 14:46:31 +02:00
perebaj
a40ef97244 replace goKitLogger in controller and namespace denylist 2024-08-29 17:33:39 -03:00
perebaj
47ae005e7e replace goKitLogger in rules and server 2024-08-29 12:17:31 -03:00
Jonathan
0cf01e5485 replace goKitLogger in operators (#6881)
* replace goKitLogger in operators

* remove goKitLogger from alertmanager operator

* remove goKitLogger from main
2024-08-28 09:49:42 +02:00
Simon Pasquier
4140711e72 chore: simplify kubelet controller constructor
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-08-26 10:37:35 +02:00
Jonathan
aa74b0d377 chore: replace gokitlog in the resource reconciler (#6819) 2024-08-08 09:43:11 -03:00
Jonathan
e84c86213c chore: replace go kit log in prometheus package (#6807) 2024-08-07 11:32:21 -03:00
perebaj
e1e9b6fddc replacing gokit-log prometheusagent package 2024-07-30 09:59:12 -03:00
Simon Pasquier
365809896c chore: simplify controller constructors
This change introduces functional options for all 4 controllers
(previously only Prometheus used them).

It also reduces code duplication regarding API version checks.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-07-25 09:33:42 +02:00
Qian_Xiao
9cdd5aec94 cmd: Add secret label selector to filter secrets to watch (#6731)
* cmd: Add secret label selector to filter secrets to watch

This commit adds a flag for secret label selector so user can use label to filter secrets that prometheus-operator watches. This reduces calls to kube-apiserver.

Fixes Exclude irrelevant certs/tls secrets watch in monitoring namespace #6610
2024-07-24 11:09:53 +02:00
Jonathan
b63f72b47b replace go kit log admission pkg (#6768) 2024-07-23 14:50:51 -03:00
perebaj
7b7b3a6476 replace go kit log 2024-07-17 16:54:03 -03:00
Ha Anh Vu
fd70f5c0c8 Check DaemonSet RBAC permissions for Prometheus Agent's DaemonSet mode (#6720)
* Check DaemonSet RBAC permissions for Prometheus Agent's DaemonSet mode
2024-07-03 12:14:23 +00:00
Simon Pasquier
704206b716 feat: add prometheus_operator_feature_gate_info metric
This change also moves the feature gates to the operator config struct.
It means that after a feature gate is enabled/disabled, the operator
will reconcile the managed Prometheus resources which should be the
right thing to do.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-06-07 08:39:23 +02:00
dongjiang
d5d08c58df feat(env): Add automatic memory limit handling (#6591)
* add auto GOMEMLIMIT

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>


---------

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2024-05-30 09:13:48 +02:00
Ha Anh Vu
d67afdd68b Add feature gate for Prometheus Agent's DaemonSet deployment (#6626)
* Add feature gate for Prometheus Agent's DaemonSet deployment
2024-05-29 16:07:45 +02:00
Nicolas Takashi
2f6f31063e [CHORE] allowing kubeconfig as parameter (#6623)
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
2024-05-29 13:24:48 +00:00
Arthur Silva Sens
5488b9f494 Use functional options pattern for Prometheus Controller
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
2024-05-28 17:16:10 -03:00
Simon Pasquier
98c18408cb feat: add automatic GOMAXPROCS to admission webhook
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-05-21 12:16:06 +02:00
Arthur Silva Sens
6b1caac3f1 Add structure for feature flags
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
2024-05-16 17:27:26 -03:00
dongjiang
bac5d117fc feat(env): auto set GOMAXPROCS by go.uber.org/automaxprocs (#6576)
---------

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
2024-05-16 11:17:58 +02:00
Simon Pasquier
80792a70e0 feat: add go_sync_mutex_wait_total_seconds_total metric
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-05-13 14:03:15 +02:00
Simon Pasquier
99c6ab2ca2 feat: add Go runtime scheduler metrics
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-05-03 14:53:55 +02:00
Ha Anh Vu
ffaeca223c Check if controllers' CRDs are provided and manageable by operator (#6351)
* operator cmd: check if controllers' crds are supplied

Only start each controller when its crd is provided, and fail the operator if no controllers start.

Fixes #6140

* Nit

* Resolve reviews
2024-04-02 09:27:46 -03:00
Ha Anh Vu
128acfc449 Kubelet: Add a flag to set node address priority (#6377)
* Add a flag to set node address priority

Currently internal node addresses are prioritized over external addresses. This adds a flag to allow users to freely set node address priority (internal/external). This is helpful for use cases where node internal addresses exist but are not routable.

Fixes #3247
2024-03-29 16:58:10 +01:00
Mario Fernandez Herrero
e3e0f9ae69 Controller id implementation to avoid errors with multiple operators (#6319)
Signed-off-by: Mario Fernandez <mariofer@redhat.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2024-03-20 09:00:10 +01:00
Arthur Silva Sens
8e443acd2b Bump prometheus/common
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
2024-03-07 09:26:37 -03:00
Simon Pasquier
34836082f8 chore: refactor logger and eventrecorder creations (#6225)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-01-13 19:13:18 -03:00
Arthur Silva Sens
895cb3b005 feat: emit events for invalid configurations (#6179)
* feat: emit events for invalid configurations

Emit events when the controller rejects a resource, owing to an invalid
configuration.

Fixes: #3611

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Decouple event recorder from operator metrics

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

* Only emit events if permissions were given

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

* Keep operator name consistent across telemetry

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

* Address comments

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

---------

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
Co-authored-by: Pranshu Srivastava <rexagod@gmail.com>
2024-01-10 08:59:47 -03:00
Simon Pasquier
3513749a91 chore: create kubelet endpoints controller
This commit moves the Kubelet endpoints reconciliation loop from the
Prometheus controller to a separate controller.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-11-27 09:21:24 +01:00
Simon Pasquier
5e9eed43e4 chore: reduce code duplication in components
* Share parsing for the logging flags across all binaries.
* Refactor and share the web server implementation between the operator
  and the admission webhook.
* Refactor controller configuration structs to include only the required
  parameters.
* Parse label and field selector arguments early instead of doing it in
  each controller.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-11-16 14:42:28 +01:00
Simon Pasquier
dfc150aa36 Merge pull request #6028 from simonpasquier/disable-http2
fix: disable HTTP2 connections by default
2023-10-30 15:25:58 +01:00
Simon Pasquier
a62e8144dc fix: disable HTTP2 connections by default
This change mitigates CVE-2023-44487 by disabling HTTP2 by default and
forcing HTTP/1.1 until the Go standard library and golang.org/x/net are
fully fixed. Right now, it is possible for authenticated and
unauthenticated users to hold open HTTP2 connections and consume huge
amounts of memory.

It is possible to revert back the change by using the
`--web.enable-http2` argument.

Before this change:

```
curl -kv https://localhost:8443/metrics
*   Trying 127.0.0.1:8443...
* Connected to localhost (127.0.0.1) port 8443 (#0)
* ALPN: offers h2,http/1.1
[...]
* ALPN: server accepted h2
[...]
* using HTTP/2
* h2h3 [:method: GET]
* h2h3 [:path: /metrics]
* h2h3 [:scheme: https]
* h2h3 [:authority: localhost:8443]
* h2h3 [user-agent: curl/8.0.1]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x5594d4614b10)
[...]
> GET /metrics HTTP/2
[...]
```

After this change:

```
curl -kv https://localhost:8443/metrics
*   Trying 127.0.0.1:8443...
* Connected to localhost (127.0.0.1) port 8443 (#0)
* ALPN: offers h2,http/1.1
[...]
* ALPN: server accepted http/1.1
[...]
* using HTTP/1.1
> GET /metrics HTTP/1.1
> Host: localhost:8443
> User-Agent: curl/8.0.1
> Accept: */*
[...]
< HTTP/1.1 200 OK
[...]
```

See also:
* https://github.com/kubernetes/kubernetes/pull/121120
* https://github.com/kubernetes/kubernetes/issues/121197
* https://github.com/golang/go/issues/63417#issuecomment-1758858612

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-10-19 16:27:04 +02:00
Pranshu Srivastava
7c31ea9ce7 change: drop deprecated metrics
Drop deprecated metrics, namely:
* prometheus_operator_rule_validation_triggered_total
* prometheus_operator_rule_validation_errors_total
* prometheus_operator_alertmanager_config_validation_triggered_total
* prometheus_operator_alertmanager_config_validation_errors_total

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2023-10-19 03:12:41 +05:30
Simon Pasquier
2655bad36d fix: set verbosity log level only for debug
client-go functions can avoid costly logging evaluations by using this
pattern:

```
if klog.V(2).Enabled() { klog.Info("log this") }
```

With this change, the klog verbosity is set to zero (except at debug log
level where it is 6) to ensure that the performance optimization is
preserved.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-10-09 14:10:18 +02:00
Simon Pasquier
29fb4ebd91 Merge pull request #5792 from infracloudio/check-storageclassname
Fixes #4108 | Add logic to check if provided storage class exist
2023-09-25 16:57:36 +02:00
Chirayu Kapoor
7f9bdca5d3 Check if operator has access to storageclass | Add logic to verify if storageclass exist | Add e2e test for invalid storageclass | RBAC to access storageclass
Signed-off-by: Chirayu Kapoor <chirayu.kapoor@suse.com>
2023-09-25 17:39:33 +05:30