1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-16 09:16:38 +00:00
Commit graph

134 commits

Author SHA1 Message Date
Arthur Silva Sens
cc47b1e160
Prometheus Agent support (#5385)
* Introduce PrometheusAgent CRD

Operator is able to run with PrometheusAgent resources in the cluster, but doesn't do anything with them yet. This is the first step to implement the Prometheus Agent Operator.

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>

* Re-enable configmap and secret informers

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 1a71db03db6b41cd0cee9d0193b6ea3884bb5bae)

* Implement Resolve for Agent operator

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 49558165b9178b6c1bda833a48f7bfe1468c942a)

* Operator is able to create Agent Statefulset

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 7a3826683c92f917312c866a2bb6401dc54b95f2)

* Agent Operator creates secret from ServiceMonitors

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 11232669befb4de9d0765dfadfe5fae00b575f11)

* Agent Operator creates secret from PodMonitors

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 5ae551734bac2babc056c86443d15729d43d12b0)

* Agent Operator creates secret from Probes

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 9637612fbbe9617335fd6188271ebf2cc74a3693)

* Agent Operator configures remote-write

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit c4bdf230d527e19f8b77ca5f938b9254ed344f7d)

* Agent Operator configures additionalScrapeConfigs

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit d9f28db764641e682bf4fe8963310f791979c387)

* Implement UpdateStatus

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit c546ecaf3e8b73916df44a8f48b279c6988e32f5)

* Add resource handlers

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 5b83359445e20f88ea5fff80302fce62d58058b9)

* make format

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
(cherry picked from commit 6507964ba28f4ebf32ce3203db752444e288c45d)

* Only start agent operator if there is enough permission

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>

* Remove node endpoint syncronization from agent operator

The server operator already handles it

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* Move PrometheusAgent API from v1 to v1alpha1

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* pkg/prometheus/agent/statefulset.go: Fix image concatenation

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* Avoid name colisions between Prometheus Agents and Servers

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* agent/createOrUpdateConfigurationSecret: Do not handle case where servicemonitor and podmonitor selectors are empty

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* make format

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* make --always-make format generate

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* Remove unused fields from Operator struct

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>

* Add deployment mode as new selector label for agent/server ssts

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>

* WIP: Fix OperatorUpgrade e2e test

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>

* Panic if type casting PrometheusInterface doesn't return Prometheus/Agent

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>

* Detect whether PrometheusAgent CRD is installed or not

If the operator's service account has all permissions on the cluster and
the CRD isn't installed then the PrometheusAgent controller will run
but fail because of the absence of the CRD.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Create dedicated governing service for Prometheus agent

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

