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

66 Commits

Author SHA1 Message Date
Simon Pasquier
f61936b22d test: add test for #8312
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2026-02-04 10:17:05 +01:00
Simon Pasquier
036a56054c fix: unblock feature-gates CI
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2025-03-14 15:02:51 +01:00
dongjiang
6cfb80cfbb chore: Update golangci-lint to v1.63.4 (#7250)
* update golangci-lint to v1.63.4

Signed-off-by: dongjiang <dongjiang1989@126.com>
2025-01-09 15:51:33 +05:30
perebaj
dda3e72b6e replace go kit log in resource selector 2024-08-08 20:06:08 -03:00
Ha Anh Vu
6412481329 Allow Prometheus Agent operator to create DaemonSet (#6708)
* Allow Prometheus Agent operator to create DaemonSet
2024-07-31 16:04:53 +02:00
Arthur Silva Sens
5bd0d839f9 Merge pull request #6621 from prometheus-operator/featuregate-testframework
e2e/framework: Allow setting feature-gates when creating Prometheus-Operator
2024-05-29 11:10:26 -03:00
Simon Pasquier
677c2d565f chore: fix testScrapeConfigKubernetesNodeRole()
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-05-29 09:49:15 +02:00
Arthur Silva Sens
7d6467b898 e2e/framework: Allow setting feature-gates when creating Prometheus-Operator
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
2024-05-27 14:46:50 -03:00
Arthur Silva Sens
921158afe3 Enable depguard in tests/framework/framework.go
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
2023-10-25 16:52:43 -03:00
Simon Pasquier
8944ea9033 chore: add e2e test for config reloader resources
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-10-16 13:30:10 +02:00
Simon Pasquier
e274af7fbc fix: reconcile on namespace changes
When the operator was configured to select only a limited number of
namespaces, it would not watch for namespace changes. It means that the
operator may not reconcile when a namespace label is added/removed
(affecting which objects should be selected or not).

This change enables the operator to use a privileged namespace
lister/watcher whenever the service account has the needed permissions.

**IMPORTANT:** it also requires Kubernetes >= 1.22 to be effective but
the operator will degrade to the suboptimal implementation without watch
if this condition isn't met.

Closes #3847

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-09-21 09:18:59 +02:00
Simon Pasquier
03cd78e557 chore: use ptr.To() function
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-08-23 10:55:49 +02:00
Simon Pasquier
12580d663a chore: fix imports order
The commit also enables the gci linter in the golangci-lint
configuration.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-06-15 10:03:42 +02:00
Guillaume Hérail
822cf9348c test: Add ScrapeConfig end to end tests (#5575)
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>
2023-05-25 17:37:24 +02:00
Simon Pasquier
2b5d2b4e40 chore: remove obsolete code
This change addresses a few TODOs that waited on v0.65.x being
available.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-05-22 17:13:23 +02:00
Guillaume Hérail
b07f92c4ed feat: Add ScrapeConfig CRD (#5335)
* api/v1alpha1: Add ScrapeConfig CRD

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* api/v1: Add ScrapeConfig selectors to Prometheus

Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* prometheus/server/operator: Add ScrapeConfig selection logic

Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>

* prometheus/server/operator: Add static_config generation from ScrapeConfig

Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* prometheus/server/operator: Add file_sd_config and http_sd_config generation from ScrapeConfig

Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* prometheus/server/operator: Check ScrapeConfig permissions before trying to select them

* prometheus/server/operator: Check that the ScrapeConfig CRD is installed

* fix: Apply suggestions from Joao

Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* fix: Apply suggestion from mrueg

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* fix: Properly generate scrape configurations for PrometheusAgent

Also check that the ScrapeConfig CRD is installed and that the operator has the
right permissions.

* fix: Address Joao's points

Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* fix: ScrapeConfig only needs get,list,watch

References:
- https://github.com/prometheus-operator/prometheus-operator/pull/5335#discussion_r1162861091

Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>

* fix: Implement ScrapeConfig ResourceEventHandlerFuncs

References:
- https://github.com/prometheus-operator/prometheus-operator/pull/5335#discussion_r1162901259

Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>

* fix: Missing permissions for prometheus-operator's serviceaccount

* fix: Address Arthur's feedback

Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>

* fix: Address Simon's feedback

Co-authored-by: Simon Pasquier <spasquie@redhat.com>

* feat: Add ScrapeConfig.HonorTimestamps

* feat: Add ScrapeConfig.HonorLabels

* fix: Address feedback from Joao

Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>

* fix: Address Simon's feedback

Co-authored-by: Simon Pasquier <spasquie@redhat.com>

* chore: Finalize the move to CRDChecker

* fix: Include ScrapeConfig in e2e tests

* docs: spec.ProbeSelector -> spec.probeSelector

* fix: Don't addEventHandler if we don't have a scrape confirm informer

* fix: Address feedback from Simon and Philip

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Philip Gough <philip.p.gough@gmail.com>

* fix: Wrap error with a better error message

* fix: Linting

---------

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Co-authored-by: Manuel Rüger <manuel@rueg.eu>
Co-authored-by: Philip Gough <philip.p.gough@gmail.com>
2023-05-03 15:54:31 +01:00
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
2ce4214759 Enforce TLS secret for the admission webhook (#5112)
The admission webhook service has to deployed with TLS enabled because
the Kubernetes API only supports webhook URLs with a "https://" scheme.

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

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2022-11-03 09:42:29 +00:00
Simon Pasquier
7062b2e957 jsonnet: tune admission webhook deployment for HA (#5099)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2022-10-14 13:32:40 +00:00
Wen Long
46fc96b096 test: re-add e2e test for Prometheus Operator upgrade path (#5015)
* test: re-add e2e test for Prometheus Operator upgrade path

PR #4758 was reverted because it broke CI. CI failed because it
was out of sync with the main branch for a long time and some of
the function signature changed.

This commit is based on PR #4758 and fix CI function signature
error.

Fixes: #4067

Signed-off-by: heylongdacoder <heylongdacoder@gmail.com>

* test: handle Prometheus observedGeneration status check

Current version is 0.59.1. The Prometheus CRD observedGeneration
will be released at version 0.60.0. This commit set the framework
version to next minor version and only check observedGeneration
status when operator version >= 0.60.0.

Signed-off-by: heylongdacoder <heylongdacoder@gmail.com>

* test/framework: cleanup 0.57.0

Signed-off-by: heylongdacoder <heylongdacoder@gmail.com>

Signed-off-by: heylongdacoder <heylongdacoder@gmail.com>
2022-09-20 11:27:08 +01:00
Philip Gough
9b91b599db Revert "test: Add e2e test for Prometheus Operator Upgrade Path" 2022-09-07 17:14:00 +01:00
heylongdacoder
e24a78f1f8 Update:
- add operatorVersion, opImage, exampleDir, resourcesDir as framework struct field
- create previousVersionFramework singleton in main_test.go
- set createResourceAdmissionHooks to true for CreateOrUpdatePrometheusOperator in upgradepath_test.go to also experience the upgrade of webhook server
- for deployment and service, remain the Create function(CreateDeployment) and create a new CreateOrUpdate function(CreateOrUpdateDeploymentAndWaitUntilReady), since the method to wait for a upgrade operation to be done is different from the create operation.

Signed-off-by: heylongdacoder <heylongdacoder@gmail.com>
2022-06-12 21:58:37 +08:00
heylongdacoder
6689274692 test: Add e2e test for Prometheus Operator Upgrade Path
Fixes #4067

Signed-off-by: heylongdacoder <heylongdacoder@gmail.com>
2022-06-10 01:48:13 +08:00
Simon Pasquier
1829e379cd *: add v1beta1 for AlertmanagerConfig CRD (#4709)
* *: add v1beta1 for AlertmanagerConfig CRD

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

* *: implement conversion webhook for AlertmanagerConfig

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

* *: add jsonnet support for CRD conversion webhook

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

* test: configure conversion webhook for AlertmanagerConfig

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

* test/e2e: add test for v1alpha1<->v1beta1 conversion

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

* Documentation: update webhook documentation

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

* pkg/apis/monitoring/v1beta1: remove Regex field from Matcher type

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

* *: rename muteTimeIntervals field to timeIntervals (v1beta1)

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

* *: restore short name for AlertmanagerConfig

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

* pkg/admission: add unit test for conversion webhook

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

* pkg/apis/monitoring/v1beta1: replace v1.SecretKeySelector by SecretKeySelector

v1.SecretKeySelector has an `Optional` field which doesn't make sense
in the context of the AlertmanagerConfig CRD. Not depending on an
external type also means that we can enforce that key and name values
are not empty.

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

* *: regenerate

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

* *: make AlertmanagerConfig v1beta1 an opt-in choice

Enabling by default AlertmanagerConfig v1beta1 by default means that
users would have to configure the conversion webhook and it must be
performed in advance or at the same time users upgrade to the latest
operator version. To offer a smoother transition, we offer
AlertmanagerConfig v1beta1 as an opt-in feature: it's neither included
in the bundle.yaml file nor in the example/prometheus-operator-crd/
manifests.

People that want to enable v1beta1 should use the
example/prometheus-operator-crd-full manifests. For jsonnet users, the
Prometheus operator jsonnet library has a new
`enableAlertmanagerConfigV1beta1` configuration option that can be set
to `true`.

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

* *: add Telegram support in v1beta1

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

* *: synchronize with latest main changes

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

* Documentation/user-guides/webhook.md: clarify mutation webhook

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

* example: regenerate

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2022-05-31 11:11:00 +02:00
Simon Pasquier
0c2e2a750b *: use consistent image name for the admision webhook
The end-to-end tests and jsonnet code were using
`quay.io/prometheus-operator/prometheus-admission-webhook` which doesn't
exist.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2022-03-16 17:16:13 +01:00
Philip Gough
3444be3637 test:framework: Deploy standalone webhook server 2022-02-16 10:21:57 +00: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
Jayapriya Pai
d67f5e4443 test/e2e: Update method calls to pass context
Need to update method signatures since removing context from struct

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
2021-09-27 17:38:52 +05:30
Jayapriya Pai
822706545b test/framework: Remove context from framework struct
Pass context as argument to methods

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
2021-09-27 17:38:52 +05:30
Jayapriya Pai
a10ba4a4e5 Remove context.TODO() from client_go function calls (#4117)
* test/framework/*.go: Remove context.TODO() from framework

Converts most of the func to framework methods

Fixes #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* /test/e2e/*.go: Remove context.TODO() from e2e tests

Update function calls to refelect method changes

Fixes #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* pkg/alertmanager/amcfg_test.go: Remove context.TODO()

Add context field in testcase

Fixes #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* pkg/k8sutil/k8sutil_test.go: Remove context.TODO()

Add context field in testcase

Fixes #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* test/framework/*.go: Fix lint errors

* pkg: Move context to testing function

* test: Update NewTestCtx method return type

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* test/e2e/*.go : Fix Nit

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* test/framework: Remove extra spaces to fix generate

* test/framework/namespace.go: Change funcs to receivers

* test/e2e: Propagate the func to receiver change
2021-06-29 17:33:14 +02:00
Jayapriya Pai
05a8e6f8cc Remove context.TODO() from client_go function calls (#4104)
* pkg/prometheus/operator.go: Remove context.TODO()

Related to #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* test/framework/*.go: Remove context.TODO()

Propagate context from framework struct instead of using context.TODO()

Related to #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* test/e2e/*.go Remove context.TODO()

Propagate context from Framework struct instead of using context.TODO()

Related to #3158

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
2021-06-16 12:17:14 +02: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
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
Frederic Branczyk
08823836ed prometheus: Implement sharding mechanism 2020-11-02 11:10:55 +01:00
Gerard Ryan
a3a014eda9 Create AM config file from base config and CRs 2020-10-13 21:19:09 +01:00
Sergiusz Urbaniak
ec3a83bae0 test/e2e: test allowlist against rolebindings, not cluster role bindings 2020-09-04 17:08:33 +02:00
paulfantom
67780ccc45 repository migration to prometheus-operator organization 2020-08-05 13:13:46 +02:00
Arno Uhlig
35fd2dd9e4 rename blackbox to probe
Signed-off-by: Arno Uhlig <arno.uhlig@sap.com>
2020-06-27 20:33:03 +02:00
Arno Uhlig
536493a8be blackboxMonitor
Signed-off-by: Arno Uhlig <arno.uhlig@sap.com>
2020-06-27 20:30:48 +02:00
Damien Grisonnet
cdc259dbac test: add CRD rbac rules manually
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-04-23 13:58:39 +02:00
Damien Grisonnet
36431d31a2 test: update framework to handle unmanaged CRDs
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-04-23 13:58:38 +02:00
Joe Lanford
bfbb40ae56 *: update kubernetes deps to v1.18.2
This commit bumps the kubernetes version dependencies from v1.17
to v1.18.

The kubernetes client-go library introduced breaking
changes in v1.18 by adding context.Context to many of its function
signatures. The kubernetes-sigs/clientgofix tools was used in this
commit to automatically add the necessary context.TODO() arguments
to all client-go usage in the repo.

Fixes #3146
2020-04-21 08:53:31 -04:00
Paul Gier
3c34cbfc32 cmd/operator: make TLS activation explicit via CLI flag
Add CLI flag for activating web server TLS.
Always use reloader for reading TLS certificates instead of loading
manually at startup.
2020-04-16 14:52:18 -05:00
Paul Gier
438ec238c4 add server tls reload and tests
Adds periodic certificate reload for operator web server TLS,
and adds basic e2e test.
2020-04-16 09:36:16 -05:00
Paul Gier
461c6c621a add e2e test for CRD creation
Checks that CRDs are created and that preserveUnknownFields is set
to false.
2019-12-10 20:58:17 -06:00
Max Leonard Inden
fd92cbfe94 pkg/prometheus: Enable users to configure bearer token from secret
To configure a bearer token users could only specify a file path in the
service monitor, pointing to a bearer token file in the Prometheus
container. This enables hostile users, being able to configure a service
monitor and controlling the scrape target, to retrieve arbitrary files
in the Prometheus container.

In cases where users can not be trusted, this patch adds an option to
disallow the above file path specification and replaces it by a secret
reference. This secret has to be in the same namespace as the service
monitor, shrinking the attack vector.

pkg/prometheus: Add option to deny file system access through service monitors

ArbitraryFSAccessThroughSMsConfig enables users to configure, whether
a service monitor selected by the Prometheus instance is allowed to use
arbitrary files on the file system of the Prometheus container. This is
the case when e.g. a service monitor specifies a BearerTokenFile in an
endpoint. A malicious user could create a service monitor
selecting arbitrary secret files in the Prometheus container. Those
secrets would then be send with a scrape request by Prometheus to a
malicious target. Denying the above would prevent the attack, users can
instead use the BearerTokenSecret field.

test/basic-auth-test-app: Add mTLS endpoint

pkg/prometheus: Enable users to configure tls from secret

pkg/prometheus/operator: Validate TLS configs before retrieving assets

Before retrieving TLS assets from Kubernetes secrets for a given service
monitor, make sure the user did not specify both file and secret
reference, e.g. both `CAFile` and `CASecret`.

test: Rename basic-auth-test-app to instrumented-sample-app

Given that the basic-auth-test-app not only supports basic auth, but
also bearer token as well as tls authentication, this patch renames the
app to a more generic name.

test/e2e/prometheus_test: Test ArbitraryFSAccessThroughSM option for tls

The Prometheus custom resource has the option to disable arbitrary
filesystem access configured through service monitors. This commit adds
an end-to-end test for this option in combination with the TLS
configuration via files or secret references in service monitors.

pkg/prometheus/operator: Move check for arbitrary fs access into func
2019-10-07 13:07:05 +02:00
Sergiusz Urbaniak
b9571bdee8 cmd/operator: add [prometheus,alertmanager]-instance-namespaces cmdline parameter
This adds two new command line parameters to prometheus operator:

--prometheus-instance-namespaces: Namespaces where Prometheus custom resources
and corresponding Secrets, Configmaps and StatefulSets are watched/created.
If set this takes precedence over --namespaces or --deny-namespaces
for Prometheus custom resources.

--alertmanager-instance-namespaces: Namespaces where Alertmanager custom resources
and corresponding StatefulSets are watched/created.
If set this takes precedence over --namespaces or --deny-namespaces
for Alertmanager custom resources.

This allows fine grained configuration of reconcilation for prometheus/alertmanager
instances to certain namespaces while allow- or deny-listing other namespaces for less
critical custom resources like ServiceMonitors, PodMonitors, etc.
2019-10-01 11:21:04 +02:00
Sergiusz Urbaniak
b42a28407b *: support namespace denylists
Currently, it is possible to explicitly watch for namespaces with the --namespaces option.
If unset, all namespaces are being watched.

The reverse is not possible today, namely exclude (deny) namespaces from being watched.
This fixes it by introducing the --deny-namespaces option.
It is mutually exclusive with --namespaces.
2019-08-16 15:59:07 +02:00
Arno Uhlig
672ded9201 fix test framework; make generate
Signed-off-by: Arno Uhlig <arno.uhlig@sap.com>
2019-06-11 15:02:07 +02:00
Arno Uhlig
b91d61b3f3 fix rbac for podmonitors 2019-06-11 11:20:24 +02:00