---------

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2023-03-27 12:30:01 +02:00
Simon Pasquier
4054641307
Remove /apis endpoints (#5396)
/apis was a workaround for getting status about the Prometheus objects
managed by the operator. The status subresource is available since
v0.56.0 and there's no reason for not using the native Kubernetes way
rather than the operator API.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-03-21 12:42:58 +00:00
Arthur Silva Sens
92efa1792f
Prepare package organization for PrometheusAgent (#5371)
* Prepare package organization for PrometheusAgent

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

* Check Prometheus  major version during config generation

Signed-off-by: ArthurSens <arthursens2005@gmail.com>

---------

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2023-03-03 11:40:50 +01:00
Manuel Rüger
7fefa2bca3 Set Read/ReadHeaderTimeouts on http.Server
Default to 30s

via gosec linter - G112: Potential slowloris attack

https://medium.com/a-journey-with-go/go-understand-and-mitigate-slowloris-attack-711c1b1403f6
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-02-14 17:30:31 +01:00
Simon Pasquier
2f2ade6938 cmd/operator: fix alertmanager-config-namespaces CLI arg
The CLI argument wasn't bound to the correct variable.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2022-03-07 11:52:36 +01:00
Philip Gough
961c3336c8
Merge pull request #4494 from PhilipGough/webhook-decoupling
Add standalone admission webhook
2022-02-21 12:16:00 +00:00
Philip Gough
c3208927e5 cmd:operator: Add deprecation warning to validation errors metrics
The information in these metrics is available natively in Kube v1.16+
See https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhook-metrics
2022-02-03 11:19:29 +00:00
Will Tran
023feeca9d
use AlertmanagerConfigAllowList for alertmanager secret informer (#4455)
* build(deps): bump github.com/prometheus/client_golang

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.12.0 to 1.12.1.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.12.0...v1.12.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add a new flag alertmanager-config-namespaces to watch

AlertmanagerConfig namespaces require Secrets list/watch, so separating
this config from general --namespaces provides better control over which
namespaces to allow Secrets RBAC access.

Fixes #3544

Signed-off-by: Will Tran <will@autonomic.ai>

* Use AlertmanagerConfigAllowList for alrtCfgInfs and nsAlrtCfgInf as well

Signed-off-by: Will Tran <will@autonomic.ai>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-02 13:30:44 +01:00
Philip Gough
fce96dac90 server: Move TLS configuration out of operator 2022-02-01 16:09:00 +00:00
bestgopher
d5313c8da5
use make to alloc memory 2022-01-04 16:43:55 +08:00
Philip Gough
e9861e7bdb
Consolidate logging setup into a standalone package (#4445)
* internal: add a package to consolidate logging setup

* cmd:operator: Setup logger via internal package

* cmd:reloader: Setup logger via internal package
2021-12-13 11:09:57 +01:00
Philip Gough
da97db812a
Adds validating webhook for AlertManagerConfig (#4338)
* alertmanager: Expose validation function for AmConfig CR

* admission: Extend admission controller for AmConf validation

* cmd:operator: Register metrics for am validating webhook

* test:e2e: Setup and test validating webhook for AmConf CR
2021-10-28 16:32:22 +02:00
Simon Pasquier
f1fed965bb *: switch to github.com/go-kit/log
Using github.com/go-kit/log instead of github.com/go-kit/kit reduces the
list of things this project depends on. This commit also removes the
wrapper for k8s.io/klog because none of the k8s libraries depend on it
anymore.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-07-22 16:22:28 +02:00
JJJJJones
63b3840645
removal of deprecated config-reloader resource flags for #3883 (#3884)
* removal of deprecated config-reloader resource flags for #3883

* remove rc* specific code from cmd/operator/main.go that should never run

* formatting issue corrected

* make format generate results
2021-07-15 12:28:03 +02:00
paulfantom
4166f11957
cmd,pkg: fix linter issues 2021-07-05 11:47:01 +02:00
Maksim Nabokikh
9fcdff92e3
Bump golangci-lint and switch to the revive (#4089)
* Bump golag-ci lint version to 1.40.1

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* Bump linter on CI

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* Fix promlinter and examples

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
2021-06-09 13:32:23 +02:00
Jan Fajerski
1889557ebe operator: don't wait to retry watching certificate reloader
`r.Watch` will wait already.

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-06-04 17:18:44 +02:00
Maxime Therreault
65e18f6f3b
Adjust flags on stdlib logger used by HTTP server to get logger adapter extract fields consistents with operator base logger (#3968)
Co-authored-by: Maxime Therreault <maxime.therreault@ubisoft.com>
2021-04-14 16:49:06 +02:00
Simon Pasquier
539108b043
*: cut v0.47.0 (#3976)
* Revert "Optimize asset secret update logic. (#3933)"

This reverts commit b18d542c67.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* *: cut v0.47.0

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-04-13 15:09:18 +02:00
Simon Pasquier
efbe51d986 *: fix errcheck errors
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-03-26 14:08:59 +01:00
Simon Pasquier
430e29d2a4 *: fix staticcheck errors
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-03-23 11:50:36 +01:00
Simon Pasquier
25e085a357
*: fix golint errors (#3924)
Also fix the missing Thanos Ruler and Alertmanager collector metrics.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-03-23 11:21:14 +01:00
JJJJJones
f021bea748 make rcCPU and rcMemory globals so checks against them can be relocated to Main(), where flag parsing is done. Add in constants for default values. Check that resourcec cvalues are valid 2021-02-22 16:22:38 -06:00
JJJJJones
191650f073 quote wrap for clarity 2021-02-19 14:39:14 -06:00
JJJJJones
3f7505524c Warn users about the incoming deprecation of flags 2021-02-19 14:37:17 -06:00
JJJJJones
ffcfff195f correct typo in the name of flag \--config-reloader-cpu-limit\ 2021-02-08 17:21:58 -06:00
JJJJJones
c072aa9b7a correct deprecation notices, 2 versions notice not 3 2021-02-08 16:47:38 -06:00
JJJJJones
7cc114dd02 remove ReloaderConfig.CPU and ReloaderConfig.Memory and move logic prioritizing flagset CPU/memory requests/limits over generic CPU/Memory flags to cmd/operator/main.go 2021-02-08 14:23:09 -06:00
JJJJJones
24cbd7a63a flag invalidation description 2021-02-08 13:51:14 -06:00
JJJJJones
729a9f8f1d update flags to use request instead of req 2021-02-08 13:48:29 -06:00
JJJJJones
c1dedf9bb1 add deprecation notices to flags 2021-02-08 13:46:13 -06:00
JJJJJones
75ae5ef385 add flags for CPU/Memory requests/limits 2021-02-04 13:11:15 -06:00
Simon Pasquier
072f7be753
cmd/operator: remove deprecated --config-reloader-image flag (#3773)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-01-05 11:22:57 +01:00
Simon Pasquier
6f3131aef4 cmd/operator: improve HTTP server's logging
This change configures the HTTP server with the same logger we use
everywhere else.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-01-05 10:01:25 +01:00
Cédric de Saint Martin
f5911ee04a operator cmd: set --config-reloader-memory to 50Mi instead of 25Mi.
New unified reloader takes more memory than the two previous ones.
2020-11-09 17:21:48 +01:00
Mateusz Gozdek
ce5107a421
Fix typos found by codespell (#3653)
By running the following command:

codespell -S .git,*.png,main,./go.sum -L ba

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
2020-11-06 17:28:46 +01:00
Chakradhar N R
243fc54010
kloggokit: #3326: Use klog-gokit for getting additional logs (#3630)
* kloggokit: #3326: Use klog-gokit for getting additional logs

* remove logtostderr from commadline args

* Added comment for why InitFlags is not needed.

* Addressing review comments

* Cleanup with go mod tidy

* after make generate

* fix failure

* fix failure
2020-11-06 09:52:12 +01:00
Simon Pasquier
ecc82e0427
Bump Go modules (#3607)
* *: switch to github.com/blang/semver/v4

* go.mod: bump github.com/brancz/kube-rbac-proxy

* Switch to github.com/evanphx/json-patch/v5

* Bump github.com/go-openapi/swag

* Bump github.com/google/go-cmp

* Bump github.com/hashicorp/go-version

* Bump github.com/mitchellh/hashstructure

* Bump github.com/prometheus-community/prom-label-proxy

* Bump github.com/prometheus/client_golang

* Bump github.com/prometheus/prometheus and k8s dependencies

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Bump golang.org/x/sync

* Update to k8s.io/klog/v2
2020-10-21 13:18:52 +02:00
Mateusz Szostok
2fda6f185b
Add more descriptive binary version information (#3592)
* Add more descriptive binary version information

It is inspired by the Prometheus implementation and fully compatible with it:
https://github.com/prometheus/common/blob/v0.14.0/version/info.go

* Use the promethus common library
2020-10-21 09:46:45 +02:00
Simon Pasquier
55baf034c4
*: use interface value instead of pointer (#3586)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-10-14 11:54:29 +02:00
Simon Pasquier
dcf34c55bc *: use a single reloader for Prometheus
This change gets rid of the additional reloader that was deployed in the
Prometheus pod to monitor rules file.

It also changes the Alertmanager and Thanos ruler statefulsets to use
the container image from the `--prometheus-config-reloader` flag instead
of `--config-reloader-image`. We pick `prometheus-config-reloader`
because it supports gzipped configuration file and is "smarter" about
when to reload the configuration (e.g. it checks that the content on
disk has effectively changed before reloading).

The `--config-reloader-image` of Prometheus operator is deprecated (e.g.
it isn't used anywhere by the operator) and it may be removed in a
future release (but not before v0.45).

Since the Prometheus config reloader doesn't watch only rule directories
anymore (e.g. for Alertmanager it watches mounted secrets), it gets a
new `--watched-dir` flag that replaces the `--rules-dir` flag.

Finally the config reloader can be configured to expose metrics with the
`--listen-address` flag. The metrics are:
* `reloader_config_apply_operations_failed_total`
* `reloader_config_apply_operations_total`
* `reloader_reloads_failed_total`
* `reloader_reloads_total`
* `reloader_watch_errors_total`
* `reloader_watches`
* `reloader_watch_events_total`

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-09-25 17:21:02 +02:00
Simon Pasquier
3b2e17d714 Instrument client-go requests
This change adds 3 metrics tracking client-go requests to the Kubernetes
API:

* `prometheus_operator_kubernetes_client_http_requests_total`, counter
  with a `status_code` label.
* `prometheus_operator_kubernetes_client_http_request_duration_seconds`,
  summary with a `endpoint` label.
* `prometheus_operator_kubernetes_client_rate_limiter_duration_seconds`,
  summary with a `endpoint` label.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-09-04 16:03:13 +02:00
Simon Pasquier
053da63f0b *: pass context.Context to client-go functions
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-09-03 14:13:31 +02:00
paulfantom
67780ccc45
repository migration to prometheus-operator organization 2020-08-05 13:13:46 +02:00
Mathis Raguin
08c18be294
prometheus/operator: rename CLI options to reflect that it's a field selector 2020-07-23 11:51:26 +02:00
Mathis Raguin
87d8b8cd47
prometheus/operator: add SecretListWatchSelector
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-22 17:13:34 +02:00
Paul Gier
461cfbf5a9 improve CLI arg help for default images 2020-07-09 17:53:22 -05:00
Damien Grisonnet
ad631b0997 cmd: fix instance-selector options description
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-04-23 13:19:08 +02:00
Damien Grisonnet
a929151823 cmd: remove with-validation option
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-04-23 13:19:08 +02:00
Damien Grisonnet
2acae2596a cmd: remove crd-kinds option
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-04-23 13:19:08 +02:00