Compare commits

..

546 Commits

Author SHA1 Message Date
Paweł Krupa
864ca1e773 Merge pull request #1448 from andrein/cherry-pick-1445
Cherry-pick grafana LDAP into release-0.9
2021-10-20 13:50:04 +02:00
Andrei Nistor
822f885d67 add grafana ldap example
(cherry picked from commit 882484daf1)
2021-10-19 17:08:11 +03:00
machinly
184a6a452b add grafana ldap support
(cherry picked from commit ce7007c568)
2021-10-19 17:08:11 +03:00
Paweł Krupa
b6ab321ac8 Merge pull request #1443 from prometheus-operator/automated-updates-release-0.9 2021-10-18 10:42:13 +02:00
dgrisonnet
6e67e7fdbb [bot] [release-0.9] Automated version update 2021-10-18 07:39:34 +00:00
Damien Grisonnet
ad19693121 Merge pull request #1432 from prometheus-operator/automated-updates-release-0.9
[bot] [release-0.9] Automated version update
2021-10-12 09:20:41 +02:00
dgrisonnet
8ccd82e40a [bot] [release-0.9] Automated version update 2021-10-11 07:39:30 +00:00
Damien Grisonnet
c1fc78c979 Merge pull request #1405 from PhilipGough/bp-9
Adjust dropped metrics from cAdvisor
2021-09-28 12:00:16 +02:00
Philip Gough
4e96f7bed6 Adjust dropped metrics from cAdvisor
This change drops pod-centric metrics without a non-empty 'container' label.

Previously we dropped pod-centric metrics without a (pod, namespace) label set
however these can be critical for debugging.

Keep 'container_fs_.*' metrics from cAdvisor
2021-09-28 10:17:59 +01:00
Damien Grisonnet
49eb7c66f6 Merge pull request #1400 from prometheus-operator/automated-updates-release-0.9
[bot] [release-0.9] Automated version update
2021-09-27 11:11:29 +02:00
dgrisonnet
b4b365cead [bot] [release-0.9] Automated version update 2021-09-27 07:39:22 +00:00
Damien Grisonnet
fdcff9a224 Merge pull request #1366 from dgrisonnet/pin-kubernetes-grafana
Pin kubernetes-grafana on release-0.9
2021-09-07 09:17:15 +02:00
Damien Grisonnet
2640b11d77 jsonnet: pin kubernetes-grafana on release-0.9
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-09-06 20:07:07 +02:00
Simon Pasquier
9ead6ebc53 Merge pull request #1349 from prometheus-operator/automated-updates-release-0.9
[bot] [release-0.9] Automated version update
2021-08-25 12:03:25 +02:00
simonpasquier
62a5b28b55 [bot] [release-0.9] Automated version update 2021-08-25 09:37:18 +00:00
Damien Grisonnet
0ca8df7a35 Merge pull request #1338 from dgrisonnet/cut-release-0.9
Cut release 0.9
2021-08-20 13:44:40 +02:00
Damien Grisonnet
4cfbfae071 Add release-0.9 CHANGELOG
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-19 16:43:34 +02:00
Damien Grisonnet
8587958cf0 Update compatibility matrix with release-0.9
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-19 16:43:34 +02:00
Damien Grisonnet
eca67844af jsonnet: pin and update jsonnet depdencies
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-19 16:41:53 +02:00
Damien Grisonnet
0df510d1fa Merge pull request #1337 from dgrisonnet/kubernetes-1.22
Test against Kubernetes 1.22
2021-08-18 19:03:21 +02:00
Damien Grisonnet
da35954628 .github: drop support for 1.20 on main
According to our policy, main branch of kube-prometheus should support
the 2 latest versions of Kubernetes. These changes update the tests and
the compatibility matrix to reflect that.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-18 17:53:40 +02:00
Damien Grisonnet
b5ec93208b jsonnet: drop deprecated etcd metric
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-18 17:27:50 +02:00
Damien Grisonnet
518c37d72d .github: test against Kubernetes 1.22
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-18 14:04:33 +02:00
Paweł Krupa
35397089d1 Merge pull request #1334 from dgrisonnet/prometheus-adapter-v0.9.0
Update prometheus-adapter to v0.9.0
2021-08-17 18:31:40 +02:00
Damien Grisonnet
45adc03cfb jsonnet: update prometheus-adapter to v0.9.0
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-17 18:05:45 +02:00
Damien Grisonnet
c1fa4971e6 Merge pull request #1325 from paulfantom/fix-1324
jsonnet: set thanos config to null by default
2021-08-17 11:20:47 +02:00
Damien Grisonnet
c69f3b4e62 Merge pull request #1330 from prometheus-operator/automated-updates-main
[bot] [main] Automated version update
2021-08-17 10:18:47 +02:00
dgrisonnet
6ade9e5c7d [bot] [main] Automated version update 2021-08-17 08:05:49 +00:00
Paweł Krupa
50c9dd2c6f Merge pull request #1326 from dgrisonnet/fix-versions-ci
Fix automated update in CI
2021-08-17 09:08:08 +02:00
Damien Grisonnet
24b0e699e4 .github: fix automated update in CI
Automated dependencies update in CI was failing whenever no new changes
were detected since git diff was returning 1.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-16 18:51:30 +02:00
paulfantom
c4113807fb jsonnet: set thanos config to null by default
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-08-16 15:16:52 +02:00
Paweł Krupa
89b57081f7 Merge pull request #1313 from dgrisonnet/enable-auto-updates
.github: enable auto updates on release branches
2021-08-16 10:16:56 +02:00
Paweł Krupa
2e8e88b882 Merge pull request #1320 from prometheus-operator/automated-updates-main
[bot] [main] Automated version update
2021-08-16 10:12:34 +02:00
paulfantom
ad3fc8920e [bot] [main] Automated version update 2021-08-16 08:04:51 +00:00
Paweł Krupa
8d36d0d707 Merge pull request #1317 from DimitrijeManic/wip/update-doc 2021-08-12 14:14:49 +02:00
Dimitrije Manic
ac75ee6221 Updates prometheus-rules documentation 2021-08-12 08:03:16 -04:00
Paweł Krupa
5452de1b43 Merge pull request #1315 from DimitrijeManic/wip/update-rule-selector 2021-08-11 16:27:38 +02:00
Dimitrije Manic
12cd7fd9ce Prometheus ruleSelector defaults to all rules 2021-08-11 10:16:24 -04:00
Damien Grisonnet
0ffe13c5d2 .github: enable auto updates on release branches
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-09 18:59:30 +02:00
Damien Grisonnet
6a150f4cc8 Merge pull request #1310 from paulfantom/full-path
jsonnet: use full dependency path
2021-08-09 17:53:22 +02:00
paulfantom
f6d6b30aed jsonnet: use full dependency path 2021-08-06 14:15:23 +02:00
Damien Grisonnet
33cc694f18 Merge pull request #1308 from PaytmLabs/feature/separate-thanos-rules
Create Thanos Sidecar rules separately from Prometheus ones
2021-08-05 16:19:01 +02:00
Maxime Brunet
961f138dd0 Add back _config.runbookURLPattern for Thanos Sidecar rules 2021-08-04 14:22:06 -07:00
Paweł Krupa
54d8f88162 Merge pull request #1307 from PaytmLabs/feature/addons/aws-vpc-cni
Turn AWS VPC CNI into a control plane add-on
2021-08-04 09:56:50 +02:00
Paweł Krupa
e931a417fc Merge pull request #1230 from Luis-TT/fix-kube-proxy-dashboard 2021-08-04 09:55:09 +02:00
Luis Vidal Ernst
0b49c3102d Added PodMonitor for kube-proxy 2021-08-03 08:31:49 +02:00
Maxime Brunet
0e7dc97bc5 Create Thanos Sidecar rules separately from Prometheus ones 2021-08-02 12:46:06 -07:00
Maxime Brunet
d3ccfb8220 Turn AWS VPC CNI into a control plane add-on 2021-08-02 11:26:33 -07:00
Damien Grisonnet
a330e8634a Merge pull request #1306 from paulfantom/fix-auto
.github: allow dispatching version updates manually and run on predefined schedule
2021-08-02 18:13:44 +02:00
paulfantom
1040e2bd70 .github: allow dispatching version updates manually and run on predefined schedule 2021-08-02 17:53:45 +02:00
Paweł Krupa
c3be50f61f Merge pull request #1303 from dgrisonnet/release-branch-update
Add automated dependency update to the remaining supported release branch
2021-08-02 17:50:28 +02:00
Paweł Krupa
075875e8aa Merge pull request #1298 from prometheus-operator/automated-updates-main
[bot] [main] Automated version update
2021-08-02 17:48:41 +02:00
Damien Grisonnet
9e8d1b0a72 .github: add remaining supported release branch
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-02 15:57:57 +02:00
dgrisonnet
e97eb0fbe9 [bot] [main] Automated version update 2021-08-02 13:37:08 +00:00
Paweł Krupa
1eeb463203 Merge pull request #1301 from dgrisonnet/fix-job-skip 2021-08-02 15:20:12 +02:00
Damien Grisonnet
844bdd9c47 .github: fix update version skip on release branch
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-02 15:11:41 +02:00
Paweł Krupa
0184f583d8 Merge pull request #1293 from dgrisonnet/release-branch-update 2021-08-02 13:51:59 +02:00
Damien Grisonnet
20f3cfaaeb .github: temporarily switch to manual updates
Temporarily switch to manual dependencies update workflow to test if it
is updated correctly across the different release branch.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-02 13:38:33 +02:00
Damien Grisonnet
7542a1b055 .github: automate release branch updates
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-08-02 13:32:32 +02:00
Paweł Krupa
d15f839802 Merge pull request #1292 from PaytmLabs/hotfix/eks/warm-ip-alert
eks: Revert back to `awscni_total_ip_addresses`-based alert
2021-08-02 13:22:13 +02:00
Maxime Brunet
b7fe018d29 eks: Revert back to awscni_total_ip_addresses-based alert 2021-07-31 11:37:12 -07:00
Paweł Krupa
b9c73c7b29 Merge pull request #1283 from prashbnair/node-veth
changing node exporter ignore list
2021-07-28 09:17:03 +02:00
Prashant Balachandran
09fdac739d changing node exporter ignore list 2021-07-27 17:17:19 +05:30
Paweł Krupa
785789b776 Merge pull request #1257 from Luis-TT/kube-state-metrics-kubac-proxy-resources 2021-07-27 12:36:26 +02:00
Paweł Krupa
bbdb21f08d Merge pull request #1282 from lanmarti/main
Add resource requests and limits to prometheus-adapter container
2021-07-27 12:36:01 +02:00
lanmarti
ed48391831 Add resource requests and limits to prometheus-adapter container 2021-07-27 12:19:51 +02:00
Damien Grisonnet
a1a9707f37 Merge pull request #1281 from prometheus-operator/paulfantom-patch-1
Use @prom-op-bot for automatic updates
2021-07-27 11:04:14 +02:00
Paweł Krupa
7b7c346aa0 Use @prom-op-bot for automatic updates 2021-07-27 08:33:08 +02:00
Damien Grisonnet
5f13edd1ea Merge pull request #1279 from prometheus-operator/automated-updates
[bot] Automated version update
2021-07-26 15:59:18 +02:00
paulfantom
05c72f83ef [bot] Automated version update 2021-07-26 13:44:14 +00:00
Paweł Krupa
93d6101bae Merge pull request #1277 from PaytmLabs/hotfix/eks/cni-relabel
eks: Fix CNI metrics relabelings
2021-07-24 11:33:29 +02:00
Maxime Brunet
3a98a3478c eks: Fix CNI metrics relabelings
Signed-off-by: Maxime Brunet <maxime.brunet@paytm.com>
2021-07-23 13:39:29 -07:00
Paweł Krupa
4965e45c15 Merge pull request #1276 from mrueg/fix-typo
node.libsonnet: Fix small typo
2021-07-23 07:44:20 +02:00
Manuel Rüger
acd1eeba4c node.libsonnet: Fix small typo
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2021-07-22 19:14:24 +02:00
Damien Grisonnet
45a466e3a7 Merge pull request #1267 from paulfantom/runbook_urlk
jsonnet/kube-prometheus: point to runbooks.prometheus-operator.dev
2021-07-22 17:40:04 +02:00
Damien Grisonnet
6d9e0fb6b2 Merge pull request #1273 from paulfantom/pr-template
.github: add PR template
2021-07-22 17:35:52 +02:00
paulfantom
755d2fe5c1 manifests: regenerate 2021-07-22 17:31:30 +02:00
paulfantom
cfe830f8f0 jsonnet/kube-prometheus: point to runbooks.prometheus-operator.dev
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-07-22 17:30:57 +02:00
paulfantom
94731577a8 .github: add PR template
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-07-22 17:24:57 +02:00
Luis Vidal Ernst
9c638162ae Allow customizing of kubeRbacProxy in kube-state-metrics 2021-07-21 13:57:05 +02:00
Paweł Krupa
acea5efd85 Merge pull request #1268 from paulfantom/alerts-best-practices
Alerts best practices
2021-07-21 09:32:32 +02:00
Paweł Krupa
cd4438ed02 Merge pull request #1250 from PhilipGough/MON-1741
jsonnet: Drop cAdvisor metrics without (pod, namespace) label pairs.
2021-07-20 14:26:43 +02:00
Philip Gough
463ad065d3 jsonnet: Drop cAdvisor metrics with no (pod, namespace) labels while preserving ability to monitor system services resource usage
The following provides a description and cardinality estimation based on the tests in a local cluster:

container_blkio_device_usage_total - useful for containers, but not for system services (nodes*disks*services*operations*2)
container_fs_.*                    - add filesystem read/write data (nodes*disks*services*4)
container_file_descriptors         - file descriptors limits and global numbers are exposed via (nodes*services)
container_threads_max              - max number of threads in cgroup. Usually for system services it is not limited (nodes*services)
container_threads                  - used threads in cgroup. Usually not important for system services (nodes*services)
container_sockets                  - used sockets in cgroup. Usually not important for system services (nodes*services)
container_start_time_seconds       - container start. Possibly not needed for system services (nodes*services)
container_last_seen                - Not needed as system services are always running (nodes*services)
container_spec_.*                  - Everything related to cgroup specification and thus static data (nodes*services*5)
2021-07-20 12:50:02 +01:00
paulfantom
46eb1713a5 jsonnet: remove unused alert unit tests as those are moved to alertmanager repository 2021-07-20 11:14:38 +02:00
paulfantom
02454b3f53 manifests: regenerate 2021-07-20 11:14:28 +02:00
paulfantom
8c357c6bde jsonnet: align alert annotations with best practices
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-07-20 10:59:49 +02:00
Paweł Krupa
414f8053d3 Merge pull request #1264 from prometheus-operator/automated-updates
[bot] Automated version update
2021-07-19 19:01:52 +02:00
paulfantom
1a3c610c61 [bot] Automated version update 2021-07-19 13:44:23 +00:00
Paweł Krupa
274eba0108 Merge pull request #1253 from ndegory/update-doc-for-0.8
update doc on Prometheus rule updates since release 0.8
2021-07-19 10:09:56 +02:00
Paweł Krupa
99ee030de3 Merge pull request #1259 from PaytmLabs/feature/eks/cni-relabel-instance
eks: Relabel instance with node name for CNI DaemonSet
2021-07-19 10:09:09 +02:00
Paweł Krupa
80bb15bedd Merge pull request #1255 from yeya24/fix-dashboards-definition-length-check 2021-07-19 09:56:09 +02:00
Maxime Brunet
7394929c76 eks: Relabel instance with node name for CNI DaemonSet 2021-07-17 11:28:38 -07:00
Nicolas Degory
9bc6bf3db8 update doc on Prometheus rule updates since release 0.8
Signed-off-by: Nicolas Degory <ndegory@axway.com>
2021-07-14 19:18:07 -07:00
Arthur Silva Sens
ae12388b33 Merge pull request #1256 from surik/update-kubernetes-mixin
Update kubernetes-mixin
2021-07-14 19:56:35 -03:00
Yury Gargay
9b08b941f8 Update kubernetes-mixin
From b710a868a9
2021-07-14 18:51:36 +02:00
ben.ye
43adca8df7 fmt again
Signed-off-by: ben.ye <ben.ye@bytedance.com>
2021-07-13 19:56:38 -07:00
ben.ye
90b2751f06 fmt code
Signed-off-by: ben.ye <ben.ye@bytedance.com>
2021-07-13 19:48:01 -07:00
ben.ye
dee7762ae3 create dashboardDefinitions if rawDashboards or folderDashboards are specified
Signed-off-by: ben.ye <ben.ye@bytedance.com>
2021-07-13 19:39:01 -07:00
Paweł Krupa
3a44309177 Merge pull request #1208 from paulfantom/cleanup 2021-07-08 12:18:36 +02:00
paulfantom
64cfda3012 legal cleanup
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-07-08 11:59:41 +02:00
Damien Grisonnet
97e77e9996 Merge pull request #1231 from dgrisonnet/fix-adapter-queries
Consolidate intervals used in prometheus-adapter CPU queries
2021-07-07 13:48:02 +02:00
Damien Grisonnet
0b3db5b6b6 Merge pull request #1245 from paulfantom/make-update
*: add "update" target to makefile and use it in automatic updater
2021-07-07 13:45:56 +02:00
Paweł Krupa
60b4b3023d Merge pull request #1244 from flurreN/prom-rules-hpa 2021-07-07 10:30:18 +02:00
paulfantom
ed2ffe9d05 *: add "update" target to makefile and use it in automatic updater
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-07-07 10:19:07 +02:00
Philip
3e6865d776 Generate kubernetes-mixin 2021-07-06 17:49:32 +02:00
Paweł Krupa
acd7cdcde0 Merge pull request #1243 from Kolossi/main
apply make fmt fixes to migration readme extracts
2021-07-06 14:01:31 +02:00
Paul Sweeney
552c9ecaea apply make fmt fixes to migration readme extracts 2021-07-06 12:18:07 +01:00
Paweł Krupa
a91ca001a9 Merge pull request #1235 from Kolossi/main
add example release-0.3 to release-0.8 migration to docs
2021-07-06 12:58:22 +02:00
Paul Sweeney
f95eaf8598 make fmt corrections to migration examples 2021-07-06 11:19:33 +01:00
Damien Grisonnet
b9563b9c2d jsonnet: improve adapter queries readability
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-07-05 15:29:45 +02:00
Damien Grisonnet
8812e45501 jsonnet: readjust prometheus-adapter intervals
Previously, prometheus-adapter configuration wasn't taking into account
the scrape interval of kubelet, node-exporter and windows-exporter
leading to getting non fresh results, and even negative results from the
CPU queries when the irate() function was extrapolating data.
To fix that, we want to set the interval used in the irate() function in
the CPU queries to 4x scrape interval in order to extrapolate data
between the last two scrapes. This will improve the freshness of the cpu
usage exposed and prevent incorrect extrapolations.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-07-05 15:28:25 +02:00
Paweł Krupa
3ab3947270 Merge pull request #1224 from sthaha/ignore-nw-eth0
jsonnet: kube-prometheus adapt to changes to veth interfaces names
2021-07-05 14:39:13 +02:00
Paul Sweeney
e77664f325 Update docs/migration-example/my.release-0.8.jsonnet - typo
Co-authored-by: Paweł Krupa <pawel@krupa.net.pl>
2021-07-05 11:43:51 +01:00
Paweł Krupa
496bab92a6 Merge pull request #1233 from sthaha/fix-make-manifests
Fix make manifests not building every time
2021-07-05 12:13:47 +02:00
Paweł Krupa
baf0774e09 Merge pull request #1237 from PhilipGough/ci-test
ci: Use wait command to ensure cluster readiness
2021-07-05 11:02:52 +02:00
Philip Gough
e38bc756a4 ci: Harden action to wait for kind cluster readiness 2021-07-05 09:56:28 +01:00
Paul Sweeney
fadb829b28 add example release-0.3 to release-0.8 migration to docs 2021-07-01 19:40:40 +01:00
Sunil Thaha
86d8ed0004 Fix make manifests not building every time
Make target `manifests` has a dependency on build.sh which if untouched
wouldn't generate the manifests after the first run. This patch fixes it
by removing the `build.sh` dependency

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
2021-07-01 12:10:48 +10:00
Sunil Thaha
0280f4ddf9 jsonnet: kube-prometheus adapt to changes to veth interfaces names
With OVN, the container veth network interface names that used to start
with `veth` has now changed to `<rand-hex>{15}@if<number>`(see Related
Links below).

This patch adapts to the new change introduced in ovn and ignores the network
interfaces that match `[a-z0-9]{15}@if\d+` in addition to those starting
with `veth`

Related Links:
  - https://github.com/openshift/ovn-kubernetes/blob/master/go-controller/vendor/github.com/containernetworking/plugins/pkg/ip/link_linux.go#L107
  - https://github.com/openshift/ovn-kubernetes/blob/master/go-controller/pkg/cni/helper_linux.go#L148

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
2021-07-01 12:01:19 +10:00
Paweł Krupa
f9fd5bd499 Merge pull request #1229 from paulfantom/new-version-only
scripts: use newer version when generating
2021-06-30 11:05:18 +02:00
paulfantom
654aa9bfac scripts: use newer version when generating 2021-06-29 10:08:20 +02:00
Paweł Krupa
ad63d6bb95 Merge pull request #1220 from fpetkovski/auto-update-deps
.github/workflows: automatically update jsonnet dependencies
2021-06-25 13:23:54 +02:00
Paweł Krupa
4a3191fc09 Merge pull request #1227 from fpetkovski/change-versions-update-schedule
.github/workflows: Update versions schedule to run each Monday
2021-06-25 13:23:09 +02:00
fpetkovski
321fa1391c .github/workflows: Update versions schedule to run each Monday 2021-06-25 11:36:50 +02:00
fpetkovski
d9fc85c0bb .github/workflows: automatically update jsonnet dependencies
This commit extends the versions github workflow to automatically update
jsonnet dependencies when the jsonnet code in upstream repositories changes.
2021-06-25 11:30:22 +02:00
Damien Grisonnet
2c5c20cfff Merge pull request #1216 from fpetkovski/prometheus-adapter-cipher-suites
jsonnet: disable insecure cypher suites for prometheus-adapter
2021-06-23 21:19:24 +02:00
Paweł Krupa
7932456718 Merge pull request #1218 from prometheus-operator/automated-updates
[bot] Automated version update
2021-06-23 16:06:21 +02:00
paulfantom
d0e21f34e5 [bot] Automated version update 2021-06-23 13:41:46 +00:00
Paweł Krupa
6ffca76858 Merge pull request #1221 from fpetkovski/update-alertmanager-branch
jsonnet: update alertmanager branch to main
2021-06-23 15:25:57 +02:00
fpetkovski
86b1207e1b jsonnet: update alertmanager branch to main
Alertmanager changed its default branch to main.
This commit updates the alertmanager branch to track the new default.

Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
2021-06-23 14:25:49 +02:00
Paweł Krupa
875d7cf4e8 Merge pull request #1219 from fpetkovski/update-deps 2021-06-23 13:57:53 +02:00
fpetkovski
0959155a1c jsonnet: update downstream dependencies
This commit updates all downstream dependencies

Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
2021-06-22 16:27:29 +02:00
fpetkovski
0ff173efea jsonnet: disable insecure cypher suites for prometheus-adapter
Running sslscan against the prometheus adapter secure port reports two
insecure SSL ciphers, ECDHE-RSA-DES-CBC3-SHA and DES-CBC3-SHA.

This commit removes those ciphers from the list.

Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
2021-06-22 14:17:09 +02:00
Paweł Krupa
94c5301c03 Merge pull request #1217 from PhilipGough/bz-1913618
Sync with kubernetes-mixin
2021-06-22 12:31:31 +02:00
Philip Gough
3a4e292aab Sync with kubernetes-mixin 2021-06-22 11:11:40 +01:00
Paweł Krupa
466eb7953f Merge pull request #1215 from prometheus-operator/automated-updates
[bot] Automated version update
2021-06-18 16:03:32 +02:00
paulfantom
ffea8f498e [bot] Automated version update 2021-06-18 13:50:44 +00:00
Arthur Silva Sens
8396c697fd Merge pull request #1212 from sanglt/main
Fix ingress path rules for networking.k8s.io/v1
2021-06-16 20:58:18 -03:00
Sang Le
4e43a1e16e Fix ingress rules for api networking.k8s.io/v1 - format code 2021-06-17 08:19:23 +10:00
Arthur Silva Sens
071b39477a Merge pull request #1213 from metalmatze/blackbox-exporter-psp
Fix name for blackbox-exporter PodSecurityPolicy
2021-06-16 08:15:16 -03:00
Matthias Loibl
4ea366eef7 Fix name for blackbox-exporter PodSecurityPolicy 2021-06-16 12:55:51 +02:00
Paweł Krupa
8d57b10d50 Merge pull request #1211 from ArthurSens/as/gitpod-k3s
[Gitpod] Deploy kube-prometheus on k3s
2021-06-16 09:50:14 +02:00
Sang Le
db6a513190 Fix ingress rules for api networking.k8s.io/v1 2021-06-16 13:06:32 +10:00
ArthurSens
b7ac30704e Run k3s inside gitpod and deploy kube-prometheus.
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-06-15 13:29:06 +00:00
Damien Grisonnet
836fa4f086 Merge pull request #1209 from paulfantom/test-sh
scripts: move test.sh script into scripts dir
2021-06-15 11:10:16 +02:00
Damien Grisonnet
59918caf8d Merge pull request #1207 from paulfantom/rm-hack
hack: remove unused directory
2021-06-15 11:07:38 +02:00
paulfantom
6dc90593f9 scripts: move test.sh script into scripts dir 2021-06-14 22:47:22 +02:00
paulfantom
253a8ff2d6 hack: remove unused directory 2021-06-14 21:55:40 +02:00
Damien Grisonnet
df4275e3c8 Merge pull request #1206 from prometheus-operator/automated-updates
[bot] Automated version update
2021-06-14 18:19:50 +02:00
paulfantom
d6201759b8 [bot] Automated version update 2021-06-14 13:50:57 +00:00
Paweł Krupa
7d48d055c6 Merge pull request #1205 from adinhodovic/import-managed-cluster-eks
jsonnet/platforms: Import managed-cluster addon for the EKS platform
2021-06-14 12:45:48 +02:00
Adin Hodovic
88034c4c41 jsonnet/platforms: Import managed-cluster addon for the EKS platform 2021-06-14 01:07:18 +02:00
Paweł Krupa
11778868b1 Merge pull request #1202 from prashbnair/kube-mixin 2021-06-12 13:36:39 +02:00
Prashant Balachandran
78a4677370 pulling in changes from kubernetes-mixin
adding changes from kube-mixin
2021-06-12 15:26:37 +05:30
Paweł Krupa
52fa4166d2 Merge pull request #1203 from prometheus-operator/automated-updates 2021-06-12 11:48:56 +02:00
paulfantom
54f79428ce [bot] Automated version update 2021-06-11 13:51:10 +00:00
Paweł Krupa
df197f6759 Merge pull request #1192 from prometheus-operator/automated-updates 2021-06-11 15:47:41 +02:00
Damien Grisonnet
8fada1a219 Merge pull request #1201 from paulfantom/no-grafana
examples: add example of running without grafana deployment
2021-06-11 14:19:19 +02:00
Damien Grisonnet
46922c11c6 Merge pull request #1200 from paulfantom/coredns-selector
jsonnet: fix label selector for coredns ServiceMonitor
2021-06-11 12:44:40 +02:00
paulfantom
859b87b454 examples: add example of running without grafana deployment
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-06-11 11:07:05 +02:00
paulfantom
edc869991d manifests: regenerate 2021-06-11 11:02:21 +02:00
paulfantom
5ea10d80a1 jsonnet: fix label selector for coredns ServiceMonitor 2021-06-11 10:56:54 +02:00
paulfantom
a2cf1acd95 [bot] Automated version update 2021-06-10 13:59:30 +00:00
Paweł Krupa
2afbb72a88 Merge pull request #1193 from ArthurSens/as/alertmanager-dashboard 2021-06-09 21:08:51 +02:00
ArthurSens
f643955034 Update alertmanager mixin
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-06-08 18:19:23 +00:00
Damien Grisonnet
a27f65e910 Merge pull request #1191 from paulfantom/fix-version-updater
.github: write temporary file to /tmp
2021-06-08 12:18:04 +02:00
paulfantom
d45114c73e .github: write temporary file to /tmp 2021-06-08 11:22:25 +02:00
Damien Grisonnet
4d8104817d Merge pull request #1131 from paulfantom/improve-all-namespace
jsonnet: improve all-namespaces addon
2021-06-01 11:00:55 +02:00
paulfantom
feee269fdb jsonnet: improve all-namespaces addon
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-06-01 09:05:07 +02:00
Paweł Krupa
6d603cf7a9 Merge pull request #1142 from faruryo/fix/kubespray-alert
Fix scheduler and controller selectors for Kubespray
2021-05-31 23:14:02 +02:00
Paweł Krupa
dccf2ee085 Merge pull request #1135 from paulfantom/use-common 2021-05-31 23:12:53 +02:00
Paweł Krupa
93cc34f0f6 Merge pull request #1171 from anarcher/pr/grafana-env-1167
feat(grafana): add env parameter for grafana component
2021-05-31 23:11:34 +02:00
Ajit
d57542eae1 Fix for bug #1163 (#1164) 2021-05-31 23:08:59 +02:00
Paweł Krupa
133c274aa9 Merge pull request #1173 from paulfantom/version-update 2021-05-31 22:57:23 +02:00
paulfantom
67f710846a .github: make version update operation atomic 2021-05-31 17:13:35 +02:00
Damien Grisonnet
68b926f643 Merge pull request #1170 from paulfantom/include-versions
scripts: include kube-rbac-proxy and config-reloader in version upgrades
2021-05-31 11:58:28 +02:00
anarcher
8bcfb98a1d feat(grafana): add env parameter for gradana component 2021-05-31 18:52:55 +09:00
paulfantom
e5720038fe scripts: include kube-rbac-proxy and config-reloader in version upgrades 2021-05-31 11:02:19 +02:00
Paweł Krupa
1a39aaa2ab Merge pull request #1166 from paulfantom/version-upgrader-v2 2021-05-31 10:56:57 +02:00
Paweł Krupa
b279e38809 Merge pull request #1129 from onprem/feature-flags 2021-05-31 10:56:39 +02:00
Paweł Krupa
ae48746f3a Merge pull request #1169 from paulportela/patch-1
Fix adding private repository
2021-05-31 10:56:05 +02:00
paulportela
f7baf1599d Fix adding private repository
`imageRepos` field was removed and the project no longer tries to compose image strings. Now the libraries use `$.values.common.images` to override default images.
2021-05-28 17:22:27 -07:00
Prem Saraswat
93282accb7 Generate manifests 2021-05-27 23:21:30 +05:30
Prem Saraswat
228f8ffdad Add support for feature-flags in Prometheus 2021-05-27 23:21:30 +05:30
paulfantom
9b65a6ddce .github: re-enable automatic version upgrader
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-05-27 18:04:12 +02:00
Paweł Krupa
e481cbd7c5 Merge pull request #1162 from paulfantom/deprecated 2021-05-27 12:38:23 +02:00
paulfantom
b10e0c9690 manifests: regenerate 2021-05-27 10:51:14 +02:00
paulfantom
039d4a1e48 jsonnet: sort list of dropped metrics 2021-05-27 10:49:36 +02:00
paulfantom
2873857dc7 jsonnet: convert string of deprecated metrics into array 2021-05-27 10:46:58 +02:00
Paweł Krupa
6c82dd5fc1 Merge pull request #1161 from paulfantom/ci-1.21
Enable tests for kubernetes 1.21
2021-05-27 10:45:57 +02:00
paulfantom
edd0eb639e manifests: regenerate 2021-05-26 12:50:11 +02:00
paulfantom
2fee85eb43 jsonnet: drop storage_operation_errors_total and storage_operation_status_count as those are deprecated in k8s 1.21 2021-05-26 12:49:44 +02:00
paulfantom
e1e367e820 .github: enable e2e tests on k8s 1.21
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-05-26 12:30:53 +02:00
Paweł Krupa
a89da4adb6 Merge pull request #1113 from paulfantom/unpin
Unpin jsonnet dependencies
2021-05-26 11:18:46 +02:00
Paweł Krupa
8f7d2b9c6a Merge pull request #1107 from paulfantom/mixin-add
Improvements in addMixin function.
2021-05-26 11:18:29 +02:00
paulfantom
888443e447 manifests: regenerate 2021-05-25 16:03:49 +02:00
paulfantom
ce7e86b93a jsonnet/kube-prometheus: fix usage of latest thanos mixin 2021-05-25 16:03:39 +02:00
paulfantom
ddfadbadf9 jsonnet: unpin dependencies
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-05-25 16:03:11 +02:00
Paweł Krupa
6134f1a967 Merge pull request #1157 from fpetkovski/update-kubeconform 2021-05-25 15:44:17 +02:00
fpetkovski
5fbdddf92e Update kubeconform to 0.4.7
This change updates the version of kubeconform to 0.4.7. It simplifies the
`validate` Makefile target and extracts the kubernetes version into a variable.
2021-05-25 15:33:47 +02:00
paulfantom
9e00fa5136 docs: regenerate 2021-05-21 11:44:16 +02:00
paulfantom
3197720de6 *: add test of mixin addition in examples/; change config to _config in addMixin to be consistent with main components 2021-05-21 11:43:59 +02:00
Paweł Krupa
b9ecb0a6c6 Merge pull request #1148 from xadereq/fix_missing_resource
jsonnet/components: fix missing resource config in blackbox exporter
2021-05-20 14:37:24 +02:00
Simon Pasquier
eb06a1ab45 Merge pull request #1146 from simonpasquier/fix-ksm-lite-addon
jsonnet/kube-prometheus/addons: fix KSM regex patterns
2021-05-20 09:22:27 +02:00
Piotr Piskiewicz
a8c344c848 jsonnet/components: fix missing resource config in blackbox exporter 2021-05-17 21:32:01 +02:00
Simon Pasquier
e58cadfe96 jsonnet/kube-prometheus/addons: fix KSM regex patterns
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-05-17 12:42:43 +02:00
faruryo
babc6b820c Fix scheduler and controller selectors for Kubespray
- refs:https://github.com/prometheus-operator/kube-prometheus/pull/916
- kubespray uses kubeadm, so it is good to inherit it
2021-05-09 23:26:47 +09:00
Paweł Krupa
3b1f268d51 Merge pull request #1140 from paulfantom/config-reloader
jsonnet: use common to populate options for additional objects
2021-05-07 10:00:29 +02:00
paulfantom
f340a76e21 jsonnet/addons: fix config-reloader limits 2021-05-07 09:37:03 +02:00
Paweł Krupa
a1210f1eff Merge pull request #1132 from paulfantom/ruleNamespaceSelector 2021-05-06 23:05:34 +02:00
paulfantom
c2ea96bf4f jsonnet: use common to populate options for additional objects
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-05-05 16:31:36 +02:00
Paweł Krupa
d50b5fd2ea Merge pull request #1136 from dgrisonnet/prometheus-adapter-pdb
Add PodDisruptionBudget to prometheus-adapter
2021-05-05 16:20:49 +02:00
Damien Grisonnet
a4a4d4b744 jsonnet: add PDB to prometheus-adapter
Adding a PodDisruptionBudget to prometheus-adapter ensure that at least
one replica of the adapter is always available. This make sure that even
during disruption the aggregated API is available and thus does not
impact the availability of the apiserver.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-05-05 16:15:25 +02:00
paulfantom
15a8351ce0 manifests: regenerate 2021-05-05 08:57:27 +02:00
paulfantom
ee7fb97598 jsonnet: by default select rules from all available namespaces 2021-05-04 13:20:28 +02:00
Paweł Krupa
e0fb2b7821 Merge pull request #1130 from prometheus-operator/paulfantom-patch-1
addons: hide antiaffinity function
2021-05-04 10:31:37 +02:00
Paweł Krupa
982360b65e addons: hide inline antiaffinity function 2021-05-03 16:01:26 +02:00
Paweł Krupa
e2f1581c37 Merge pull request #1124 from kaflake/feature/configRbacImage 2021-05-03 10:15:44 +02:00
paulfantom
b9a49678b2 jsonnet: fmt 2021-05-03 10:02:45 +02:00
paulfantom
2531c043dc jsonnet: fix conflict resolution 2021-05-03 10:01:37 +02:00
Paweł Krupa
624c6c0108 Merge branch 'main' into feature/configRbacImage 2021-05-03 09:57:23 +02:00
Paweł Krupa
db7f3c9107 Merge pull request #1125 from kaflake/feature/configGrafanaImage
can change grafanaImage over $.values.common.images
2021-05-03 09:55:19 +02:00
Paweł Krupa
4eb52db22c Merge pull request #1123 from kaflake/feature/configmapReloadImage 2021-05-03 09:55:04 +02:00
Paweł Krupa
c45f7377ac Merge pull request #1126 from junaid-ali/patch-1 2021-05-03 09:54:44 +02:00
Nagel, Felix
8c221441d1 fix formatting issues 2021-05-03 07:02:28 +02:00
Nagel, Felix
f107e8fb16 fix formatting issues 2021-05-03 06:59:10 +02:00
Nagel, Felix
14e6143037 replace double quotes with single quotes 2021-05-03 06:35:59 +02:00
Junaid Ali
78b88e1b17 Update README.md 2021-05-01 16:30:03 +01:00
Junaid Ali
80408c6057 Adding release branch URLs to compatibility matrix 2021-05-01 16:28:42 +01:00
Paweł Krupa
5b2740d517 Merge pull request #1114 from dgrisonnet/export-anti-affinity
Export anti-affinity addon
2021-04-30 17:20:01 +02:00
Nagel, Felix
7e5d4196b9 can change grafanaImage over $.values.common.images 2021-04-30 14:05:23 +02:00
Nagel, Felix
5761267842 can change kubeRbacProxy over $.values.common.images 2021-04-30 13:48:34 +02:00
Nagel, Felix
be2964887f can change configmapReload over $.values.common.images 2021-04-30 12:46:48 +02:00
Paweł Krupa
dbf61818fa Merge pull request #1115 from paulfantom/fix-1112
jsonnet: pin alertmanager to specific commit
2021-04-28 10:08:35 +02:00
paulfantom
53efc25b3f jsonnet: pin alertmanager to specific commit as release-0.21 doesn't have mixin directory
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-04-27 22:11:49 +02:00
Damien Grisonnet
fa05e2cde8 jsonnet: export anti-affinity addon
Export the antiaffinity function of the anti-affinity addon to make it
possible to extend the addon to component that are not present in the
kube-prometheus stack.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-04-27 15:30:06 +02:00
Sergiusz Urbaniak
d2f8152a8b Merge pull request #1101 from paulfantom/cut-0.8
*: cut release-0.8
2021-04-27 13:19:03 +02:00
paulfantom
415afa4cc0 *: cut release-0.8
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-04-27 13:08:03 +02:00
Paweł Krupa
984de5fb3d Merge pull request #1111 from Luis-TT/fix-windows-addon-label 2021-04-27 13:07:47 +02:00
Luis Vidal Ernst
419eaf28ce Fixed windows addon example 2021-04-27 12:49:29 +02:00
Luis Vidal Ernst
8c712eaa36 Fixed labels in windows addon 2021-04-27 12:47:23 +02:00
Frederic Branczyk
9d69c4c318 Merge pull request #1103 from paulfantom/anti-affinity-test
examples: add anti-affinity example and include it in readme
2021-04-23 13:50:18 +02:00
Paweł Krupa
63da55bc9f Merge pull request #1102 from superbiche/fix/anti-affinity 2021-04-23 09:38:42 +02:00
paulfantom
cd755f2487 examples: add anti-affinity example and include it in readme 2021-04-23 09:38:23 +02:00
Michel Tomas
dd1b9d00e3 docs: fix outdated anti-affinity docs 2021-04-23 01:19:22 +02:00
Michel Tomas
e9d5221fb7 fix(addons): anti-affinity field does not exist: config 2021-04-23 01:19:05 +02:00
Paweł Krupa
cf039d2222 Merge pull request #1050 from paulfantom/fix827
jsonnet/kube-prometheus: fix jb warning message
2021-04-22 13:08:34 +02:00
Paweł Krupa
a3d67f5219 Merge pull request #1095 from dgrisonnet/prometheus-adapter-ha
Make prometheus-adapter highly-available
2021-04-22 12:00:39 +02:00
Kemal Akkoyun
31189e3a18 Merge pull request #1091 from paulfantom/default-containers
jsonnet: add default container annotation for KSM and blackbox exporter
2021-04-22 11:19:14 +02:00
Damien Grisonnet
4c6a06cf7e jsonnet: make prometheus-adapter highly-available
Prometheus-adapter is a component of the monitoring stack that in most
cases require to be highly available. For instance, we most likely
always want the autoscaling pipeline to be available and we also want to
avoid having no available backends serving the metrics API apiservices
has it would result in both the AggregatedAPIDown alert firing and the
kubectl top command not working anymore.

In order to make the adapter highly-avaible, we need to increase its
replica count to 2 and come up with a rolling update strategy and a
pod anti-affinity rule based on the kubernetes hostname to prevent the
adapters to be scheduled on the same node. The default rolling update
strategy for deployments isn't enough as the default maxUnavaible value
is 25% and is rounded down to 0. This means that during rolling-updates
scheduling will fail if there isn't more nodes than the number of
replicas. As for the maxSurge, the default should be fine as it is
rounded up to 1, but for clarity it might be better to just set it to 1.
For the pod anti-affinity constraints, it would be best if it was hard,
but having it soft should be good enough and fit most use-cases.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-04-22 09:57:14 +02:00
paulfantom
412061ef51 manifests: regenerate 2021-04-21 18:43:01 +02:00
paulfantom
7b69800686 jsonnet: add default container annotation for KSM and blackbox
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-04-21 18:43:00 +02:00
paulfantom
417e8b3f66 jsonnet/kube-prometheus: fix jb warning message
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-04-20 19:18:22 +02:00
Paweł Krupa
752d1a7fdc Merge pull request #1093 from ArthurSens/as/custom-alerts-description 2021-04-20 19:13:48 +02:00
Paweł Krupa
4839afb546 Merge pull request #1100 from jan--f/update-kubernetes-mixins 2021-04-20 15:01:48 +02:00
Jan Fajerski
8b39a459fa update generated assets
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-04-20 14:35:31 +02:00
Jan Fajerski
9952e858c7 update kubernetes-mixins
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-04-20 14:31:40 +02:00
Paweł Krupa
cf6f5f2801 Merge pull request #1096 from ArthurSens/as/gitpod-githook
Add githook to gitpod.yml that validates fmt and manifests
2021-04-19 08:03:49 +02:00
ArthurSens
b043054974 Add githook to gitpod.yaml that validates fmt and manifests
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-04-16 19:49:10 +00:00
ArthurSens
72b742d7e8 Regenerate manifests
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-04-16 18:06:47 +00:00
ArthurSens
c96c639ef1 Add summary
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-04-16 18:06:47 +00:00
ArthurSens
92016ef68d Change message to description
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-04-16 18:06:47 +00:00
Kemal Akkoyun
0cde11d3fb Merge pull request #1094 from paulfantom/follow-up#1039
jsonnet: fix windows addon
2021-04-16 17:19:59 +02:00
paulfantom
3135cdd70d jsonnet: fix windows addon 2021-04-16 15:12:41 +02:00
Paweł Krupa
07136d1d6e Merge pull request #1039 from paulfantom/unify-config
jsonnet: unify internal configuration field name
2021-04-16 15:05:26 +02:00
Paweł Krupa
8b62749642 Merge pull request #1076 from paulfantom/ksm-lite
reduce KSM cardinality by denylisting unused metrics
2021-04-16 12:36:31 +02:00
Paweł Krupa
0cb0c49186 Merge pull request #1092 from xpepermint/update-versions
Update versions
2021-04-16 08:58:26 +02:00
Kristijan Sedlak
28d58a9dbc Update versions 2021-04-14 20:19:00 +02:00
Paweł Krupa
7a3879ba49 Merge pull request #1070 from ArthurSens/as/psp-respect-common-ns
Psp should be deployed at the same namespace as kube-prometheus stack
2021-04-12 10:31:51 +02:00
Paweł Krupa
9b5b9dccf7 Merge pull request #1080 from markus-codes/main
update customizing kube-prometheus installing section
2021-04-12 09:34:25 +02:00
Paweł Krupa
0306cdc053 Merge pull request #1081 from adinhodovic/document-mixin-lib
Document usage of the mixin library
2021-04-12 09:33:45 +02:00
Adin Hodovic
19801f0709 Document usage of the mixin library 2021-04-10 00:19:17 +02:00
Markus Heinemann
e13f0db3d1 update customizing kube-prometheus installing section
raised the version of kube-prometheus to 0.7 in the customizing
kube-prometheus installing section
2021-04-09 12:42:11 +00:00
Paweł Krupa
1e67c71703 Merge pull request #1072 from dgrisonnet/platform-patch
Allow configuring the platform used directly instead of having to use a patch
2021-04-09 14:29:34 +02:00
Damien Grisonnet
ed5a2f94fc jsonnet: fix test failures with platformPatch
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-04-09 12:59:18 +02:00
Paweł Krupa
eaeb0c6acf Merge pull request #1078 from jan--f/update-kubernetes-mixins 2021-04-09 12:36:01 +02:00
Jan Fajerski
1cefb18e55 update generated manifests
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-04-09 11:53:06 +02:00
Jan Fajerski
0c468d534d update kubernetes-mixins
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-04-09 11:52:22 +02:00
Paweł Krupa
de3673a286 Merge pull request #1054 from adinhodovic/add-external-mixin-support
jsonnet: Add External mixin lib
2021-04-08 09:11:48 +02:00
Paweł Krupa
874bf089ae Merge pull request #1074 from ArthurSens/as/gitpodfy
Setup gitpod config for ephemeral dev-environments
2021-04-08 09:11:22 +02:00
paulfantom
f81412d05d jsonnet/kube-prometheus/addons: reduce KSM cardinality by denylisting unused metrics
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-04-07 14:23:43 +02:00
Paweł Krupa
2ba8d8aca2 Merge pull request #1058 from mansikulkarni96/windows_exporter 2021-04-07 10:07:33 +02:00
Adin Hodovic
0268128bd1 Add External mixin library
Add library for mixins
2021-04-06 11:59:03 +02:00
Damien Grisonnet
b59b2c23d8 examples: update platform snippets and doc
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-04-06 11:42:29 +02:00
ArthurSens
cf4d2ad524 Setup gitpod config for ephemeral dev-environments
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-04-02 01:34:04 +00:00
mansikulkarni96
1c63b6d021 Add relabel_config to replace endpoint address
This commit adds a relabeling config to the scrape config of
windows-exporter using the 'replace' action field to replace
the node endpoint address with node name. The windows_exporter
returns endpoint target as node IP but we need it to be node name
to use the prometheus adapter queries and collect resource metrics
information.
2021-03-31 13:29:16 -04:00
Damien Grisonnet
f06175bb3b jsonnet: add function to apply platform patches
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-03-31 18:00:04 +02:00
ArthurSens
069f95148f Psp should be deployed at the same namespace as kube-prometheus stack
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-30 19:00:12 +00:00
Frederic Branczyk
f5f72e1b50 Merge pull request #1060 from ArthurSens/as/psp-addon-fixes
PodSecurityPolicy uses role instead of clusterRole where posible
2021-03-30 13:33:48 +02:00
mansikulkarni96
7ba0479433 jsonnet: Add windows_exporter queries for adapter
This commit includes windows_exporter metrics in the
node queries for the prometheus adapter configuration.
This will help obtain the resource metrics: memory and
CPU for Windows nodes. This change will also help in
displaying metrics reported through the 'kubectl top'
command which currently reports 'unknown' status for
Windows nodes.
2021-03-29 14:55:11 -04:00
Lili Cosic
dafa0f8edd Merge pull request #1064 from lilic/bump-ksm-rc.1
Bump kube-state-metrics to latest kube-state-metrics rc.1
2021-03-29 15:46:04 +02:00
Lili Cosic
0df93109d4 manifests: Regenerate files 2021-03-29 14:32:08 +02:00
Lili Cosic
17b11ae344 jsonnetfile.lock.json: Bump kube-state-metrics to 2.0.0-rc.1 2021-03-29 14:29:59 +02:00
Lili Cosic
af0719e8d8 Merge pull request #1063 from viperstars/main
add cluster role to list and watch ingresses in "networking.k8s.io"
2021-03-29 13:29:01 +02:00
viperstars
d1f401a73d add cluster role to list and watch ingresses in api group "networking.k8s.io" 2021-03-29 14:19:35 +08:00
Frederic Branczyk
003daae495 Merge pull request #1052 from paulfantom/simplify-managed-cluster-addon
jsonnet/addons: simplify managed-cluster addon
2021-03-26 19:35:22 +01:00
ArthurSens
c9b52c97f5 PodSecurityPolicy uses role instead of clusterRole where posible
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-25 20:59:49 +00:00
Paweł Krupa
6497d78f2c Merge pull request #1023 from paulfantom/deps-update 2021-03-25 21:03:56 +01:00
Paweł Krupa
e3dcbb7fa6 Merge pull request #1059 from dgrisonnet/watchdog-example
Update developing examples to use ExampleAlert instead of Watchdog
2021-03-25 20:59:37 +01:00
Damien Grisonnet
8973a90049 examples: use ExampleAlert instead of Watchdog
Replace Watchdog alerts part of the `example-group` in some examples by
ExampleAlert alerts to reinforce the fact that this is just an example.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-03-25 18:11:56 +01:00
paulfantom
c960da64bb manifests: regenerate 2021-03-25 14:22:38 +01:00
paulfantom
35a22050e0 *: update dependencies
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-03-25 14:22:06 +01:00
Paweł Krupa
ea12911e4f Merge pull request #1041 from lilic/ksm-2.0.0-rc.0 2021-03-25 14:18:27 +01:00
Lili Cosic
4bc91a8303 Merge pull request #1057 from jan--f/update-kubernetes-mixins
Update kubernetes mixins
2021-03-25 10:38:55 +01:00
Jan Fajerski
9966c37573 update generated manifests
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-03-24 16:52:30 +01:00
Jan Fajerski
4e5087c665 jsonnet: update kubernetes-mixins
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2021-03-24 16:51:54 +01:00
Paweł Krupa
ab554c6ecb Merge pull request #911 from jsturtevant/windows
Windows addon
2021-03-23 09:48:25 +01:00
Paweł Krupa
fe1a446b01 Merge pull request #1019 from dgrisonnet/thanos-image
examples/thanos-sidecar: fix image url
2021-03-23 09:47:05 +01:00
paulfantom
5d2156ffbf jsonnet/addons: simplify managed-cluster addon
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-03-23 09:36:08 +01:00
Paweł Krupa
4d200f29f5 Merge pull request #1022 from lentzi90/update-readme 2021-03-22 13:50:18 +01:00
paulfantom
0bf34a24f8 jsonnet: unify internal configuration field name
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-03-22 12:48:55 +01:00
Paweł Krupa
ed884b0399 Merge pull request #1045 from enkov/main
allow install grafana plugins
2021-03-22 10:17:01 +01:00
Petr Enkov
094cdb34e8 allow install grafana plugins 2021-03-22 11:57:11 +04:00
Paweł Krupa
eacf316f61 Merge pull request #1040 from paulfantom/release-0.6-compat
*: remove statement about release-0.6 compatibility with k8s 1.18
2021-03-19 16:11:51 +01:00
Paweł Krupa
63e20afe98 Merge pull request #1038 from paulfantom/prom-op-0.46 2021-03-19 16:11:41 +01:00
Paweł Krupa
bea6b1a0c2 Merge pull request #1042 from ArthurSens/arthursens/adding-externallabels-86
Add externalLabels to Prometheus defaults
2021-03-19 11:37:46 +01:00
Paweł Krupa
c2ac2a2838 Merge pull request #1010 from ArthurSens/arthursens/add-pod-security-policies-572 2021-03-19 11:27:31 +01:00
ArthurSens
b7d7ba0271 Use node-exporter defaults.port on psp
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-18 20:57:48 +00:00
ArthurSens
478a18a6a7 Turn alertmanager's and grafana's roles into clusterRoles
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-18 20:57:48 +00:00
ArthurSens
e8abcd3dc9 Allow node-exporter to use hostPath volumes
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-18 20:57:48 +00:00
ArthurSens
98559a0f42 Allow kube-state-metrics to run as any user
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-18 20:57:48 +00:00
ArthurSens
1237843e62 Adds an addon for podSecurityPolicies
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-18 20:57:48 +00:00
ArthurSens
2fa7ef162f Add externalLabels on Prometheus defaults
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-18 18:36:10 +00:00
Lili Cosic
09b30e124f manifests: Regenerate 2021-03-18 09:30:35 +01:00
Lili Cosic
4bba284d9b jsonnetfile.lock.json: jb update kube-state-metrics only 2021-03-18 09:30:35 +01:00
Lili Cosic
b473929b36 jsonnet/kube-prometheus/: Bump kube-state-metrics to v2.0.0-rc 2021-03-18 09:30:24 +01:00
Frederic Branczyk
ecd70d66c8 Merge pull request #1037 from paulfantom/prom-adapter-query
jsonnet/prometheus-adapter: include pause container in resource calculations
2021-03-18 08:22:08 +01:00
Lennart Jern
6ece9ca0bc squash! Update README defaults and config 2021-03-18 09:21:35 +02:00
paulfantom
24afd652ab *: remove statement about release-0.6 compatibility with k8s 1.18 2021-03-17 16:06:28 +01:00
Matthias Loibl
41b3f9bafd Merge pull request #1030 from metalmatze/website
Add headers for Hugo website
2021-03-17 09:31:01 +01:00
paulfantom
8b877c1753 manifests: regenerate 2021-03-16 18:48:58 +01:00
paulfantom
70a63d1541 jsonnet: lock prom-op to 0.46 branch 2021-03-16 18:48:48 +01:00
Matthias Loibl
558574b086 Update docs/deploy-kind.md
Co-authored-by: Paweł Krupa <pawel@krupa.net.pl>
2021-03-16 18:21:17 +01:00
Matthias Loibl
d1a3ebbe90 Update docs/deploy-kind.md
Co-authored-by: Paweł Krupa <pawel@krupa.net.pl>
2021-03-16 18:21:02 +01:00
paulfantom
8b30b2b669 manifests: regenerate 2021-03-16 15:19:18 +01:00
paulfantom
0d2e0875d9 jsonnet/prometheus-adapter: include pause container in resource calculations 2021-03-16 15:17:22 +01:00
Matthias Loibl
9a6289a045 Add content header for hugo website 2021-03-16 14:57:51 +01:00
Frederic Branczyk
e4b58eaa5c Merge pull request #1036 from paulfantom/better_pdb
jsonnet: conditionally add PDB
2021-03-16 08:25:13 +01:00
paulfantom
30a41d18d8 jsonnet: conditionally add PDB 2021-03-15 23:39:24 +01:00
Frederic Branczyk
60d5aa25fc Merge pull request #1035 from paulfantom/pdb
Add PodDisruptionBudget objects
2021-03-15 16:43:56 +01:00
paulfantom
9268851d8b *: regenerate 2021-03-15 16:34:29 +01:00
paulfantom
9d327cb328 jsonnet: add PDB to alertmanager and prometheus pods 2021-03-15 16:33:18 +01:00
Paweł Krupa
5516b05926 Merge pull request #1034 from adinhodovic/cleanup-managed-cluster-addon
jsonnet/addons: Cleanup managed cluster addon
2021-03-15 15:51:08 +01:00
Adin Hodovic
db2f6f1acc jsonnet/addons: Cleanup managed cluster addon 2021-03-15 15:05:03 +01:00
Paweł Krupa
578fa2dede Merge pull request #1033 from paulfantom/ksm_version
jsonnet: pick kube-state-metrics version from versions.json file
2021-03-15 14:58:40 +01:00
Paweł Krupa
7c43411531 Merge pull request #1032 from adinhodovic/fix-managed-cluster-addon
Fix managed cluster addon
2021-03-15 14:43:29 +01:00
paulfantom
10f710bb58 jsonnet: pick kube-state-metrics version from versions.json file 2021-03-15 14:38:48 +01:00
Adin Hodovic
24d9633998 Fix managed Cluster addon 2021-03-15 14:23:38 +01:00
Paweł Krupa
4b13b15f2b Merge pull request #1031 from ArthurSens/fix-managed-cluster-addon
Managed-cluster addon shouldn't fully override prometheus object
2021-03-15 09:53:01 +01:00
ArthurSens
5f06f0da5e managed-cluster addon to not fully override prometheus object, only what's necessary
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-12 17:55:40 +00:00
Lili Cosic
148fe71cc5 Merge pull request #1028 from lilic/add-warning
docs/migration-guide.md: Add label changes warning
2021-03-12 15:42:11 +01:00
Lili Cosic
f5ed97771c docs/migration-guide.md: Add label changes warning 2021-03-12 15:25:03 +01:00
Lennart Jern
b40fe984b3 Update README defaults and config 2021-03-12 07:53:45 +02:00
Paweł Krupa
44008b2682 Merge pull request #1018 from dgrisonnet/thanos-sidecar
Cleanup thanos-sidecar addon imports
2021-03-10 11:56:06 +01:00
Paweł Krupa
3eab50538a Merge pull request #1017 from paulfantom/bot
Disable version updater
2021-03-10 11:55:37 +01:00
Damien Grisonnet
9f6c7d7654 examples/thanos-sidecar: fix image url
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-03-10 11:47:57 +01:00
Damien Grisonnet
816c73acc6 examples: cleanup thanos-sidecar addon imports
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2021-03-10 10:59:59 +01:00
paulfantom
8834c2d5e0 .github: disable version updater
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-03-10 10:59:04 +01:00
paulfantom
e3db1c174e scripts: fail if version generator cannot retrieve currently used version 2021-03-10 10:49:16 +01:00
Matthias Loibl
8e5bf00c54 Merge pull request #984 from paulfantom/am_resources
jsonnet/alertmanager: add default alertmanager resource requirements
2021-03-08 10:20:20 +01:00
Paweł Krupa
5f13d38155 Merge pull request #1007 from ArthurSens/arthursens/missing-runbook-url-1001 2021-03-05 15:36:04 +01:00
ArthurSens
bb2971e874 Add runbook_url annotation for custom mixins
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-05 14:07:01 +00:00
ArthurSens
e586afb280 Add runbook_url annotation to all alerts
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-05 13:39:40 +00:00
Paweł Krupa
9785c3bb68 Merge pull request #1002 from paulfantom/versions
jsonnet,scripts: better version updater
2021-03-05 14:02:42 +01:00
paulfantom
16c05d16e2 jsonnet,scripts: better version updater 2021-03-05 10:36:58 +01:00
James Sturtevant
6961da9b90 Update docs/windows.md
Co-authored-by: Andrew Purdin <44270026+andrewpurdin@users.noreply.github.com>
2021-03-03 08:13:36 -08:00
Paweł Krupa
ebd4b28b91 Merge pull request #985 from prometheus-operator/automated-dependencies-update
Autoupdate dependencies
2021-03-03 15:27:09 +01:00
s-urbaniak
654283a048 Auto-updated dependencies 2021-03-03 08:38:39 +00:00
Frederic Branczyk
e3346b8fce Merge pull request #994 from paulfantom/ci
.github: do not persist credentials on checkout
2021-03-02 16:13:46 +01:00
paulfantom
f8c92f0428 .github: do not persist credentials on checkout 2021-03-02 13:57:37 +01:00
Paweł Krupa
a9961b8f6e Merge pull request #992 from paulfantom/am-rules
Better name for alertmanager prometheusRule object
2021-03-01 13:42:14 +01:00
paulfantom
e13ec2e448 manifests: regenerate 2021-03-01 13:27:17 +01:00
paulfantom
f7f817a79e jsonnet/alertmanager: better name for prometheus-rule object 2021-03-01 13:26:46 +01:00
Paweł Krupa
60826aa71d Merge pull request #991 from paulfantom/creds
.github/workflows: do not persist credentials
2021-03-01 13:21:52 +01:00
paulfantom
9c38152dbb .github/workflows: do not persist credentials 2021-03-01 11:20:21 +01:00
James Sturtevant
d9ac51aed0 Windows addon
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2021-02-26 10:09:27 -08:00
paulfantom
d753169176 manifests: regenerate 2021-02-25 18:52:31 +01:00
paulfantom
23c8d865f5 jsonnet/alertmanager: add default alertmanager resource requirements
Co-authored-by: Latch M <latch_mihaylov@homedepot.com>
2021-02-25 18:51:34 +01:00
Lili Cosic
dff8d8c11c Merge pull request #983 from paulfantom/updater
fix version updating CI job
2021-02-25 16:02:02 +01:00
paulfantom
ebef4e02ef fix version updating CI job 2021-02-25 15:41:56 +01:00
Sergiusz Urbaniak
aecfa970c9 Merge pull request #978 from paulfantom/open-main
Open `main` branch - refactoring is finished
2021-02-24 17:06:58 +01:00
paulfantom
6acc4f6569 docs: migration guide
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-24 14:56:51 +01:00
Paweł Krupa
1d2a0e275a Merge pull request #971 from paulfantom/auto-updates
*: allow automatic updates of installed components
2021-02-23 17:59:42 +01:00
paulfantom
c88d18c9d2 *: allow automatic updates of installed components
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-23 14:24:55 +01:00
Paweł Krupa
55b6848b42 Merge pull request #967 from paulfantom/ksm-1.9.8 2021-02-23 14:21:30 +01:00
paulfantom
c229d9d34c manifests: regenerate 2021-02-23 12:09:07 +01:00
paulfantom
c0a136a4c7 jsonnet: bump KSM to 1.9.8 and use multi-arch images 2021-02-23 12:07:49 +01:00
Paweł Krupa
70cb4c10cd Merge pull request #961 from PaytmLabs/feature/anti-affinity/soft-hard-topologykey
addons/anti-affinity: Support soft/hard podAntiAffinity and topologyKey
2021-02-23 10:31:18 +01:00
Paweł Krupa
f691421c91 Merge pull request #960 from paulfantom/k8s-control-plane
Do not modify $.prometheus object when it is not needed (k8s control plane)
2021-02-23 10:30:17 +01:00
Frederic Branczyk
da05d36c31 Merge pull request #941 from paulfantom/ksm-krp-cpu
increase default CPU values for main kube-rbac-proxy sidecar in kube-state-metrics
2021-02-23 09:50:16 +01:00
paulfantom
390f2d72db manifests: regenerate 2021-02-23 09:36:35 +01:00
paulfantom
7c95f88a2b jsonnet: increase default CPU values for main krp sidecar in ksm
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-23 09:36:24 +01:00
Maxime Brunet
32bfeea94f addons/anti-affinity: Support soft/hard podAntiAffinity and topologyKey 2021-02-22 16:23:02 -08:00
paulfantom
66e4a7ba15 *: regenerate 2021-02-22 16:38:34 +01:00
paulfantom
bf9a917cfa examples: adapt examples to stop modifying prometheus object when it is not needed 2021-02-22 16:38:19 +01:00
paulfantom
5d06e286ca examples: adapt examples to use k8s-control-plane component 2021-02-22 16:38:07 +01:00
paulfantom
57730b757e jsonnet/kube-prometheus/platforms: adapt platform addons to use new k8s-control-plane component 2021-02-22 16:36:39 +01:00
paulfantom
c80a82b19a jsonnet/kube-prometheus: create k8s control plane component
* Extract ServiceMonitors related to k8s control plane from prometheus
object into separate one
* Add kubernetes-mixin to new object

Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-22 16:36:14 +01:00
Paweł Krupa
bc1026ae2b Merge pull request #956 from PaytmLabs/feature/prometheus/unique-servicemonitor
Ensure Prometheus ServiceMonitor is unique
2021-02-22 08:39:47 +01:00
Maxime Brunet
f039fc94cf Ensure Prometheus ServiceMonitor is unique 2021-02-19 17:09:52 -08:00
Frederic Branczyk
d909241c4a Merge pull request #954 from phanirithvij/patch-1
jsonnet needs to be mentioned here
2021-02-19 12:44:31 +01:00
Frederic Branczyk
8daef560ea Merge pull request #920 from paulfantom/prober-anti-affinity
anti-affinity addon should also affect blackbox exporter
2021-02-19 12:39:45 +01:00
paulfantom
1817baccf1 jsonnet: antiaffinity addon should also affect blackbox exporter
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-19 10:28:27 +01:00
Paweł Krupa
daad0e1fae Merge pull request #925 from shreyashah1903/fix-kubelet-label
kubelet: Update label selector
2021-02-19 10:19:35 +01:00
Phani Rithvij
a51f690387 jsonnet needs to be mentioned here 2021-02-19 01:56:08 +05:30
Frederic Branczyk
bd0cc5675c Merge pull request #912 from aisbaa/patch-1
Include build.sh and example.jsonnet download
2021-02-18 14:51:27 +01:00
Frederic Branczyk
d0c746d64b Merge pull request #949 from paulfantom/readme
*: add badges to readme
2021-02-18 13:49:21 +01:00
paulfantom
99838deb5d *: add badges to readme 2021-02-18 13:10:48 +01:00
Sergiusz Urbaniak
0c25559b39 Merge pull request #940 from paulfantom/prometheus-rule-name
jsonnet: better name for prometheus PrometheusRule object
2021-02-15 09:41:12 +01:00
paulfantom
0fbf8e03e0 manifests: regenerate 2021-02-12 09:40:22 +01:00
paulfantom
cff8fec592 jsonnet: better name for prometheus PrometheusRule object 2021-02-12 09:40:14 +01:00
Kemal Akkoyun
2a66bb88b5 Merge pull request #929 from paulfantom/thanos-fix
Do not include thanos config when thanos is not used.
2021-02-11 15:35:37 +01:00
Kemal Akkoyun
d283e67059 Merge pull request #932 from paulfantom/etcd-mixin
etcd mixin changed place
2021-02-11 14:56:16 +01:00
paulfantom
83441715a8 jsonnet: etcd mixin changed place
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-11 13:26:00 +01:00
paulfantom
e40e42cf72 manifests: regenerate 2021-02-10 12:07:32 +01:00
paulfantom
30d3d5950d jsonnet: do not include thanos field when not needed
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-10 12:06:43 +01:00
Shreya Shah
ff3e0e1ee4 Update kubelet label selector 2021-02-09 17:52:54 +05:30
Paweł Krupa
de2d1b5231 Merge pull request #919 from paulfantom/node-exporter-1.1.0
bump node-exporter to 1.1.0 and remove deprecated flag
2021-02-08 16:50:36 +01:00
paulfantom
fc1a03053d manifests: regenerate 2021-02-06 19:58:55 +01:00
paulfantom
4245ded81b jsonnet: bump node-exporter to 1.1.0 and remove deprecated flag 2021-02-06 19:58:45 +01:00
Paweł Krupa
2ff04a63a3 Merge pull request #907 from paulfantom/grafana-v2
jsonnet/grafana: re-map datasources and config
2021-02-05 16:59:31 +01:00
paulfantom
a9dd864c67 jsonnet/grafana: re-map datasources and config
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-05 16:49:41 +01:00
Lili Cosic
73db89874e Merge pull request #914 from paulfantom/typo
jsonnet: remove superfluous quotation mark
2021-02-05 16:48:13 +01:00
Paweł Krupa
18630eaca1 Merge pull request #909 from paulfantom/thanos-sidecar-follow-up
First-level support for thanos sidecar
2021-02-04 16:37:10 +01:00
paulfantom
f8bae9fd96 manifests: regenerate 2021-02-04 14:43:23 +01:00
paulfantom
0b0b967764 jsonnet: thanos sidecar as first-level addon
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-04 14:43:16 +01:00
paulfantom
11aa604d39 manifests: regenerate 2021-02-04 10:49:03 +01:00
paulfantom
6dfd6d891c jsonnet: remove superfluous quotation mark 2021-02-03 16:41:58 +01:00
Aistis Jokubauskas
90298f8f5c Include build.sh and example.jsonnet download
I've tripped on this while trying to compile kube-prometheus manifests. 

Ref: https://github.com/prometheus-operator/kube-prometheus/issues/902
2021-02-03 09:32:56 +02:00
Kemal Akkoyun
1384b847f4 Merge pull request #906 from paulfantom/thanos-sidecar
fix thanos-sidecar addon
2021-02-02 13:56:41 +01:00
paulfantom
f95f0fa875 examples,jsonnet: fix thanos-sidecar addon; add test for thanos-sidecar addon 2021-02-02 13:36:10 +01:00
Paweł Krupa
e3cd00e01a Merge pull request #904 from paulfantom/dashboarding_issues
Dashboarding issues
2021-02-02 11:09:11 +01:00
paulfantom
9c93c7aeee docs: regenerate 2021-02-02 10:24:15 +01:00
paulfantom
ab3dff2016 examples,jsonnet: expose kubernetes-grafana API to fix grafana examples
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-02-02 10:24:07 +01:00
Paweł Krupa
6758acbb30 Merge pull request #900 from simonpasquier/switch-apiv2-alerting
Default alerting to Alertmanager API v2
2021-02-02 09:46:05 +01:00
Simon Pasquier
102d4c6513 Default alerting to Alertmanager API v2
Alertmanager API v2 is available for more than 2 years now, there's no
reason to not use it by default.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-01-29 15:57:16 +01:00
Kemal Akkoyun
8588e30bd0 Merge pull request #898 from paulfantom/validation
*: add resource validation
2021-01-29 15:22:00 +01:00
paulfantom
3670d5bf7d *: add resource validation
Co-Authored-By: Yann Hamon <yann.hamon@contentful.com>
Co-Authored-By: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-29 12:25:28 +01:00
Paweł Krupa
40c1c7a190 Merge pull request #885 from lanmarti/hotfix/884
Changed labels for grafana service monitor selector
2021-01-29 10:48:19 +01:00
Paweł Krupa
c2155fa206 Merge pull request #893 from johanneswuerbach/k8s-prometheus-adapter-v0.8.3
k8s-prometheus-adapter v0.8.3
2021-01-28 14:32:28 +01:00
Johannes Würbach
0a79177c19 k8s-prometheus-adapter v0.8.3 2021-01-28 10:24:42 +01:00
Paweł Krupa
6081b306c2 Merge pull request #894 from jimmidyson/configmap-reload-cve
jsonnet: Upgrade configmap-reload image to v0.5.0 to fix CVE
2021-01-28 10:11:01 +01:00
Jimmi Dyson
5b6f50ffb2 jsonnet: Upgrade configmap-reload image to v0.5.0 to fix CVE 2021-01-27 10:56:44 +00:00
Frederic Branczyk
dd8fdd68fe Merge pull request #892 from paulfantom/easier_images
jsonnet: move all images and versions into values.common
2021-01-27 10:43:47 +01:00
paulfantom
07a057f09d manifests: regenerate to fix grafana version label 2021-01-26 15:43:55 +01:00
paulfantom
7afbfa3534 jsonnet: move all images and versions into values.common
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-26 15:43:40 +01:00
Paweł Krupa
ab8132a33d Merge pull request #890 from paulfantom/no_veth
remove virtual interfaces from node_exporter metrics
2021-01-25 15:02:22 +01:00
paulfantom
4220f4e862 manifests: regenerate
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-25 14:52:25 +01:00
paulfantom
d3ad5de993 jsonnet/kube-promethues/components: remove veth interfaces from node_exporter metrics
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-25 14:49:13 +01:00
lanmarti
5cefc105f7 Ran make generate 2021-01-25 13:04:49 +01:00
lanmarti
70cfe27872 Added quotes around label key 2021-01-25 13:03:05 +01:00
lanmarti
ff3e611245 Changed labels for grafana service monitor selector 2021-01-25 13:03:05 +01:00
Paweł Krupa
1bf4381117 Merge pull request #875 from paulfantom/directory-layout
Simplify directory structure
2021-01-21 18:36:21 +01:00
Paweł Krupa
a89a364ece Merge pull request #882 from paulfantom/deps 2021-01-21 11:50:10 +01:00
paulfantom
9bba0e2a2a manifests: regenerate 2021-01-21 10:34:21 +01:00
paulfantom
6d8e56727c jsonnet: update dependencies 2021-01-21 10:32:55 +01:00
paulfantom
e2dbc63764 format and regenerate 2021-01-19 15:46:51 +01:00
paulfantom
0424835b04 jsonnet/addons: update removal of resource limits for certain containers 2021-01-19 15:46:34 +01:00
paulfantom
4132da532c jsonnet/addons: fix autoscaler 2021-01-19 15:46:00 +01:00
paulfantom
fe81e7de56 jsonnet: fix thanos example 2021-01-19 15:45:18 +01:00
paulfantom
4f9d464087 examples,jsonnet: fix weave-net 2021-01-19 15:44:56 +01:00
paulfantom
625ab137fa regenerate 2021-01-19 13:56:26 +01:00
paulfantom
2913c866bb fix references to old variables and to other files
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-19 13:56:20 +01:00
Kemal Akkoyun
66b5416bf6 Merge pull request #880 from lilic/remove-owners
OWNERS: This file is superseded by github team under the org
2021-01-18 18:53:49 +03:00
paulfantom
b70eb1c49c jsonnet: move kops-coredns to platforms 2021-01-18 16:41:59 +01:00
paulfantom
369730b701 jsonnet: move ksm--autoscaler to addons 2021-01-18 16:41:19 +01:00
Lili Cosic
828cbbbea4 OWNERS: This file is superseded by github team under the org 2021-01-18 14:32:18 +01:00
paulfantom
42a3ac0606 regenerate
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-15 15:30:28 +01:00
paulfantom
cbddf907db examples: adjust tests 2021-01-15 15:23:24 +01:00
paulfantom
1eedb90c17 jsonnet: move files around
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-15 15:07:10 +01:00
Paweł Krupa
75f918067d Merge pull request #873 from paulfantom/separate-mixins 2021-01-15 14:32:50 +01:00
paulfantom
092b22d62b regenerate 2021-01-15 11:58:04 +01:00
paulfantom
d4c48539a0 jsonnet: fix too much nesting of data in PrometheusRules
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-15 11:57:57 +01:00
paulfantom
f1bd7af657 jsonnet: helmize :)
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-15 11:35:32 +01:00
paulfantom
5624c5a9a8 jsonnet: refactor the rest of mixins and grafana inclusion
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-15 10:46:51 +01:00
paulfantom
86d4571aea jsonnet: remove grafana global state 2021-01-14 18:38:43 +01:00
paulfantom
e556dbfd88 jsonnet: add separated kubernetes mixin and custom kube prometheus alerts 2021-01-14 16:58:14 +01:00
paulfantom
ba052559cf jsonnet: separate mixins into components
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-14 15:58:07 +01:00
Paweł Krupa
24496d1fac Merge pull request #870 from paulfantom/prom-op-globals
Remove mutating global state in prometheus-operator objects
2021-01-14 13:28:10 +01:00
paulfantom
b67686409e jsonnet: remove wrapping prometheus-operator lib 2021-01-14 13:19:39 +01:00
paulfantom
255cd9a1c5 manifests: regenerate 2021-01-13 16:59:48 +01:00
paulfantom
7335ac40d0 jsonnet: remove unused kube-rbac-proxy config and helper lib 2021-01-13 16:59:39 +01:00
paulfantom
bed5cc8efb jsonnet/kube-prometheus: use refactored upstream prometheus-operator library 2021-01-13 16:59:15 +01:00
paulfantom
e2c50fa40f jsonnet: update prometheus-operator dependency 2021-01-13 16:45:00 +01:00
Paweł Krupa
e02cc471f5 Merge pull request #869 from paulfantom/prometheus-globals
Remove mutating global state in prometheus objects
2021-01-13 10:07:38 +01:00
paulfantom
5dcb5de788 manifests: regenerate 2021-01-13 09:59:29 +01:00
paulfantom
9cf2ce9ffc jsonnet: create function responsible for prometheus objects
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-13 09:59:03 +01:00
Paweł Krupa
6b11d79c4b Merge pull request #871 from paulfantom/mixins-global
Remove mutating global state in monitoring mixins imports
2021-01-13 09:39:34 +01:00
paulfantom
b4fcf8f6cc jsonnet: fix copy-paste errors, format, and lint
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-13 09:15:42 +01:00
paulfantom
55900d9e1c jsonnet: wrap mixins into a function and parametrize
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-13 09:13:47 +01:00
paulfantom
5f9b222c41 jsonnet: remove dead code 2021-01-13 09:13:46 +01:00
paulfantom
18e804217a manifests: regenerate 2021-01-13 09:13:45 +01:00
paulfantom
6e132e4490 jsonnet: refactor monitoring mixins imports 2021-01-13 09:13:44 +01:00
Paweł Krupa
4c1ff463db Merge pull request #812 from paulfantom/jsonnet-lint 2021-01-12 16:11:54 +01:00
paulfantom
d00a923299 jsonnet: format 2021-01-12 16:03:13 +01:00
paulfantom
b5ab602911 jsonnet: lint 2021-01-12 15:21:56 +01:00
paulfantom
48579a9679 .github/workflows: run fmt and lint in CI 2021-01-12 15:19:44 +01:00
paulfantom
ecbaa85d81 *: add jsonnet-lint to tooling
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-12 15:19:43 +01:00
Paweł Krupa
e255923c05 Merge pull request #868 from paulfantom/kube-state-metrics-globals 2021-01-12 15:19:10 +01:00
Paweł Krupa
2ce2c80a48 Merge pull request #872 from johanneswuerbach/patch-1
Fix service names in kube-prometheus-kops
2021-01-12 13:03:18 +01:00
Johannes Würbach
7828570118 Fix service names in kube-prometheus-kops 2021-01-12 11:55:48 +01:00
paulfantom
a76135a9f9 manifests: regenerate 2021-01-07 17:35:30 +01:00
paulfantom
2eed12b2b7 jsonnet: create function responsible for kube-state-metrics objects
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-07 17:35:07 +01:00
Paweł Krupa
4b47de57f8 Merge pull request #863 from paulfantom/blackbox-global
Remove mutating global state in blackbox-exporter objects
2021-01-07 11:39:50 +01:00
paulfantom
1c06faf207 manifests: regenerate 2021-01-07 11:33:11 +01:00
paulfantom
09ce4afca8 jsonnet: create function responsible for blackbox-exporter objects 2021-01-07 11:33:08 +01:00
Paweł Krupa
5ca429157f Merge pull request #864 from paulfantom/prometheus-adapter-global
Remove mutating global state in prometheus-adapter objects
2021-01-07 11:31:47 +01:00
paulfantom
f2686477f4 manifests: regenerate to fix version number 2021-01-07 11:20:41 +01:00
paulfantom
d4999048fc jsonnet: create function responsible for prometheus-adapter objects 2021-01-07 11:20:39 +01:00
Paweł Krupa
6248e73890 Merge pull request #862 from paulfantom/alertmanager-global
Remove mutating global state in alertmanager objects
2021-01-07 11:13:25 +01:00
paulfantom
d9b40073d4 manifests: regenerate to include better alertmanager version 2021-01-07 09:11:34 +01:00
paulfantom
ea3fee466e jsonnet: create function responsible for alertmanager objects
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-01-07 09:11:13 +01:00
Paweł Krupa
a36c6042e5 Merge pull request #857 from paulfantom/globals_experiment_1
Remove mutating global state in node-exporter objects
2021-01-07 09:08:59 +01:00
paulfantom
3b7d4690ba add information about code refactoring to readme 2021-01-05 16:14:17 +01:00
paulfantom
630bc31183 jsonnet: do not compose image string for node-exporter 2021-01-05 16:11:37 +01:00
paulfantom
da817040c6 manifests: regenerate to fix version number 2021-01-05 15:16:10 +01:00
paulfantom
5b8feb783c jsonnet: create function responsible for node-exporter objects 2021-01-05 15:15:44 +01:00
paulfantom
19376df824 jsonnet: move kube-rbac-proxy mixin to separate file 2021-01-05 15:14:43 +01:00
Frederic Branczyk
808c2f8c3d Merge pull request #858 from brancz/fix-kubelet-label
kubelet: Revert label selector
2021-01-04 16:53:56 +01:00
Frederic Branczyk
cf916082b8 kubelet: Revert label selector
The Kubelet's Service/Endpoints object maintained by the Prometheus
Operator does not have the recommended app label (yet). Therefore we
need to use the old label until a Prometheus Operator version has been
released and integrated in kube-promteheus that does use it.
2021-01-04 16:45:27 +01:00
Frederic Branczyk
a4306c9c7a Merge pull request #855 from brancz/bb-ipv4
blackbox-exporter: Prefer ipv4 by default in probe config
2021-01-04 11:27:53 +01:00
Frederic Branczyk
b1dda44501 blackbox-exporter: Prefer ipv4 by default in probe config 2021-01-04 11:01:45 +01:00
Frederic Branczyk
1928f7083a Merge pull request #852 from brancz/probe-port
blackbox-exporter: Add probe port to Service
2021-01-04 11:01:13 +01:00
Frederic Branczyk
6501366ff8 blackbox-exporter: Add probe port to Service 2021-01-04 10:17:05 +01:00
Frederic Branczyk
2984ca585c Merge pull request #844 from paulfantom/hostpid
node-exporter: do not mount /proc as it is covered by hostPID
2020-12-31 12:16:39 +01:00
Frederic Branczyk
06d7df8075 Merge pull request #843 from paulfantom/labels-part2
jsonnet: add missing labels
2020-12-31 12:16:06 +01:00
Frederic Branczyk
b0e2449a8b Merge pull request #778 from tpalfalvi/blackbox-exporter
install a blackbox-exporter instance
2020-12-31 12:15:10 +01:00
PÁLFALVI Tamás
5083ae2e89 regenerate manifests 2020-12-30 23:12:45 +01:00
PÁLFALVI Tamás
dcd99f7d68 set up authorization for blackbox-exporter 2020-12-30 23:02:25 +01:00
PÁLFALVI Tamás
66aca04688 monitor blackbox-exporter over https 2020-12-30 23:02:25 +01:00
PÁLFALVI Tamás
eda90b6833 put blackbox-exporter behind kube-rbac-proxy 2020-12-30 23:02:25 +01:00
PÁLFALVI Tamás
97aaa1f534 accept formatting changes made by jsonnetfmt 2020-12-30 22:50:20 +01:00
PÁLFALVI Tamás
8b4effaba0 update examples and regenerate manifests 2020-12-30 22:50:20 +01:00
PÁLFALVI Tamás
8d53477ec8 put the service monitor for the blackbox exporter in the configured namespace 2020-12-30 22:50:20 +01:00
PÁLFALVI Tamás
c2fb1f4208 include the blackbox exporter mixin by default 2020-12-30 22:50:20 +01:00
PÁLFALVI Tamás
b39b1bfcfc install a blackbox-exporter instance 2020-12-30 22:50:20 +01:00
paulfantom
4f306fc3ff manifests: regenerate 2020-12-18 14:18:02 +01:00
paulfantom
41e3f7d03f node-exporter: do not mount /proc as it is covered by hostPID 2020-12-18 14:17:07 +01:00
paulfantom
f36b68458d manifests: regenerate 2020-12-18 11:32:12 +01:00
paulfantom
723ac0fd27 jsonnet: add missing labels
Signed-off-by: paulfantom <pawel@krupa.net.pl>
2020-12-18 11:32:03 +01:00
Paweł Krupa
09ca49fce0 Merge pull request #832 from paulfantom/labels 2020-12-17 16:29:44 +01:00
paulfantom
af0465fd79 manifests: regenerate 2020-12-16 11:10:15 +01:00
paulfantom
ee553a708d jsonnet: replace all k8s-app labels with app.kubernetes.io/name 2020-12-16 11:07:29 +01:00
paulfantom
3830bc8076 jsonnet: add recommended k8s labels 2020-12-16 11:07:14 +01:00
Lili Cosic
7d7d40b4de Merge pull request #831 from dgrisonnet/bump-grafana-v7.3.5
Bump grafana to v7.3.5
2020-12-11 14:33:02 +01:00
Damien Grisonnet
d37a299499 jsonnet,manifests: bump grafana to v7.3.5
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-12-11 14:19:29 +01:00
244 changed files with 17241 additions and 10657 deletions

37
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,37 @@
<!--
WARNING: Not using this template will result in a longer review process and your change won't be visible in CHANGELOG.
-->
## Description
_Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue._
## Type of change
_What type of changes does your code introduce to the kube-prometheus? Put an `x` in the box that apply._
- [ ] `CHANGE` (fix or feature that would cause existing functionality to not work as expected)
- [ ] `FEATURE` (non-breaking change which adds functionality)
- [ ] `BUGFIX` (non-breaking change which fixes an issue)
- [ ] `ENHANCEMENT` (non-breaking change which improves existing functionality)
- [ ] `NONE` (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)
## Changelog entry
_Please put a one-line changelog entry below. Later this will be copied to the changelog file._
<!--
Your release note should be written in clear and straightforward sentences. Most often, users aren't familiar with
the technical details of your PR, so consider what they need to know when you write your release note.
Some brief examples of release notes:
- Add metadataConfig field to the Prometheus CRD for configuring how remote-write sends metadata information.
- Generate correct scraping configuration for Probes with empty or unset module parameter.
-->
```release-note
```

View File

@@ -4,7 +4,7 @@ on:
- pull_request
env:
golang-version: '1.15'
kind-version: 'v0.9.0'
kind-version: 'v0.11.1'
jobs:
generate:
runs-on: ${{ matrix.os }}
@@ -16,15 +16,35 @@ jobs:
name: Generate
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: make --always-make generate && git diff --exit-code
- run: make --always-make generate validate && git diff --exit-code
lint:
runs-on: ubuntu-latest
name: Jsonnet linter
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- run: make --always-make lint
fmt:
runs-on: ubuntu-latest
name: Jsonnet formatter
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- run: make --always-make fmt && git diff --exit-code
unit-tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- run: make --always-make test
e2e-tests:
name: E2E tests
@@ -32,22 +52,20 @@ jobs:
strategy:
matrix:
kind-image:
- 'kindest/node:v1.19.0'
- 'kindest/node:v1.20.0'
- 'kindest/node:v1.21.1'
- 'kindest/node:v1.22.0'
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Start KinD
uses: engineerd/setup-kind@v0.5.0
with:
version: ${{ env.kind-version }}
image: ${{ matrix.kind-image }}
wait: 300s
- name: Wait for cluster to finish bootstraping
run: |
until [ "$(kubectl get pods --all-namespaces --no-headers | grep -cEv '([0-9]+)/\1')" -eq 0 ]; do
sleep 5s
done
kubectl cluster-info
kubectl get pods -A
run: kubectl wait --for=condition=Ready pods --all --all-namespaces --timeout=300s
- name: Create kube-prometheus stack
run: |
kubectl create -f manifests/setup

68
.github/workflows/versions.yaml vendored Normal file
View File

@@ -0,0 +1,68 @@
name: Upgrade to latest versions
on:
workflow_dispatch:
schedule:
- cron: '37 7 * * 1'
jobs:
versions:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- 'release-0.5'
- 'release-0.6'
- 'release-0.7'
- 'release-0.8'
- 'main'
steps:
- uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
- uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Upgrade versions
run: |
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
# Write to temporary file to make update atomic
scripts/generate-versions.sh > /tmp/versions.json
mv /tmp/versions.json jsonnet/kube-prometheus/versions.json
if: matrix.branch == 'main'
- name: Update jsonnet dependencies
run: |
make update
make generate
# Reset jsonnetfile.lock.json if no dependencies were updated
changedFiles=$(git diff --name-only | grep -v 'jsonnetfile.lock.json' | wc -l)
if [[ "$changedFiles" -eq 0 ]]; then
git checkout -- jsonnetfile.lock.json;
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: "[bot] [${{ matrix.branch }}] Automated version update"
title: "[bot] [${{ matrix.branch }}] Automated version update"
body: |
## Description
This is an automated version and jsonnet dependencies update performed from CI.
Configuration of the workflow is located in `.github/workflows/versions.yaml`
## Type of change
- [x] `NONE` (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)
## Changelog entry
```release-note
```
team-reviewers: kube-prometheus-reviewers
branch: automated-updates-${{ matrix.branch }}
delete-branch: true
# GITHUB_TOKEN cannot be used as it won't trigger CI in a created PR
# More in https://github.com/peter-evans/create-pull-request/issues/155
token: ${{ secrets.PROM_OP_BOT_PAT }}

3
.gitignore vendored
View File

@@ -3,3 +3,6 @@ minikube-manifests/
vendor/
./auth
.swp
crdschemas/
.gitpod/_output/

47
.gitpod.yml Normal file
View File

@@ -0,0 +1,47 @@
image: gitpod/workspace-full
checkoutLocation: gitpod-k3s
tasks:
- init: |
make --always-make
export PATH="$(pwd)/tmp/bin:${PATH}"
cat > ${PWD}/.git/hooks/pre-commit <<EOF
#!/bin/bash
echo "Checking jsonnet fmt"
make fmt > /dev/null 2>&1
echo "Checking if manifests are correct"
make generate > /dev/null 2>&1
git diff --exit-code
if [[ \$? == 1 ]]; then
echo "
This commit is being rejected because the YAML manifests are incorrect or jsonnet needs to be formatted."
echo "Please commit your changes again!"
exit 1
fi
EOF
chmod +x ${PWD}/.git/hooks/pre-commit
- name: run kube-prometheus
command: |
.gitpod/prepare-k3s.sh
.gitpod/deploy-kube-prometheus.sh
- name: kernel dev environment
init: |
sudo apt update -y
sudo apt install qemu qemu-system-x86 linux-image-$(uname -r) libguestfs-tools sshpass netcat -y
sudo curl -o /usr/bin/kubectl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo chmod +x /usr/bin/kubectl
.gitpod/prepare-rootfs.sh
command: |
.gitpod/qemu.sh
ports:
- port: 3000
onOpen: open-browser
- port: 9090
onOpen: open-browser
- port: 9093
onOpen: open-browser
vscode:
extensions:
- heptio.jsonnet@0.1.0:woEDU5N62LRdgdz0g/I6sQ==

View File

@@ -0,0 +1,16 @@
kubectl apply -f manifests/setup
# Safety wait for CRDs to be working
sleep 30
kubectl apply -f manifests/
kubectl rollout status -n monitoring daemonset node-exporter
kubectl rollout status -n monitoring statefulset alertmanager-main
kubectl rollout status -n monitoring statefulset prometheus-k8s
kubectl rollout status -n monitoring deployment grafana
kubectl rollout status -n monitoring deployment kube-state-metrics
kubectl port-forward -n monitoring svc/grafana 3000 > /dev/null 2>&1 &
kubectl port-forward -n monitoring svc/alertmanager-main 9093 > /dev/null 2>&1 &
kubectl port-forward -n monitoring svc/prometheus-k8s 9090 > /dev/null 2>&1 &

49
.gitpod/prepare-k3s.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
script_dirname="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
rootfslock="${script_dirname}/_output/rootfs/rootfs-ready.lock"
k3sreadylock="${script_dirname}/_output/rootfs/k3s-ready.lock"
if test -f "${k3sreadylock}"; then
exit 0
fi
cd $script_dirname
function waitssh() {
while ! nc -z 127.0.0.1 2222; do
sleep 0.1
done
./ssh.sh "whoami" &>/dev/null
if [ $? -ne 0 ]; then
sleep 1
waitssh
fi
}
function waitrootfs() {
while ! test -f "${rootfslock}"; do
sleep 0.1
done
}
echo "🔥 Installing everything, this will be done only one time per workspace."
echo "Waiting for the rootfs to become available, it can take a while, open the terminal #2 for progress"
waitrootfs
echo "✅ rootfs available"
echo "Waiting for the ssh server to become available, it can take a while, after this k3s is getting installed"
waitssh
echo "✅ ssh server available"
./ssh.sh "curl -sfL https://get.k3s.io | sh -"
mkdir -p ~/.kube
./scp.sh root@127.0.0.1:/etc/rancher/k3s/k3s.yaml ~/.kube/config
echo "✅ k3s server is ready"
touch "${k3sreadylock}"
# safety wait for cluster availability
sleep 30s

48
.gitpod/prepare-rootfs.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
set -euo pipefail
img_url="https://cloud-images.ubuntu.com/hirsute/current/hirsute-server-cloudimg-amd64.tar.gz"
script_dirname="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
outdir="${script_dirname}/_output/rootfs"
rm -Rf $outdir
mkdir -p $outdir
curl -L -o "${outdir}/rootfs.tar.gz" $img_url
cd $outdir
tar -xvf rootfs.tar.gz
qemu-img resize hirsute-server-cloudimg-amd64.img +20G
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --run-command 'resize2fs /dev/sda'
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --root-password password:root
netconf="
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
"
# networking setup
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --run-command "echo '${netconf}' > /etc/netplan/01-net.yaml"
# copy kernel modules
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --copy-in /lib/modules/$(uname -r):/lib/modules
# ssh
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --run-command 'apt remove openssh-server -y && apt install openssh-server -y'
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --run-command "sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config"
sudo virt-customize -a hirsute-server-cloudimg-amd64.img --run-command "sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config"
# mark as ready
touch rootfs-ready.lock
echo "k3s development environment is ready"

14
.gitpod/qemu.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -xeuo pipefail
script_dirname="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
outdir="${script_dirname}/_output"
sudo qemu-system-x86_64 -kernel "/boot/vmlinuz" \
-boot c -m 3073M -hda "${outdir}/rootfs/hirsute-server-cloudimg-amd64.img" \
-net user \
-smp 8 \
-append "root=/dev/sda rw console=ttyS0,115200 acpi=off nokaslr" \
-nic user,hostfwd=tcp::2222-:22,hostfwd=tcp::6443-:6443 \
-serial mon:stdio -display none

3
.gitpod/scp.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
sshpass -p 'root' scp -o StrictHostKeychecking=no -P 2222 $@

3
.gitpod/ssh.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
sshpass -p 'root' ssh -o StrictHostKeychecking=no -p 2222 root@127.0.0.1 "$@"

44
CHANGELOG.md Normal file
View File

@@ -0,0 +1,44 @@
## release-0.9 / 2021-08-19
* [CHANGE] Test against Kubernetes 1.21 and 1,22. #1161 #1337
* [CHANGE] Drop cAdvisor metrics without (pod, namespace) label pairs. #1250
* [CHANGE] Excluded deprecated `etcd_object_counts` metric. #1337
* [FEATURE] Add PodDisruptionBudget to prometheus-adapter. #1136
* [FEATURE] Add support for feature flags in Prometheus. #1129
* [FEATURE] Add env parameter for grafana component. #1171
* [FEATURE] Add gitpod deployment of kube-prometheus on k3s. #1211
* [FEATURE] Add resource requests and limits to prometheus-adapter container. #1282
* [FEATURE] Add PodMonitor for kube-proxy. #1230
* [FEATURE] Turn AWS VPC CNI into a control plane add-on. #1307
* [ENHANCEMENT] Export anti-affinity addon. #1114
* [ENHANCEMENT] Allow changing configmap-reloader, grafana, and kube-rbac-proxy images in $.values.common.images. #1123 #1124 #1125
* [ENHANCEMENT] Add automated version upgrader. #1166
* [ENHANCEMENT] Improve all-namespace addon. #1131
* [ENHANCEMENT] Add example of running without grafana deployment. #1201
* [ENHANCEMENT] Import managed-cluster addon for the EKS platform. #1205
* [ENHANCEMENT] Automatically update jsonnet dependencies. #1220
* [ENHANCEMENT] Adapt kube-prometheus to changes to ovn veth interfaces names. #1224
* [ENHANCEMENT] Add example release-0.3 to release-0.8 migration to docs. #1235
* [ENHANCEMENT] Consolidate intervals used in prometheus-adapter CPU queries. #1231
* [ENHANCEMENT] Create dashboardDefinitions if rawDashboards or folderDashboards are specified. #1255
* [ENHANCEMENT] Relabel instance with node name for CNI DaemonSet on EKS. #1259
* [ENHANCEMENT] Update doc on Prometheus rule updates since release 0.8. #1253
* [ENHANCEMENT] Point runbooks to https://runbooks.prometheus-operator.dev. #1267
* [ENHANCEMENT] Allow setting of kubeRbacProxyMainResources in kube-state-metrics. #1257
* [ENHANCEMENT] Automate release branch updates. #1293 #1303
* [ENHANCEMENT] Create Thanos Sidecar rules separately from Prometheus ones. #1308
* [ENHANCEMENT] Allow using newer jsonnet-bundler dependency resolution when using windows addon. #1310
* [ENHANCEMENT] Prometheus ruleSelector defaults to all rules.
* [BUGFIX] Fix kube-state-metrics metric denylist regex pattern. #1146
* [BUGFIX] Fix missing resource config in blackbox exporter. #1148
* [BUGFIX] Fix adding private repository. #1169
* [BUGFIX] Fix kops selectors for scheduler, controllerManager and kube-dns. #1164
* [BUGFIX] Fix scheduler and controller selectors for Kubespray. #1142
* [BUGFIX] Fix label selector for coredns ServiceMonitor. #1200
* [BUGFIX] Fix name for blackbox-exporter PodSecurityPolicy. #1213
* [BUGFIX] Fix ingress path rules for networking.k8s.io/v1. #1212
* [BUGFIX] Disable insecure cypher suites for prometheus-adapter. #1216
* [BUGFIX] Fix CNI metrics relabelings on EKS. #1277
* [BUGFIX] Fix node-exporter ignore list for OVN. #1283
* [BUGFIX] Revert back to awscni_total_ip_addresses-based alert on EKS. #1292
* [BUGFIX] Allow passing `thanos: {}` to prometheus configuration. #1325

View File

@@ -6,11 +6,15 @@ EMBEDMD_BIN=$(BIN_DIR)/embedmd
JB_BIN=$(BIN_DIR)/jb
GOJSONTOYAML_BIN=$(BIN_DIR)/gojsontoyaml
JSONNET_BIN=$(BIN_DIR)/jsonnet
JSONNETLINT_BIN=$(BIN_DIR)/jsonnet-lint
JSONNETFMT_BIN=$(BIN_DIR)/jsonnetfmt
TOOLING=$(EMBEDMD_BIN) $(JB_BIN) $(GOJSONTOYAML_BIN) $(JSONNET_BIN) $(JSONNETFMT_BIN)
KUBECONFORM_BIN=$(BIN_DIR)/kubeconform
TOOLING=$(EMBEDMD_BIN) $(JB_BIN) $(GOJSONTOYAML_BIN) $(JSONNET_BIN) $(JSONNETLINT_BIN) $(JSONNETFMT_BIN) $(KUBECONFORM_BIN)
JSONNETFMT_ARGS=-n 2 --max-blank-lines 2 --string-style s --comment-style s
KUBE_VERSION?="1.20.0"
all: generate fmt test
.PHONY: clean
@@ -24,22 +28,38 @@ generate: manifests **.md
**.md: $(EMBEDMD_BIN) $(shell find examples) build.sh example.jsonnet
$(EMBEDMD_BIN) -w `find . -name "*.md" | grep -v vendor`
manifests: examples/kustomize.jsonnet $(GOJSONTOYAML_BIN) vendor build.sh
manifests: examples/kustomize.jsonnet $(GOJSONTOYAML_BIN) vendor
./build.sh $<
vendor: $(JB_BIN) jsonnetfile.json jsonnetfile.lock.json
rm -rf vendor
$(JB_BIN) install
crdschemas: vendor
./scripts/generate-schemas.sh
.PHONY: update
update: $(JB_BIN)
$(JB_BIN) update
.PHONY: validate
validate: crdschemas manifests $(KUBECONFORM_BIN)
$(KUBECONFORM_BIN) -kubernetes-version $(KUBE_VERSION) -schema-location 'default' -schema-location 'crdschemas/{{ .ResourceKind }}.json' -skip CustomResourceDefinition manifests/
.PHONY: fmt
fmt: $(JSONNETFMT_BIN)
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
xargs -n 1 -- $(JSONNETFMT_BIN) $(JSONNETFMT_ARGS) -i
.PHONY: lint
lint: $(JSONNETLINT_BIN) vendor
find jsonnet/ -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
xargs -n 1 -- $(JSONNETLINT_BIN) -J vendor
.PHONY: test
test: $(JB_BIN)
$(JB_BIN) install
./test.sh
./scripts/test.sh
.PHONY: test-e2e
test-e2e:

5
NOTICE
View File

@@ -1,5 +0,0 @@
CoreOS Project
Copyright 2018 CoreOS, Inc
This product includes software developed at CoreOS, Inc.
(http://www.coreos.com/).

15
OWNERS
View File

@@ -1,15 +0,0 @@
reviewers:
- brancz
- kakkoyun
- metalmatze
- mxinden
- s-urbaniak
- squat
- paulfantom
approvers:
- brancz
- metalmatze
- mxinden
- s-urbaniak
- squat
- paulfantom

361
README.md
View File

@@ -1,5 +1,9 @@
# kube-prometheus
[![Build Status](https://github.com/prometheus-operator/kube-prometheus/workflows/ci/badge.svg)](https://github.com/prometheus-operator/kube-prometheus/actions)
[![Slack](https://img.shields.io/badge/join%20slack-%23prometheus--operator-brightgreen.svg)](http://slack.k8s.io/)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/prometheus-operator/kube-prometheus)
> Note that everything is experimental and may change significantly at any time.
This repository collects Kubernetes manifests, [Grafana](http://grafana.com/) dashboards, and [Prometheus rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with [Prometheus](https://prometheus.io/) using the Prometheus Operator.
@@ -18,9 +22,14 @@ Components included in this package:
This stack is meant for cluster monitoring, so it is pre-configured to collect metrics from all Kubernetes components. In addition to that it delivers a default set of dashboards and alerting rules. Many of the useful dashboards and alerts come from the [kubernetes-mixin project](https://github.com/kubernetes-monitoring/kubernetes-mixin), similar to this project it provides composable jsonnet as a library for users to customize to their needs.
## Warning
If you are migrating from `release-0.7` branch or earlier please read [what changed and how to migrate in our guide](https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/migration-guide.md).
## Table of contents
- [kube-prometheus](#kube-prometheus)
- [Warning](#warning)
- [Table of contents](#table-of-contents)
- [Prerequisites](#prerequisites)
- [minikube](#minikube)
@@ -53,12 +62,15 @@ This stack is meant for cluster monitoring, so it is pre-configured to collect m
- [Stripping container resource limits](#stripping-container-resource-limits)
- [Customizing Prometheus alerting/recording rules and Grafana dashboards](#customizing-prometheus-alertingrecording-rules-and-grafana-dashboards)
- [Exposing Prometheus/Alermanager/Grafana via Ingress](#exposing-prometheusalermanagergrafana-via-ingress)
- [Setting up a blackbox exporter](#setting-up-a-blackbox-exporter)
- [Minikube Example](#minikube-example)
- [Continuous Delivery](#continuous-delivery)
- [Troubleshooting](#troubleshooting)
- [Error retrieving kubelet metrics](#error-retrieving-kubelet-metrics)
- [Authentication problem](#authentication-problem)
- [Authorization problem](#authorization-problem)
- [kube-state-metrics resource usage](#kube-state-metrics-resource-usage)
- [Error retrieving kube-proxy metrics](#error-retrieving-kube-proxy-metrics)
- [Contributing](#contributing)
- [License](#license)
@@ -94,19 +106,17 @@ $ minikube addons disable metrics-server
The following versions are supported and work as we test against these versions in their respective branches. But note that other versions might work!
| kube-prometheus stack | Kubernetes 1.16 | Kubernetes 1.17 | Kubernetes 1.18 | Kubernetes 1.19 | Kubernetes 1.20 |
|-----------------------|-----------------|-----------------|-----------------|-----------------|-----------------|
| `release-0.4` | ✔ (v1.16.5+) | ✔ | ✗ | ✗ | ✗ |
| `release-0.5` | ✗ | | ✔ | ✗ | ✗ |
| `release-0.6` | ✗ | ✗ | ✔ | ✔ | ✗ |
| `release-0.7` | ✗ | ✗ | ✗ | ✔ | ✔ |
| `HEAD` | ✗ | ✗ | ✗ | ✔ | ✔ |
Note: Due to [two](https://github.com/kubernetes/kubernetes/issues/83778) [bugs](https://github.com/kubernetes/kubernetes/issues/86359) in Kubernetes v1.16.1, and prior to Kubernetes v1.16.5 the kube-prometheus release-0.4 branch only supports v1.16.5 and higher. The `extension-apiserver-authentication-reader` role in the kube-system namespace can be manually edited to include list and watch permissions in order to workaround the second issue with Kubernetes v1.16.2 through v1.16.4.
| kube-prometheus stack | Kubernetes 1.18 | Kubernetes 1.19 | Kubernetes 1.20 | Kubernetes 1.21 | Kubernetes 1.22 |
|------------------------------------------------------------------------------------------|-----------------|-----------------|-----------------|-----------------|-----------------|
| [`release-0.6`](https://github.com/prometheus-operator/kube-prometheus/tree/release-0.6) | ✗ | ✔ | ✗ | ✗ | ✗ |
| [`release-0.7`](https://github.com/prometheus-operator/kube-prometheus/tree/release-0.7) | ✗ | | ✔ | ✗ | ✗ |
| [`release-0.8`](https://github.com/prometheus-operator/kube-prometheus/tree/release-0.8) | ✗ | ✗ | ✔ | ✔ | ✗ |
| [`release-0.9`](https://github.com/prometheus-operator/kube-prometheus/tree/release-0.9) | ✗ | ✗ | ✗ | ✔ | ✔ |
| [`HEAD`](https://github.com/prometheus-operator/kube-prometheus/tree/main) | ✗ | ✗ | ✗ | ✔ | ✔ |
## Quickstart
>Note: For versions before Kubernetes v1.20.z refer to the [Kubernetes compatibility matrix](#kubernetes-compatibility-matrix) in order to choose a compatible branch.
>Note: For versions before Kubernetes v1.21.z refer to the [Kubernetes compatibility matrix](#kubernetes-compatibility-matrix) in order to choose a compatible branch.
This project is intended to be used as a library (i.e. the intent is not for you to create your own modified copy of this repository).
@@ -114,7 +124,7 @@ Though for a quickstart a compiled version of the Kubernetes [manifests](manifes
* Create the monitoring stack using the config in the `manifests` directory:
```shell
# Create the namespace and CRDs, and then wait for them to be availble before creating the remaining resources
# Create the namespace and CRDs, and then wait for them to be available before creating the remaining resources
kubectl create -f manifests/setup
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
kubectl create -f manifests/
@@ -175,12 +185,15 @@ Install this library in your own project with [jsonnet-bundler](https://github.c
$ mkdir my-kube-prometheus; cd my-kube-prometheus
$ jb init # Creates the initial/empty `jsonnetfile.json`
# Install the kube-prometheus dependency
$ jb install github.com/prometheus-operator/kube-prometheus/jsonnet/kube-prometheus@release-0.4 # Creates `vendor/` & `jsonnetfile.lock.json`, and fills in `jsonnetfile.json`
$ jb install github.com/prometheus-operator/kube-prometheus/jsonnet/kube-prometheus@release-0.7 # Creates `vendor/` & `jsonnetfile.lock.json`, and fills in `jsonnetfile.json`
$ wget https://raw.githubusercontent.com/prometheus-operator/kube-prometheus/release-0.7/example.jsonnet -O example.jsonnet
$ wget https://raw.githubusercontent.com/prometheus-operator/kube-prometheus/release-0.7/build.sh -O build.sh
```
> `jb` can be installed with `go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb`
> An e.g. of how to install a given version of this library: `jb install github.com/prometheus-operator/kube-prometheus/jsonnet/kube-prometheus@release-0.4`
> An e.g. of how to install a given version of this library: `jb install github.com/prometheus-operator/kube-prometheus/jsonnet/kube-prometheus@release-0.7`
In order to update the kube-prometheus dependency, simply use the jsonnet-bundler update functionality:
```shell
@@ -191,7 +204,7 @@ $ jb update
e.g. of how to compile the manifests: `./build.sh example.jsonnet`
> before compiling, install `gojsontoyaml` tool with `go get github.com/brancz/gojsontoyaml`
> before compiling, install `gojsontoyaml` tool with `go get github.com/brancz/gojsontoyaml` and `jsonnet` with `go get github.com/google/go-jsonnet/cmd/jsonnet`
Here's [example.jsonnet](example.jsonnet):
@@ -200,34 +213,39 @@ Here's [example.jsonnet](example.jsonnet):
[embedmd]:# (example.jsonnet)
```jsonnet
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/main.libsonnet') +
// Uncomment the following imports to enable its patches
// (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-managed-cluster.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-node-ports.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-thanos-sidecar.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-custom-metrics.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-external-metrics.libsonnet') +
// (import 'kube-prometheus/addons/anti-affinity.libsonnet') +
// (import 'kube-prometheus/addons/managed-cluster.libsonnet') +
// (import 'kube-prometheus/addons/node-ports.libsonnet') +
// (import 'kube-prometheus/addons/static-etcd.libsonnet') +
// (import 'kube-prometheus/addons/custom-metrics.libsonnet') +
// (import 'kube-prometheus/addons/external-metrics.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
```
And here's the [build.sh](build.sh) script (which uses `vendor/` to render all manifests in a json structure of `{filename: manifest-content}`):
@@ -268,7 +286,7 @@ The previous steps (compilation) has created a bunch of manifest files in the ma
Now simply use `kubectl` to install Prometheus and Grafana as per your configuration:
```shell
# Update the namespace and CRDs, and then wait for them to be availble before creating the remaining resources
# Update the namespace and CRDs, and then wait for them to be available before creating the remaining resources
$ kubectl apply -f manifests/setup
$ kubectl apply -f manifests/
```
@@ -310,74 +328,22 @@ Once updated, just follow the instructions under "Compiling" and "Apply the kube
Jsonnet has the concept of hidden fields. These are fields, that are not going to be rendered in a result. This is used to configure the kube-prometheus components in jsonnet. In the example jsonnet code of the above [Customizing Kube-Prometheus section](#customizing-kube-prometheus), you can see an example of this, where the `namespace` is being configured to be `monitoring`. In order to not override the whole object, use the `+::` construct of jsonnet, to merge objects, this way you can override individual settings, but retain all other settings and defaults.
These are the available fields with their respective default values:
The available fields and their default values can be seen in [main.libsonnet](jsonnet/kube-prometheus/main.libsonnet). Note that many of the fields get their default values from variables, and for example the version numbers are imported from [versions.json](jsonnet/kube-prometheus/versions.json).
Configuration is mainly done in the `values` map. You can see this being used in the `example.jsonnet` to set the namespace to `monitoring`. This is done in the `common` field, which all other components take their default value from. See for example how Alertmanager is configured in `main.libsonnet`:
```
{
_config+:: {
namespace: "default",
versions+:: {
alertmanager: "v0.17.0",
nodeExporter: "v0.18.1",
kubeStateMetrics: "v1.5.0",
kubeRbacProxy: "v0.4.1",
prometheusOperator: "v0.30.0",
prometheus: "v2.10.0",
},
imageRepos+:: {
prometheus: "quay.io/prometheus/prometheus",
alertmanager: "quay.io/prometheus/alertmanager",
kubeStateMetrics: "quay.io/coreos/kube-state-metrics",
kubeRbacProxy: "quay.io/brancz/kube-rbac-proxy",
nodeExporter: "quay.io/prometheus/node-exporter",
prometheusOperator: "quay.io/prometheus-operator/prometheus-operator",
},
prometheus+:: {
names: 'k8s',
replicas: 2,
rules: {},
},
alertmanager+:: {
alertmanager: {
name: 'main',
config: |||
global:
resolve_timeout: 5m
route:
group_by: ['job']
group_wait: 30s
group_interval: 5m
repeat_interval: 12h
receiver: 'null'
routes:
- match:
alertname: Watchdog
receiver: 'null'
receivers:
- name: 'null'
|||,
replicas: 3,
// Use the namespace specified under values.common by default.
namespace: $.values.common.namespace,
version: $.values.common.versions.alertmanager,
image: $.values.common.images.alertmanager,
mixin+: { ruleLabels: $.values.common.ruleLabels },
},
kubeStateMetrics+:: {
collectors: '', // empty string gets a default set
scrapeInterval: '30s',
scrapeTimeout: '30s',
baseCPU: '100m',
baseMemory: '150Mi',
},
nodeExporter+:: {
port: 9100,
},
},
}
```
The grafana definition is located in a different project (https://github.com/brancz/kubernetes-grafana), but needed configuration can be customized from the same top level `_config` field. For example to allow anonymous access to grafana, add the following `_config` section:
The grafana definition is located in a different project (https://github.com/brancz/kubernetes-grafana), but needed configuration can be customized from the same top level `values` field. For example to allow anonymous access to grafana, add the following `values` section:
```
grafana+:: {
config: { // http://docs.grafana.org/installation/configuration/
@@ -394,57 +360,28 @@ Jsonnet is a turing complete language, any logic can be reflected in it. It also
### Cluster Creation Tools
A common example is that not all Kubernetes clusters are created exactly the same way, meaning the configuration to monitor them may be slightly different. For [kubeadm](examples/jsonnet-snippets/kubeadm.jsonnet), [bootkube](examples/jsonnet-snippets/bootkube.jsonnet), [kops](examples/jsonnet-snippets/kops.jsonnet) and [kubespray](examples/jsonnet-snippets/kubespray.jsonnet) clusters there are mixins available to easily configure these:
A common example is that not all Kubernetes clusters are created exactly the same way, meaning the configuration to monitor them may be slightly different. For the following clusters there are mixins available to easily configure them:
kubeadm:
* aws
* bootkube
* eks
* gke
* kops-coredns
* kubeadm
* kubespray
[embedmd]:# (examples/jsonnet-snippets/kubeadm.jsonnet)
These mixins are selectable via the `platform` field of kubePrometheus:
[embedmd]:# (examples/jsonnet-snippets/platform.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet')
```
bootkube:
[embedmd]:# (examples/jsonnet-snippets/bootkube.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-bootkube.libsonnet')
```
kops:
[embedmd]:# (examples/jsonnet-snippets/kops.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kops.libsonnet')
```
kops with CoreDNS:
If your kops cluster is using CoreDNS, there is an additional mixin to import.
[embedmd]:# (examples/jsonnet-snippets/kops-coredns.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kops.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kops-coredns.libsonnet')
```
kubespray:
[embedmd]:# (examples/jsonnet-snippets/kubespray.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubespray.libsonnet')
```
kube-aws:
[embedmd]:# (examples/jsonnet-snippets/kube-aws.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kube-aws.libsonnet')
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
platform: 'example-platform',
},
},
}
```
### Internal Registry
@@ -470,10 +407,12 @@ Then to generate manifests with `internal-registry.com/organization`, use the `w
[embedmd]:# (examples/internal-registry.jsonnet)
```jsonnet
local mixin = import 'kube-prometheus/kube-prometheus-config-mixins.libsonnet';
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local mixin = import 'kube-prometheus/addons/config-mixins.libsonnet';
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
} + mixin.withImageRepository('internal-registry.com/organization');
@@ -492,8 +431,8 @@ Another mixin that may be useful for exploring the stack is to expose the UIs of
[embedmd]:# (examples/jsonnet-snippets/node-ports.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-node-ports.libsonnet')
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/node-ports.libsonnet')
```
### Prometheus Object Name
@@ -502,7 +441,7 @@ To give another customization example, the name of the `Prometheus` object provi
[embedmd]:# (examples/prometheus-name-override.jsonnet)
```jsonnet
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
((import 'kube-prometheus/main.libsonnet') + {
prometheus+: {
prometheus+: {
metadata+: {
@@ -519,7 +458,7 @@ Standard Kubernetes manifests are all written using [ksonnet-lib](https://github
[embedmd]:# (examples/ksonnet-example.jsonnet)
```jsonnet
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
((import 'kube-prometheus/main.libsonnet') + {
nodeExporter+: {
daemonset+: {
metadata+: {
@@ -532,12 +471,12 @@ Standard Kubernetes manifests are all written using [ksonnet-lib](https://github
### Alertmanager configuration
The Alertmanager configuration is located in the `_config.alertmanager.config` configuration field. In order to set a custom Alertmanager configuration simply set this field.
The Alertmanager configuration is located in the `values.alertmanager.config` configuration field. In order to set a custom Alertmanager configuration simply set this field.
[embedmd]:# (examples/alertmanager-config.jsonnet)
```jsonnet
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
((import 'kube-prometheus/main.libsonnet') + {
values+:: {
alertmanager+: {
config: |||
global:
@@ -564,8 +503,8 @@ In the above example the configuration has been inlined, but can just as well be
[embedmd]:# (examples/alertmanager-config-external.jsonnet)
```jsonnet
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
((import 'kube-prometheus/main.libsonnet') + {
values+:: {
alertmanager+: {
config: importstr 'alertmanager-config.yaml',
},
@@ -575,15 +514,17 @@ In the above example the configuration has been inlined, but can just as well be
### Adding additional namespaces to monitor
In order to monitor additional namespaces, the Prometheus server requires the appropriate `Role` and `RoleBinding` to be able to discover targets from that namespace. By default the Prometheus server is limited to the three namespaces it requires: default, kube-system and the namespace you configure the stack to run in via `$._config.namespace`. This is specified in `$._config.prometheus.namespaces`, to add new namespaces to monitor, simply append the additional namespaces:
In order to monitor additional namespaces, the Prometheus server requires the appropriate `Role` and `RoleBinding` to be able to discover targets from that namespace. By default the Prometheus server is limited to the three namespaces it requires: default, kube-system and the namespace you configure the stack to run in via `$.values.namespace`. This is specified in `$.values.prometheus.namespaces`, to add new namespaces to monitor, simply append the additional namespaces:
[embedmd]:# (examples/additional-namespaces.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+:: {
prometheus+: {
namespaces+: ['my-namespace', 'my-second-namespace'],
},
},
@@ -608,14 +549,16 @@ You can define ServiceMonitor resources in your `jsonnet` spec. See the snippet
[embedmd]:# (examples/additional-namespaces-servicemonitor.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+:: {
namespaces+: ['my-namespace', 'my-second-namespace'],
},
},
prometheus+:: {
exampleApplication: {
serviceMonitorMyNamespace: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
@@ -647,7 +590,8 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }
```
> NOTE: make sure your service resources have the right labels (eg. `'app': 'myapp'`) applied. Prometheus uses kubernetes labels to discover resources inside the namespaces.
@@ -658,12 +602,13 @@ In case you want to monitor all namespaces in a cluster, you can add the followi
[embedmd]:# (examples/all-namespaces.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-all-namespaces.libsonnet') + {
_config+:: {
namespace: 'monitoring',
prometheus+:: {
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/all-namespaces.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+: {
namespaces: [],
},
},
@@ -691,11 +636,26 @@ In order to configure a static etcd cluster to scrape there is a simple [kube-pr
### Pod Anti-Affinity
To prevent `Prometheus` and `Alertmanager` instances from being deployed onto the same node when
possible, one can include the [kube-prometheus-anti-affinity.libsonnet](jsonnet/kube-prometheus/kube-prometheus-anti-affinity.libsonnet) mixin:
possible, one can include the [kube-prometheus-anti-affinity.libsonnet](jsonnet/kube-prometheus/addons/anti-affinity.libsonnet) mixin:
[embedmd]:# (examples/anti-affinity.jsonnet)
```jsonnet
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/anti-affinity.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
```
### Stripping container resource limits
@@ -705,10 +665,12 @@ To do that, one can import the following mixin
[embedmd]:# (examples/strip-limits.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-strip-limits.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/strip-limits.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
@@ -729,6 +691,36 @@ See [developing Prometheus rules and Grafana dashboards](docs/developing-prometh
See [exposing Prometheus/Alertmanager/Grafana](docs/exposing-prometheus-alertmanager-grafana-ingress.md) guide.
### Setting up a blackbox exporter
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
// ... all necessary mixins ...
{
values+:: {
// ... configuration for other features ...
blackboxExporter+:: {
modules+:: {
tls_connect: {
prober: 'tcp',
tcp: {
tls: true
}
}
}
}
}
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
// ... other rendering blocks ...
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) }
```
Then describe the actual blackbox checks you want to run using `Probe` resources. Specify `blackbox-exporter.<namespace>.svc.cluster.local:9115` as the `spec.prober.url` field of the `Probe` resource.
See the [blackbox exporter guide](docs/blackbox-exporter.md) for the list of configurable options and a complete example.
## Minikube Example
To use an easy to reproduce example, see [minikube.jsonnet](examples/minikube.jsonnet), which uses the minikube setup as demonstrated in [Prerequisites](#prerequisites). Because we would like easy access to our Prometheus, Alertmanager and Grafana UIs, `minikube.jsonnet` exposes the services as NodePort type services.
@@ -766,7 +758,7 @@ resources. One driver for more resource needs, is a high number of
namespaces. There may be others.
kube-state-metrics resource allocation is managed by
[addon-resizer](https://github.com/kubernetes/autoscaler/tree/master/addon-resizer/nanny)
[addon-resizer](https://github.com/kubernetes/autoscaler/tree/main/addon-resizer/nanny)
You can control it's parameters by setting variables in the
config. They default to:
@@ -779,6 +771,13 @@ config. They default to:
}
```
### Error retrieving kube-proxy metrics
By default, kubeadm will configure kube-proxy to listen on 127.0.0.1 for metrics. Because of this prometheus would not be able to scrape these metrics. This would have to be changed to 0.0.0.0 in one of the following two places:
1. Before cluster initialization, the config file passed to kubeadm init should have KubeProxyConfiguration manifest with the field metricsBindAddress set to 0.0.0.0:10249
2. If the k8s cluster is already up and running, we'll have to modify the configmap kube-proxy in the namespace kube-system and set the metricsBindAddress field. After this kube-proxy daemonset would have to be restarted with
`kubectl -n kube-system rollout restart daemonset kube-proxy`
## Contributing
All `.yaml` files in the `/manifests` folder are generated via
@@ -794,4 +793,4 @@ the following process:
## License
Apache License 2.0, see [LICENSE](https://github.com/prometheus-operator/kube-prometheus/blob/master/LICENSE).
Apache License 2.0, see [LICENSE](https://github.com/prometheus-operator/kube-prometheus/blob/main/LICENSE).

View File

@@ -1,4 +1,4 @@
## CoreOS Community Code of Conduct
## Community Code of Conduct
### Contributor Code of Conduct
@@ -33,29 +33,9 @@ This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting a project maintainer, Brandon Philips
<brandon.philips@coreos.com>, and/or Rithu John <rithu.john@coreos.com>.
reported by contacting a project maintainer listed in
https://github.com/prometheus-operator/prometheus-operator/blob/master/MAINTAINERS.md.
This Code of Conduct is adapted from the Contributor Covenant
(http://contributor-covenant.org), version 1.2.0, available at
http://contributor-covenant.org/version/1/2/0/
### CoreOS Events Code of Conduct
CoreOS events are working conferences intended for professional networking and
collaboration in the CoreOS community. Attendees are expected to behave
according to professional standards and in accordance with their employers
policies on appropriate workplace behavior.
While at CoreOS events or related social networking opportunities, attendees
should not engage in discriminatory or offensive speech or actions including
but not limited to gender, sexuality, race, age, disability, or religion.
Speakers should be especially aware of these concerns.
CoreOS does not condone any statements by speakers contrary to these standards.
CoreOS reserves the right to deny entrance and/or eject from an event (without
refund) any individual found to be engaging in discriminatory or offensive
speech or actions.
Please bring any concerns to the immediate attention of designated on-site
staff, Brandon Philips <brandon.philips@coreos.com>, and/or Rithu John <rithu.john@coreos.com>.

View File

@@ -7,23 +7,31 @@ One fatal issue that can occur is that you run out of IP addresses in your eks c
You can monitor the `awscni` using kube-promethus with :
[embedmd]:# (../examples/eks-cni-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-eks.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
kubePrometheus+: {
platform: 'eks',
},
},
prometheusRules+:: {
groups+: [
{
name: 'example-group',
rules: [
kubernetesControlPlane+: {
prometheusRuleEksCNI+: {
spec+: {
groups+: [
{
record: 'aws_eks_available_ip',
expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < 10',
name: 'example-group',
rules: [
{
record: 'aws_eks_available_ip',
expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < 10',
},
],
},
],
},
],
},
},
};

97
docs/blackbox-exporter.md Normal file
View File

@@ -0,0 +1,97 @@
---
title: "Blackbox Exporter"
description: "Generated API docs for the Prometheus Operator"
lead: "This Document documents the types introduced by the Prometheus Operator to be consumed by users."
date: 2021-03-08T08:49:31+00:00
lastmod: 2021-03-08T08:49:31+00:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 630
toc: true
---
# Setting up a blackbox exporter
The `prometheus-operator` defines a `Probe` resource type that can be used to describe blackbox checks. To execute these, a separate component called [`blackbox_exporter`](https://github.com/prometheus/blackbox_exporter) has to be deployed, which can be scraped to retrieve the results of these checks. You can use `kube-prometheus` to set up such a blackbox exporter within your Kubernetes cluster.
## Adding blackbox exporter manifests to an existing `kube-prometheus` configuration
1. Override blackbox-related configuration parameters as needed.
2. Add the following to the list of renderers to render the blackbox exporter manifests:
```
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) }
```
## Configuration parameters influencing the blackbox exporter
* `_config.namespace`: the namespace where the various generated resources (`ConfigMap`, `Deployment`, `Service`, `ServiceAccount` and `ServiceMonitor`) will reside. This does not affect where you can place `Probe` objects; that is determined by the configuration of the `Prometheus` resource. This option is shared with other `kube-prometheus` components; defaults to `default`.
* `_config.imageRepos.blackboxExporter`: the name of the blackbox exporter image to deploy. Defaults to `quay.io/prometheus/blackbox-exporter`.
* `_config.versions.blackboxExporter`: the tag of the blackbox exporter image to deploy. Defaults to the version `kube-prometheus` was tested with.
* `_config.imageRepos.configmapReloader`: the name of the ConfigMap reloader image to deploy. Defaults to `jimmidyson/configmap-reload`.
* `_config.versions.configmapReloader`: the tag of the ConfigMap reloader image to deploy. Defaults to the version `kube-prometheus` was tested with.
* `_config.resources.blackbox-exporter.requests`: the requested resources; this is used for each container. Defaults to `10m` CPU and `20Mi` RAM. See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for details.
* `_config.resources.blackbox-exporter.limits`: the resource limits; this is used for each container. Defaults to `20m` CPU and `40Mi` RAM. See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for details.
* `_config.blackboxExporter.port`: the exposed HTTPS port of the exporter. This is what Prometheus can scrape for metrics related to the blackbox exporter itself. Defaults to `9115`.
* `_config.blackboxExporter.internalPort`: the internal plaintext port of the exporter. Prometheus scrapes configured via `Probe` objects cannot access the HTTPS port right now, so you have to specify this port in the `url` field. Defaults to `19115`.
* `_config.blackboxExporter.replicas`: the number of exporter replicas to be deployed. Defaults to `1`.
* `_config.blackboxExporter.matchLabels`: map of the labels to be used to select resources belonging to the instance deployed. Defaults to `{ 'app.kubernetes.io/name': 'blackbox-exporter' }`
* `_config.blackboxExporter.assignLabels`: map of the labels applied to components of the instance deployed. Defaults to all the labels included in the `matchLabels` option, and additionally `app.kubernetes.io/version` is set to the version of the blackbox exporter.
* `_config.blackboxExporter.modules`: the modules available in the blackbox exporter installation, i.e. the types of checks it can perform. The default value includes most of the modules defined in the default blackbox exporter configuration: `http_2xx`, `http_post_2xx`, `tcp_connect`, `pop3s_banner`, `ssh_banner`, and `irc_banner`. `icmp` is omitted so the exporter can be run with minimum privileges, but you can add it back if needed - see the example below. See https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md for the configuration format, except you have to use JSON instead of YAML here.
* `_config.blackboxExporter.privileged`: whether the `blackbox-exporter` container should be running as non-root (`false`) or root with heavily-restricted capability set (`true`). Defaults to `true` if you have any ICMP modules defined (which need the extra permissions) and `false` otherwise.
## Complete example
```jsonnet
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
blackboxExporter+:: {
modules+:: {
icmp: {
prober: 'icmp',
},
},
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
```
After installing the generated manifests, you can create `Probe` resources, for example:
```yaml
kind: Probe
apiVersion: monitoring.coreos.com/v1
metadata:
name: example-com-website
namespace: monitoring
spec:
interval: 60s
module: http_2xx
prober:
url: blackbox-exporter.monitoring.svc.cluster.local:19115
targets:
staticConfig:
static:
- http://example.com
- https://example.com
```

19
docs/deploy-kind.md Normal file
View File

@@ -0,0 +1,19 @@
---
title: "Deploy to kind"
description: "Deploy kube-prometheus to Kubernets kind."
lead: "Deploy kube-prometheus to Kubernets kind."
date: 2021-03-08T23:04:32+01:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 500
toc: true
---
---
Time to explain how!
Your chance of [**contributing**](https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/deploy-kind.md)!

View File

@@ -1,4 +1,16 @@
# Developing Prometheus Rules and Grafana Dashboards
---
title: "Prometheus Rules and Grafana Dashboards"
description: "Create Prometheus Rules and Grafana Dashboards on top of kube-prometheus"
lead: "Create Prometheus Rules and Grafana Dashboards on top of kube-prometheus"
date: 2021-03-08T23:04:32+01:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 650
toc: true
---
`kube-prometheus` ships with a set of default [Prometheus rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) and [Grafana](http://grafana.com/) dashboards. At some point one might like to extend them, the purpose of this document is to explain how to do this.
@@ -11,34 +23,39 @@ As a basis, all examples in this guide are based on the base example of the kube
[embedmd]:# (../example.jsonnet)
```jsonnet
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/main.libsonnet') +
// Uncomment the following imports to enable its patches
// (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-managed-cluster.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-node-ports.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-thanos-sidecar.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-custom-metrics.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-external-metrics.libsonnet') +
// (import 'kube-prometheus/addons/anti-affinity.libsonnet') +
// (import 'kube-prometheus/addons/managed-cluster.libsonnet') +
// (import 'kube-prometheus/addons/node-ports.libsonnet') +
// (import 'kube-prometheus/addons/static-etcd.libsonnet') +
// (import 'kube-prometheus/addons/custom-metrics.libsonnet') +
// (import 'kube-prometheus/addons/external-metrics.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
```
## Prometheus rules
@@ -53,28 +70,40 @@ The format is exactly the Prometheus format, so there should be no changes neces
[embedmd]:# (../examples/prometheus-additional-alert-rule-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusAlerts+:: {
groups+: [
{
name: 'example-group',
rules: [
exampleApplication: {
prometheusRuleExample: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
},
spec: {
groups: [
{
alert: 'Watchdog',
expr: 'vector(1)',
labels: {
severity: 'none',
},
annotations: {
description: 'This is a Watchdog meant to ensure that the entire alerting pipeline is functional.',
},
name: 'example-group',
rules: [
{
alert: 'ExampleAlert',
expr: 'vector(1)',
labels: {
severity: 'warning',
},
annotations: {
description: 'This is an example alert.',
},
},
],
},
],
},
],
},
},
};
@@ -85,7 +114,8 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }
```
### Recording rules
@@ -96,22 +126,34 @@ In order to add a recording rule, simply do the same with the `prometheusRules`
[embedmd]:# (../examples/prometheus-additional-recording-rule-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusRules+:: {
groups+: [
{
name: 'example-group',
rules: [
exampleApplication: {
prometheusRuleExample: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
},
spec: {
groups: [
{
record: 'some_recording_rule_name',
expr: 'vector(1)',
name: 'example-group',
rules: [
{
record: 'some_recording_rule_name',
expr: 'vector(1)',
},
],
},
],
},
],
},
},
};
@@ -122,7 +164,8 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }
```
### Pre-rendered rules
@@ -143,12 +186,24 @@ Then import it in jsonnet:
[embedmd]:# (../examples/prometheus-additional-rendered-rule-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusAlerts+:: {
groups+: (import 'existingrule.json').groups,
exampleApplication: {
prometheusRuleExample: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
},
spec: {
groups: (import 'existingrule.json').groups,
},
},
},
};
@@ -159,76 +214,118 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }
```
### Changing default rules
Along with adding additional rules, we give the user the option to filter or adjust the existing rules imported by `kube-prometheus/kube-prometheus.libsonnet`. The recording rules can be found in [kube-prometheus/rules](../jsonnet/kube-prometheus/rules) and [kubernetes-mixin/rules](https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/rules) while the alerting rules can be found in [kube-prometheus/alerts](../jsonnet/kube-prometheus/alerts) and [kubernetes-mixin/alerts](https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/alerts).
Along with adding additional rules, we give the user the option to filter or adjust the existing rules imported by `kube-prometheus/main.libsonnet`. The recording rules can be found in [kube-prometheus/components/mixin/rules](../jsonnet/kube-prometheus/components/mixin/rules) and [kubernetes-mixin/rules](https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/rules) while the alerting rules can be found in [kube-prometheus/components/mixin/alerts](../jsonnet/kube-prometheus/components/mixin/alerts) and [kubernetes-mixin/alerts](https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/alerts).
Knowing which rules to change, the user can now use functions from the [Jsonnet standard library](https://jsonnet.org/ref/stdlib.html) to make these changes. Below are examples of both a filter and an adjustment being made to the default rules. These changes can be assigned to a local variable and then added to the `local kp` object as seen in the examples above.
#### Filter
Here the alert `KubeStatefulSetReplicasMismatch` is being filtered out of the group `kubernetes-apps`. The default rule can be seen [here](https://github.com/kubernetes-monitoring/kubernetes-mixin/blob/master/alerts/apps_alerts.libsonnet).
Here the alert `KubeStatefulSetReplicasMismatch` is being filtered out of the group `kubernetes-apps`. The default rule can be seen [here](https://github.com/kubernetes-monitoring/kubernetes-mixin/blob/master/alerts/apps_alerts.libsonnet). You first need to find out in which component the rule is defined (here it is kuberentesControlPlane).
```jsonnet
local filter = {
prometheusAlerts+:: {
groups: std.map(
function(group)
if group.name == 'kubernetes-apps' then
group {
rules: std.filter(function(rule)
rule.alert != "KubeStatefulSetReplicasMismatch",
group.rules
)
}
else
group,
super.groups
),
kubernetesControlPlane+: {
prometheusRule+: {
spec+: {
groups: std.map(
function(group)
if group.name == 'kubernetes-apps' then
group {
rules: std.filter(
function(rule)
rule.alert != 'KubeStatefulSetReplicasMismatch',
group.rules
),
}
else
group,
super.groups
),
},
},
},
};
```
#### Adjustment
Here the expression for the alert used above is updated from its previous value. The default rule can be seen [here](https://github.com/kubernetes-monitoring/kubernetes-mixin/blob/master/alerts/apps_alerts.libsonnet).
Here the expression for another alert in the same component is updated from its previous value. The default rule can be seen [here](https://github.com/kubernetes-monitoring/kubernetes-mixin/blob/master/alerts/apps_alerts.libsonnet).
```jsonnet
local update = {
prometheusAlerts+:: {
groups: std.map(
function(group)
if group.name == 'kubernetes-apps' then
group {
rules: std.map(
function(rule)
if rule.alert == "KubeStatefulSetReplicasMismatch" then
rule {
expr: "kube_statefulset_status_replicas_ready{job=\"kube-state-metrics\",statefulset!=\"vault\"} != kube_statefulset_status_replicas{job=\"kube-state-metrics\",statefulset!=\"vault\"}"
}
else
rule,
group.rules
)
}
else
group,
super.groups
),
kubernetesControlPlane+: {
prometheusRule+: {
spec+: {
groups: std.map(
function(group)
if group.name == 'kubernetes-apps' then
group {
rules: std.map(
function(rule)
if rule.alert == 'KubePodCrashLooping' then
rule {
expr: 'rate(kube_pod_container_status_restarts_total{namespace=kube-system,job="kube-state-metrics"}[10m]) * 60 * 5 > 0',
}
else
rule,
group.rules
),
}
else
group,
super.groups
),
},
},
},
};
```
Using the example from above about adding in pre-rendered rules, the new local variables can be added in as follows:
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + filter + update + {
prometheusAlerts+:: (import 'existingrule.json'),
local add = {
exampleApplication:: {
prometheusRule+: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'example-application-rules',
namespace: $.values.common.namespace,
},
spec: (import 'existingrule.json'),
},
},
};
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
local kp = (import 'kube-prometheus/main.libsonnet') + filter + update + add;
local kp = (import 'kube-prometheus/main.libsonnet') +
filter +
update +
add + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) } +
{ ['exampleApplication-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }
```
## Dashboards
@@ -249,35 +346,37 @@ local prometheus = grafana.prometheus;
local template = grafana.template;
local graphPanel = grafana.graphPanel;
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
},
grafana+:: {
dashboards+:: {
'my-dashboard.json':
dashboard.new('My Dashboard')
.addTemplate(
{
current: {
text: 'Prometheus',
value: 'Prometheus',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+:: {
namespace: 'monitoring',
},
grafana+: {
dashboards+:: {
'my-dashboard.json':
dashboard.new('My Dashboard')
.addTemplate(
{
current: {
text: 'Prometheus',
value: 'Prometheus',
},
hide: 0,
label: null,
name: 'datasource',
options: [],
query: 'prometheus',
refresh: 1,
regex: '',
type: 'datasource',
},
hide: 0,
label: null,
name: 'datasource',
options: [],
query: 'prometheus',
refresh: 1,
regex: '',
type: 'datasource',
},
)
.addRow(
row.new()
.addPanel(graphPanel.new('My Panel', span=6, datasource='$datasource')
.addTarget(prometheus.target('vector(1)')))
),
)
.addRow(
row.new()
.addPanel(graphPanel.new('My Panel', span=6, datasource='$datasource')
.addTarget(prometheus.target('vector(1)')))
),
},
},
},
};
@@ -297,16 +396,15 @@ As jsonnet is a superset of json, the jsonnet `import` function can be used to i
[embedmd]:# (../examples/grafana-additional-rendered-dashboard-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
},
grafanaDashboards+:: { // monitoring-mixin compatibility
'my-dashboard.json': (import 'example-grafana-dashboard.json'),
},
grafana+:: {
dashboards+:: { // use this method to import your dashboards to Grafana
'my-dashboard.json': (import 'example-grafana-dashboard.json'),
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+:: {
namespace: 'monitoring',
},
grafana+: {
dashboards+:: { // use this method to import your dashboards to Grafana
'my-dashboard.json': (import 'example-grafana-dashboard.json'),
},
},
},
};
@@ -323,13 +421,15 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
In case you have lots of json dashboard exported out from grafana UI the above approach is going to take lots of time to improve performance we can use `rawDashboards` field and provide it's value as json string by using `importstr`
[embedmd]:# (../examples/grafana-additional-rendered-dashboard-example-2.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
},
grafana+:: {
rawDashboards+:: {
'my-dashboard.json': (importstr 'example-grafana-dashboard.json'),
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+:: {
namespace: 'monitoring',
},
grafana+: {
rawDashboards+:: {
'my-dashboard.json': (importstr 'example-grafana-dashboard.json'),
},
},
},
};
@@ -342,3 +442,117 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
```
### Mixins
Kube-prometheus comes with a couple of default mixins as the Kubernetes-mixin and the Node-exporter mixin, however there [are many more mixins](https://monitoring.mixins.dev/). To use other mixins Kube-prometheus has a jsonnet library for creating a Kubernetes PrometheusRule CRD and Grafana dashboards from a mixin. Below is an example of creating a mixin object that has Prometheus rules and Grafana dashboards:
```jsonnet
// Import the library function for adding mixins
local addMixin = (import 'kube-prometheus/lib/mixin.libsonnet');
// Create your mixin
local myMixin = addMixin({
name: 'myMixin',
mixin: import 'my-mixin/mixin.libsonnet',
});
```
The myMixin object will have two objects - `prometheusRules` and `grafanaDashboards`. The `grafanaDashboards` object will be needed to be added to the `dashboards` field as in the example below:
```jsonnet
values+:: {
grafana+:: {
dashboards+:: myMixin.grafanaDashboards
```
The `prometheusRules` object is a PrometheusRule Kubernetes CRD and it should be defined as its own jsonnet object. If you define multiple mixins in a single jsonnet object there is a possibility that they will overwrite each others' configuration and there will be unintended effects. Therefore, use the `prometheusRules` object as its own jsonnet object:
```jsonnet
...
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ 'external-mixins/my-mixin-prometheus-rules': myMixin.prometheusRules } // one object for each mixin
```
As mentioned above each mixin is configurable and you would configure the mixin as in the example below:
```jsonnet
local myMixin = addMixin({
name: 'myMixin',
mixin: (import 'my-mixin/mixin.libsonnet') + {
_config+:: {
myMixinSelector: 'my-selector',
interval: '30d', // example
},
},
});
```
The library has also two optional parameters - the namespace for the `PrometheusRule` CRD and the dashboard folder for the Grafana dashboards. The below example shows how to use both:
```jsonnet
local myMixin = addMixin({
name: 'myMixin',
namespace: 'prometheus', // default is monitoring
dashboardFolder: 'Observability',
mixin: (import 'my-mixin/mixin.libsonnet') + {
_config+:: {
myMixinSelector: 'my-selector',
interval: '30d', // example
},
},
});
```
The created `prometheusRules` object will have the metadata field `namespace` added and the usage will remain the same. However, the `grafanaDasboards` will be added to the `folderDashboards` field instead of the `dashboards` field as shown in the example below:
```jsonnet
values+:: {
grafana+:: {
folderDashboards+:: {
Kubernetes: {
...
},
Misc: {
'grafana-home.json': import 'dashboards/misc/grafana-home.json',
},
} + myMixin.grafanaDashboards
```
Full example of including etcd mixin using method described above:
[embedmd]:# (../examples/mixin-inclusion.jsonnet)
```jsonnet
local addMixin = (import 'kube-prometheus/lib/mixin.libsonnet');
local etcdMixin = addMixin({
name: 'etcd',
mixin: (import 'github.com/etcd-io/etcd/contrib/mixin/mixin.libsonnet') + {
_config+: {}, // mixin configuration object
},
});
local kp = (import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
grafana+: {
// Adding new dashboard to grafana. This will modify grafana configMap with dashboards
dashboards+: etcdMixin.grafanaDashboards,
},
},
};
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
// Rendering prometheusRules object. This is an object compatible with prometheus-operator CRD definition for prometheusRule
{ 'external-mixins/etcd-mixin-prometheus-rules': etcdMixin.prometheusRules }
```

View File

@@ -1,12 +1,24 @@
# Exposing Prometheus, Alertmanager and Grafana UIs via Ingress
---
title: "Expose via Ingress"
description: "How to setup a Kubernetes Ingress to expose the Prometheus, Alertmanager and Grafana."
lead: "How to setup a Kubernetes Ingress to expose the Prometheus, Alertmanager and Grafana."
date: 2021-03-08T23:04:32+01:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 500
toc: true
---
In order to access the web interfaces via the Internet [Kubernetes Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) is a popular option. This guide explains, how Kubernetes Ingress can be setup, in order to expose the Prometheus, Alertmanager and Grafana UIs, that are included in the [kube-prometheus](https://github.com/coreos/kube-prometheus) project.
In order to access the web interfaces via the Internet [Kubernetes Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) is a popular option. This guide explains, how Kubernetes Ingress can be setup, in order to expose the Prometheus, Alertmanager and Grafana UIs, that are included in the [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus) project.
Note: before continuing, it is recommended to first get familiar with the [kube-prometheus](https://github.com/coreos/kube-prometheus) stack by itself.
Note: before continuing, it is recommended to first get familiar with the [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus) stack by itself.
## Prerequisites
Apart from a running Kubernetes cluster with a running [kube-prometheus](https://github.com/coreos/kube-prometheus) stack, a Kubernetes Ingress controller must be installed and functional. This guide was tested with the [nginx-ingress-controller](https://github.com/kubernetes/ingress-nginx). If you wish to reproduce the exact result in as depicted in this guide we recommend using the nginx-ingress-controller.
Apart from a running Kubernetes cluster with a running [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus) stack, a Kubernetes Ingress controller must be installed and functional. This guide was tested with the [nginx-ingress-controller](https://github.com/kubernetes/ingress-nginx). If you wish to reproduce the exact result in as depicted in this guide we recommend using the nginx-ingress-controller.
## Setting up Ingress

View File

@@ -1,15 +1,22 @@
<br>
<div class="alert alert-info" role="alert">
<i class="fa fa-exclamation-triangle"></i><b> Note:</b> Starting with v0.12.0, Prometheus Operator requires use of Kubernetes v1.7.x and up.
</div>
---
title: "Deploy to kubeadm"
description: "Deploy kube-prometheus to Kubernets kubeadm."
lead: "Deploy kube-prometheus to Kubernets kubeadm."
date: 2021-03-08T23:04:32+01:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 500
toc: true
---
# Kube Prometheus on Kubeadm
The [kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/) tool is linked by Kubernetes as the offical way to deploy and manage self-hosted clusters. Kubeadm does a lot of heavy lifting by automatically configuring your Kubernetes cluster with some common options. This guide is intended to show you how to deploy Prometheus, Prometheus Operator and Kube Prometheus to get you started monitoring your cluster that was deployed with Kubeadm.
The [kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/) tool is linked by Kubernetes as the offical way to deploy and manage self-hosted clusters. kubeadm does a lot of heavy lifting by automatically configuring your Kubernetes cluster with some common options. This guide is intended to show you how to deploy Prometheus, Prometheus Operator and Kube Prometheus to get you started monitoring your cluster that was deployed with kubeadm.
This guide assumes you have a basic understanding of how to use the functionality the Prometheus Operator implements. If you haven't yet, we recommend reading through the [getting started guide](https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/getting-started.md) as well as the [alerting guide](https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/alerting.md).
## Kubeadm Pre-requisites
## kubeadm Pre-requisites
This guide assumes you have some familiarity with `kubeadm` or at least have deployed a cluster using `kubeadm`. By default, `kubeadm` does not expose two of the services that we will be monitoring. Therefore, in order to get the most out of the `kube-prometheus` package, we need to make some quick tweaks to the Kubernetes cluster. Since we will be monitoring the `kube-controller-manager` and `kube-scheduler`, we must expose them to the cluster.

View File

@@ -0,0 +1,296 @@
// Has the following customisations
// Custom alert manager config
// Ingresses for the alert manager, prometheus and grafana
// Grafana admin user password
// Custom prometheus rules
// Custom grafana dashboards
// Custom prometheus config - Data retention, memory, etc.
// Node exporter role and role binding so we can use a PSP for the node exporter
// External variables
// See https://jsonnet.org/learning/tutorial.html
local cluster_identifier = std.extVar('cluster_identifier');
local etcd_ip = std.extVar('etcd_ip');
local etcd_tls_ca = std.extVar('etcd_tls_ca');
local etcd_tls_cert = std.extVar('etcd_tls_cert');
local etcd_tls_key = std.extVar('etcd_tls_key');
local grafana_admin_password = std.extVar('grafana_admin_password');
local prometheus_data_retention_period = std.extVar('prometheus_data_retention_period');
local prometheus_request_memory = std.extVar('prometheus_request_memory');
// Derived variables
local alert_manager_host = 'alertmanager.' + cluster_identifier + '.myorg.local';
local grafana_host = 'grafana.' + cluster_identifier + '.myorg.local';
local prometheus_host = 'prometheus.' + cluster_identifier + '.myorg.local';
// Imports
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
local ingress = k.extensions.v1beta1.ingress;
local ingressRule = ingress.mixin.spec.rulesType;
local ingressRuleHttpPath = ingressRule.mixin.http.pathsType;
local ingressTls = ingress.mixin.spec.tlsType;
local role = k.rbac.v1.role;
local roleBinding = k.rbac.v1.roleBinding;
local roleRulesType = k.rbac.v1.role.rulesType;
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet') +
(import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') +
{
_config+:: {
// Override namespace
namespace: 'monitoring',
// Override alert manager config
// See https://github.com/coreos/kube-prometheus/tree/master/examples/alertmanager-config-external.jsonnet
alertmanager+: {
config: importstr 'alertmanager.yaml',
},
// Override etcd config
// See https://github.com/coreos/kube-prometheus/blob/master/jsonnet/kube-prometheus/kube-prometheus-static-etcd.libsonnet
// See https://github.com/coreos/kube-prometheus/blob/master/examples/etcd-skip-verify.jsonnet
etcd+:: {
clientCA: etcd_tls_ca,
clientCert: etcd_tls_cert,
clientKey: etcd_tls_key,
ips: [etcd_ip],
},
// Override grafana config
// anonymous access
// See http://docs.grafana.org/installation/configuration/
// See http://docs.grafana.org/auth/overview/#anonymous-authentication
// admin_password
// See http://docs.grafana.org/installation/configuration/#admin-password
grafana+:: {
config: {
sections: {
'auth.anonymous': {
enabled: true,
},
security: {
admin_password: grafana_admin_password,
},
},
},
},
},
// Additional grafana dashboards
grafanaDashboards+:: {
'my-specific.json': (import 'my-grafana-dashboard-definitions.json'),
},
// Alert manager needs an externalUrl
alertmanager+:: {
alertmanager+: {
spec+: {
// See https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md
// See https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/exposing-prometheus-and-alertmanager.md
externalUrl: 'https://' + alert_manager_host,
},
},
},
// Add additional ingresses
// See https://github.com/coreos/kube-prometheus/tree/master/examples/ingress.jsonnet
ingress+:: {
alertmanager:
ingress.new() +
ingress.mixin.metadata.withName('alertmanager') +
ingress.mixin.metadata.withNamespace($._config.namespace) +
ingress.mixin.metadata.withAnnotations({
'kubernetes.io/ingress.class': 'nginx-api',
}) +
ingress.mixin.spec.withRules(
ingressRule.new() +
ingressRule.withHost(alert_manager_host) +
ingressRule.mixin.http.withPaths(
ingressRuleHttpPath.new() +
ingressRuleHttpPath.mixin.backend.withServiceName('alertmanager-operated') +
ingressRuleHttpPath.mixin.backend.withServicePort(9093)
),
) +
// Note we do not need a TLS secretName here as we are going to use the nginx-ingress default secret which is a wildcard
// secretName would need to be in the same namespace at this time, see https://github.com/kubernetes/ingress-nginx/issues/2371
ingress.mixin.spec.withTls(
ingressTls.new() +
ingressTls.withHosts(alert_manager_host)
),
grafana:
ingress.new() +
ingress.mixin.metadata.withName('grafana') +
ingress.mixin.metadata.withNamespace($._config.namespace) +
ingress.mixin.metadata.withAnnotations({
'kubernetes.io/ingress.class': 'nginx-api',
}) +
ingress.mixin.spec.withRules(
ingressRule.new() +
ingressRule.withHost(grafana_host) +
ingressRule.mixin.http.withPaths(
ingressRuleHttpPath.new() +
ingressRuleHttpPath.mixin.backend.withServiceName('grafana') +
ingressRuleHttpPath.mixin.backend.withServicePort(3000)
),
) +
// Note we do not need a TLS secretName here as we are going to use the nginx-ingress default secret which is a wildcard
// secretName would need to be in the same namespace at this time, see https://github.com/kubernetes/ingress-nginx/issues/2371
ingress.mixin.spec.withTls(
ingressTls.new() +
ingressTls.withHosts(grafana_host)
),
prometheus:
ingress.new() +
ingress.mixin.metadata.withName('prometheus') +
ingress.mixin.metadata.withNamespace($._config.namespace) +
ingress.mixin.metadata.withAnnotations({
'kubernetes.io/ingress.class': 'nginx-api',
}) +
ingress.mixin.spec.withRules(
ingressRule.new() +
ingressRule.withHost(prometheus_host) +
ingressRule.mixin.http.withPaths(
ingressRuleHttpPath.new() +
ingressRuleHttpPath.mixin.backend.withServiceName('prometheus-operated') +
ingressRuleHttpPath.mixin.backend.withServicePort(9090)
),
) +
// Note we do not need a TLS secretName here as we are going to use the nginx-ingress default secret which is a wildcard
// secretName would need to be in the same namespace at this time, see https://github.com/kubernetes/ingress-nginx/issues/2371
ingress.mixin.spec.withTls(
ingressTls.new() +
ingressTls.withHosts(prometheus_host)
),
},
// Node exporter PSP role and role binding
// Add a new top level field for this, the "node-exporter" PSP already exists, so not defining here just referencing
// See https://github.com/coreos/prometheus-operator/issues/787
nodeExporterPSP: {
role:
role.new() +
role.mixin.metadata.withName('node-exporter-psp') +
role.mixin.metadata.withNamespace($._config.namespace) +
role.withRules([
roleRulesType.new() +
roleRulesType.withApiGroups(['policy']) +
roleRulesType.withResources(['podsecuritypolicies']) +
roleRulesType.withVerbs(['use']) +
roleRulesType.withResourceNames(['node-exporter']),
]),
roleBinding:
roleBinding.new() +
roleBinding.mixin.roleRef.withApiGroup('rbac.authorization.k8s.io') +
roleBinding.mixin.metadata.withName('node-exporter-psp') +
roleBinding.mixin.metadata.withNamespace($._config.namespace) +
roleBinding.mixin.roleRef.withName('node-exporter-psp') +
roleBinding.mixin.roleRef.mixinInstance({ kind: 'Role' }) +
roleBinding.withSubjects([{ kind: 'ServiceAccount', name: 'node-exporter' }]),
},
// Prometheus needs some extra custom config
prometheus+:: {
prometheus+: {
spec+: {
// See https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
externalLabels: {
cluster: cluster_identifier,
},
// See https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md
// See https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/exposing-prometheus-and-alertmanager.md
externalUrl: 'https://' + prometheus_host,
// Override reuest memory
resources: {
requests: {
memory: prometheus_request_memory,
},
},
// Override data retention period
retention: prometheus_data_retention_period,
},
},
},
// Additional prometheus rules
// See https://github.com/coreos/kube-prometheus/docs/developing-prometheus-rules-and-grafana-dashboards.md
// cat my-prometheus-rules.yaml | gojsontoyaml -yamltojson | jq . > my-prometheus-rules.json
prometheusRules+:: {
groups+: import 'my-prometheus-rules.json',
},
};
// Render
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ [name + '-ingress']: kp.ingress[name] for name in std.objectFields(kp.ingress) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['node-exporter-psp-' + name]: kp.nodeExporterPSP[name] for name in std.objectFields(kp.nodeExporterPSP) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }

View File

@@ -0,0 +1,316 @@
// Has the following customisations
// Custom alert manager config
// Ingresses for the alert manager, prometheus and grafana
// Grafana admin user password
// Custom prometheus rules
// Custom grafana dashboards
// Custom prometheus config - Data retention, memory, etc.
// Node exporter role and role binding so we can use a PSP for the node exporter
// for help with expected content, see https://github.com/thaum-xyz/ankhmorpork
// External variables
// See https://jsonnet.org/learning/tutorial.html
local cluster_identifier = std.extVar('cluster_identifier');
local etcd_ip = std.extVar('etcd_ip');
local etcd_tls_ca = std.extVar('etcd_tls_ca');
local etcd_tls_cert = std.extVar('etcd_tls_cert');
local etcd_tls_key = std.extVar('etcd_tls_key');
local grafana_admin_password = std.extVar('grafana_admin_password');
local prometheus_data_retention_period = std.extVar('prometheus_data_retention_period');
local prometheus_request_memory = std.extVar('prometheus_request_memory');
// Derived variables
local alert_manager_host = 'alertmanager.' + cluster_identifier + '.myorg.local';
local grafana_host = 'grafana.' + cluster_identifier + '.myorg.local';
local prometheus_host = 'prometheus.' + cluster_identifier + '.myorg.local';
// ksonnet no longer required
local kp =
(import 'kube-prometheus/main.libsonnet') +
// kubeadm now achieved by setting platform value - see 9 lines below
(import 'kube-prometheus/addons/static-etcd.libsonnet') +
(import 'kube-prometheus/addons/podsecuritypolicies.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
// Add kubeadm platform-specific items,
// including kube-contoller-manager and kube-scheduler discovery
kubePrometheus+: {
platform: 'kubeadm',
},
// Override alert manager config
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/examples/alertmanager-config-external.jsonnet
alertmanager+: {
config: importstr 'alertmanager.yaml',
},
// Override etcd config
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/addons/static-etcd.libsonnet
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/examples/etcd-skip-verify.jsonnet
etcd+:: {
clientCA: etcd_tls_ca,
clientCert: etcd_tls_cert,
clientKey: etcd_tls_key,
ips: [etcd_ip],
},
// Override grafana config
// anonymous access
// See http://docs.grafana.org/installation/configuration/
// See http://docs.grafana.org/auth/overview/#anonymous-authentication
// admin_password
// See http://docs.grafana.org/installation/configuration/#admin-password
grafana+:: {
config: {
sections: {
'auth.anonymous': {
enabled: true,
},
security: {
admin_password: grafana_admin_password,
},
},
},
// Additional grafana dashboards
dashboards+:: {
'my-specific.json': (import 'my-grafana-dashboard-definitions.json'),
},
},
},
// Alert manager needs an externalUrl
alertmanager+:: {
alertmanager+: {
spec+: {
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/exposing-prometheus-alertmanager-grafana-ingress.md
externalUrl: 'https://' + alert_manager_host,
},
},
},
// Add additional ingresses
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/examples/ingress.jsonnet
ingress+:: {
alertmanager: {
apiVersion: 'networking.k8s.io/v1',
kind: 'Ingress',
metadata: {
name: 'alertmanager',
namespace: $.values.common.namespace,
annotations: {
'kubernetes.io/ingress.class': 'nginx-api',
},
},
spec: {
rules: [{
host: alert_manager_host,
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'alertmanager-operated',
port: {
number: 9093,
},
},
},
}],
},
}],
tls: [{
hosts: [alert_manager_host],
}],
},
},
grafana: {
apiVersion: 'networking.k8s.io/v1',
kind: 'Ingress',
metadata: {
name: 'grafana',
namespace: $.values.common.namespace,
annotations: {
'kubernetes.io/ingress.class': 'nginx-api',
},
},
spec: {
rules: [{
host: grafana_host,
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'grafana',
port: {
number: 3000,
},
},
},
}],
},
}],
tls: [{
hosts: [grafana_host],
}],
},
},
prometheus: {
apiVersion: 'networking.k8s.io/v1',
kind: 'Ingress',
metadata: {
name: 'prometheus',
namespace: $.values.common.namespace,
annotations: {
'kubernetes.io/ingress.class': 'nginx-api',
},
},
spec: {
rules: [{
host: prometheus_host,
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'prometheus-operated',
port: {
number: 9090,
},
},
},
}],
},
}],
tls: [{
hosts: [prometheus_host],
}],
},
},
},
// Node exporter PSP role and role binding
nodeExporter+: {
'psp-role'+: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'Role',
metadata: {
name: 'node-exporter-psp',
namespace: $.values.common.namespace,
},
rules: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: ['node-exporter'],
}],
},
'psp-rolebinding'+: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'RoleBinding',
metadata: {
name: 'node-exporter-psp',
namespace: $.values.common.namespace,
},
roleRef: {
apiGroup: 'rbac.authorization.k8s.io',
name: 'node-exporter-psp',
kind: 'Role',
},
subjects: [{
kind: 'ServiceAccount',
name: 'node-exporter',
}],
},
},
// Prometheus needs some extra custom config
prometheus+:: {
prometheus+: {
spec+: {
externalLabels: {
cluster: cluster_identifier,
},
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/exposing-prometheus-alertmanager-grafana-ingress.md
externalUrl: 'https://' + prometheus_host,
// Override reuest memory
resources: {
requests: {
memory: prometheus_request_memory,
},
},
// Override data retention period
retention: prometheus_data_retention_period,
},
},
},
// Additional prometheus rules
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/developing-prometheus-rules-and-grafana-dashboards.md#pre-rendered-rules
// cat my-prometheus-rules.yaml | gojsontoyaml -yamltojson | jq . > my-prometheus-rules.json
prometheusMe: {
rules: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
labels: {
'app.kubernetes.io/name': 'kube-prometheus',
'app.kubernetes.io/part-of': 'kube-prometheus',
prometheus: 'k8s',
role: 'alert-rules',
},
},
spec: {
groups: import 'my-prometheus-rules.json',
},
},
},
};
// Render
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ [name + '-ingress']: kp.ingress[name] for name in std.objectFields(kp.ingress) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
+ { ['prometheus-my-' + name]: kp.prometheusMe[name] for name in std.objectFields(kp.prometheusMe) }

View File

@@ -0,0 +1,250 @@
## Example of conversion of a legacy my.jsonnet file
An example conversion of a legacy custom jsonnet file to release-0.8
format can be seen by viewing and comparing this
[release-0.3 jsonnet file](./my.release-0.3.jsonnet) (when the github
repo was under `https://github.com/coreos/kube-prometheus...`)
and the corresponding [release-0.8 jsonnet file](./my.release-0.8.jsonnet).
These two files have had necessary blank lines added so that they
can be compared side-by-side and line-by-line on screen.
The conversion covers both the change of stopping using ksonnet after
release-0.3 and also the major migration after release-0.7 as described in
[migration-guide.md](../migration-guide.md)
The sample files are intended as an example of format conversion and
not necessarily best practice for the files in release-0.3 or release-0.8.
Below are three sample extracts of the conversion as an indication of the
changes required.
<table>
<tr>
<th> release-0.3 </th>
<th> release-0.8 </th>
</tr>
<tr>
<td>
```jsonnet
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet') +
(import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') +
{
_config+:: {
// Override namespace
namespace: 'monitoring',
```
</td>
<td>
```jsonnet
local kp =
(import 'kube-prometheus/main.libsonnet') +
// kubeadm now achieved by setting platform value - see 9 lines below
(import 'kube-prometheus/addons/static-etcd.libsonnet') +
(import 'kube-prometheus/addons/podsecuritypolicies.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
// Add kubeadm platform-specific items,
// including kube-contoller-manager and kube-scheduler discovery
kubePrometheus+: {
platform: 'kubeadm',
},
```
</td>
</tr>
</table>
<table>
<tr>
<th> release-0.3 </th>
<th> release-0.8 </th>
</tr>
<tr>
<td>
```jsonnet
// Add additional ingresses
// See https://github.com/coreos/kube-prometheus/...
// tree/master/examples/ingress.jsonnet
ingress+:: {
alertmanager:
ingress.new() +
ingress.mixin.metadata.withName('alertmanager') +
ingress.mixin.metadata.withNamespace($._config.namespace) +
ingress.mixin.metadata.withAnnotations({
'kubernetes.io/ingress.class': 'nginx-api',
}) +
ingress.mixin.spec.withRules(
ingressRule.new() +
ingressRule.withHost(alert_manager_host) +
ingressRule.mixin.http.withPaths(
ingressRuleHttpPath.new() +
ingressRuleHttpPath.mixin.backend
.withServiceName('alertmanager-operated') +
ingressRuleHttpPath.mixin.backend.withServicePort(9093)
),
) +
// Note we do not need a TLS secretName here as we are going to use the
// nginx-ingress default secret which is a wildcard
// secretName would need to be in the same namespace at this time,
// see https://github.com/kubernetes/ingress-nginx/issues/2371
ingress.mixin.spec.withTls(
ingressTls.new() +
ingressTls.withHosts(alert_manager_host)
),
```
</td>
<td>
```jsonnet
// Add additional ingresses
// See https://github.com/prometheus-operator/kube-prometheus/...
// blob/main/examples/ingress.jsonnet
ingress+:: {
alertmanager: {
apiVersion: 'networking.k8s.io/v1',
kind: 'Ingress',
metadata: {
name: 'alertmanager',
namespace: $.values.common.namespace,
annotations: {
'kubernetes.io/ingress.class': 'nginx-api',
},
},
spec: {
rules: [{
host: alert_manager_host,
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'alertmanager-operated',
port: {
number: 9093,
},
},
},
}],
},
}],
tls: [{
hosts: [alert_manager_host],
}],
},
},
```
</td>
</tr>
</table>
<table>
<tr>
<th> release-0.3 </th>
<th> release-0.8 </th>
</tr>
<tr>
<td>
```jsonnet
// Additional prometheus rules
// See https://github.com/coreos/kube-prometheus/docs/...
// developing-prometheus-rules-and-grafana-dashboards.md
//
// cat my-prometheus-rules.yaml | \
// gojsontoyaml -yamltojson | \
// jq . > my-prometheus-rules.json
prometheusRules+:: {
groups+: import 'my-prometheus-rules.json',
},
};
```
</td>
<td>
```jsonnet
// Additional prometheus rules
// See https://github.com/prometheus-operator/kube-prometheus/blob/main/...
// docs/developing-prometheus-rules-and-grafana-dashboards.md...
// #pre-rendered-rules
// cat my-prometheus-rules.yaml | \
// gojsontoyaml -yamltojson | \
// jq . > my-prometheus-rules.json
prometheusMe: {
rules: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
labels: {
'app.kubernetes.io/name': 'kube-prometheus',
'app.kubernetes.io/part-of': 'kube-prometheus',
prometheus: 'k8s',
role: 'alert-rules',
},
},
spec: {
groups: import 'my-prometheus-rules.json',
},
},
},
};
...
+ { ['prometheus-my-' + name]: kp.prometheusMe[name] for name in std.objectFields(kp.prometheusMe) }
```
</td>
</tr>
</table>

87
docs/migration-guide.md Normal file
View File

@@ -0,0 +1,87 @@
# Migration guide from release-0.7 and earlier
## Why?
Thanks to our community we identified a lot of short-commings of previous design, varying from issues with global state to UX problems. Hoping to fix at least part of those issues we decided to do a complete refactor of the codebase.
## Overview
### Breaking Changes
- global `_config` object is removed and the new `values` object is a partial replacement
- `imageRepos` field was removed and the project no longer tries to compose image strings. Use `$.values.common.images` to override default images.
- prometheus alerting and recording rules are split into multiple `PrometheusRule` objects
- kubernetes control plane ServiceMonitors and Services are now part of the new `kubernetesControlPlane` top-level object instead of `prometheus` object
- `jsonnet/kube-prometheus/kube-prometheus.libsonnet` file was renamed to `jsonnet/kube-prometheus/main.libsonnet` and slimmed down to bare minimum
- `jsonnet/kube-prometheus/kube-prometheus*-.libsonnet` files were move either to `jsonnet/kube-prometheus/addons/` or `jsonnet/kube-prometheus/platforms/` depending on the feature they provided
- all component libraries are now function- and not object-based
- monitoring-mixins are included inside each component and not globally. `prometheusRules`, `prometheusAlerts`, and `grafanaDashboards` are accessible only per component via `mixin` object (ex. `$.alertmanager.mixin.prometheusAlerts`)
- default repository branch changed from `master` to `main`
- labels on resources have changes, `kubectl apply` will not work correctly due to those field being immutable. Deleting the resource first before applying is a workaround if you are using the kubectl CLI. (This only applies to `Deployments` and `DaemonSets`.)
### New Features
- concept of `addons`, `components`, and `platforms` was introduced
- all main `components` are now represented internally by a function with default values and required parameters (see #Component-configuration for more information)
- `$.values` holds main configuration parameters and should be used to set basic stack configuration.
- common parameters across all `components` are stored now in `$.values.common`
- removed dependency on deprecated ksonnet library
## Details
### Components, Addons, Platforms
Those concepts were already present in the repository but it wasn't clear which file is holding what. After refactoring we categorized jsonnet code into 3 buckets and put them into separate directories:
- `components` - main building blocks for kube-prometheus, written as functions responsible for creating multiple objects representing kubernetes manifests. For example all objects for node_exporter deployment are bundled in `components/node_exporter.libsonnet` library
- `addons` - everything that can enhance kube-prometheus deployment. Those are small snippets of code adding a small feature, for example adding anti-affinity to pods via [`addons/anti-affinity.libsonnet`][antiaffinity]. Addons are meant to be used in object-oriented way like `local kp = (import 'kube-prometheus/main.libsonnet') + (import 'kube-prometheus/addons/all-namespaces.libsonnet')`
- `platforms` - currently those are `addons` specialized to allow deploying kube-prometheus project on a specific platform.
### Component configuration
Refactoring main components to use functions allowed us to define APIs for said components. Each function has a default set of parameters that can be overridden or that are required to be set by a user. Those default parameters are represented in each component by `defaults` map at the top of each library file, for example in [`node_exporter.libsonnet`][node_exporter_defaults_example].
This API is meant to ease the use of kube-prometheus as parameters can be passed from a JSON file and don't need to be in jsonnet format. However, if you need to modify particular parts of the stack, jsonnet allows you to do this and we are also not restricting such access in any way. An example of such modifications can be seen in any of our `addons`, like the [`addons/anti-affinity.libsonnet`][antiaffinity] one.
### Mixin integration
Previously kube-prometheus project joined all mixins on a global level. However with a wider adoption of monitoring mixins this turned out to be a problem, especially apparent when two mixins started to use the same configuration field for different purposes. To fix this we moved all mixins into their own respective components:
- alertmanager mixin -> `alertmanager.libsonnet`
- kubernetes mixin -> `k8s-control-plane.libsonnet`
- kube-state-metrics mixin -> `kube-state-metrics.libsonnet`
- node_exporter mixin -> `node_exporter.libsonnet`
- prometheus and thanos sidecar mixins -> `prometheus.libsonnet`
- prometheus-operator mixin -> `prometheus-operator.libsonnet`
- kube-prometheus alerts and rules -> `components/mixin/custom.libsonnet`
> etcd mixin is a special case as we add it inside an `addon` in `addons/static-etcd.libsonnet`
This results in creating multiple `PrometheusRule` objects instead of having one giant object as before. It also means each mixin is configured separately and accessing mixin objects is done via `$.<component>.mixin`.
## Examples
All examples from `examples/` directory were adapted to the new codebase. [Please take a look at them for guideance](https://github.com/prometheus-operator/kube-prometheus/tree/main/examples)
## Legacy migration
An example of conversion of a legacy release-0.3 my.jsonnet file to release-0.8 can be found in [migration-example](./migration-example)
## Advanced usage examples
For more advanced usage examples you can take a look at those two, open to public, implementations:
- [thaum-xyz/ankhmorpork][thaum] - extending kube-prometheus to adapt to a required environment
- [openshift/cluster-monitoring-operator][openshift] - using kube-prometheus components as standalone libraries to build a custom solution
## Final note
Refactoring was a huge undertaking and possibly this document didn't describe in enough detail how to help you with migration to the new stack. If that is the case, please reach out to us by using [GitHub discussions][discussions] feature or directly on [#prometheus-operator kubernetes slack channel][slack].
[antiaffinity]: https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/addons/anti-affinity.libsonnet
[node_exporter_defaults_example]: https://github.com/prometheus-operator/kube-prometheus/blob/1d2a0e275af97948667777739a18b24464480dc8/jsonnet/kube-prometheus/components/node-exporter.libsonnet#L3-L34
[openshift]: https://github.com/openshift/cluster-monitoring-operator/pull/1044
[thaum]: https://github.com/thaum-xyz/ankhmorpork/blob/master/apps/monitoring/jsonnet
[discussions]: https://github.com/prometheus-operator/kube-prometheus/discussions
[slack]: http://slack.k8s.io/

View File

@@ -1,5 +1,18 @@
# Monitoring external etcd
This guide will help you monitor an external etcd cluster. When the etcd cluster is not hosted inside Kubernetes.
---
title: "Monitoring external etcd"
description: "This guide will help you monitor an external etcd cluster."
lead: "This guide will help you monitor an external etcd cluster."
date: 2021-03-08T23:04:32+01:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 640
toc: true
---
When the etcd cluster is not hosted inside Kubernetes.
This is often the case with Kubernetes setups. This approach has been tested with kube-aws but the same principals apply to other tools.
Note that [etcd.jsonnet](../examples/etcd.jsonnet) & [kube-prometheus-static-etcd.libsonnet](../jsonnet/kube-prometheus/kube-prometheus-static-etcd.libsonnet) (which are described by a section of the [Readme](../README.md#static-etcd-configuration)) do the following:

View File

@@ -1,4 +1,17 @@
# Monitoring other Kubernetes Namespaces
---
title: "Monitoring other Namespaces"
description: "This guide will help you monitor applications in other Namespaces."
lead: "This guide will help you monitor applications in other Namespaces."
date: 2021-03-08T23:04:32+01:00
draft: false
images: []
menu:
docs:
parent: "kube"
weight: 640
toc: true
---
This guide will help you monitor applications in other Namespaces. By default the RBAC rules are only enabled for the `Default` and `kube-system` Namespace during Install.
# Setup

View File

@@ -17,36 +17,42 @@ Using kube-prometheus and kubectl you will be able install the following for mon
[embedmd]:# (../examples/weave-net-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-weave-net.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/weave-net/weave-net.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusAlerts+:: {
groups: std.map(
function(group)
if group.name == 'weave-net' then
group {
rules: std.map(
function(rule)
if rule.alert == 'WeaveNetFastDPFlowsLow' then
rule {
expr: 'sum(weave_flows) < 20000',
}
else if rule.alert == 'WeaveNetIPAMUnreachable' then
rule {
expr: 'weave_ipam_unreachable_percentage > 25',
}
else
rule
,
group.rules
),
}
else
group,
super.groups
),
kubernetesControlPlane+: {
prometheusRuleWeaveNet+: {
spec+: {
groups: std.map(
function(group)
if group.name == 'weave-net' then
group {
rules: std.map(
function(rule)
if rule.alert == 'WeaveNetFastDPFlowsLow' then
rule {
expr: 'sum(weave_flows) < 20000',
}
else if rule.alert == 'WeaveNetIPAMUnreachable' then
rule {
expr: 'weave_ipam_unreachable_percentage > 25',
}
else
rule
,
group.rules
),
}
else
group,
super.groups
),
},
},
},
};

22
docs/windows.md Normal file
View File

@@ -0,0 +1,22 @@
# Windows
The [Windows addon](../examples/windows.jsonnet) adds the dashboards and rules from [kubernetes-monitoring/kubernetes-mixin](https://github.com/kubernetes-monitoring/kubernetes-mixin#dashboards-for-windows-nodes).
Currently, Windows does not support running with [windows_exporter](https://github.com/prometheus-community/windows_exporter) in a pod so this add on uses [additional scrape configuration](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/additional-scrape-config.md) to set up a static config to scrape the node ports where windows_exporter is configured.
The addon requires you to specify the node ips and ports where it can find the windows_exporter. See the [full example](../examples/windows.jsonnet) for setup.
```
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/windows.libsonnet') +
{
values+:: {
windowsScrapeConfig+:: {
static_configs: {
targets: ["10.240.0.65:5000", "10.240.0.63:5000"],
},
},
},
};
```

View File

@@ -1,29 +1,34 @@
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/main.libsonnet') +
// Uncomment the following imports to enable its patches
// (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-managed-cluster.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-node-ports.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-thanos-sidecar.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-custom-metrics.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-external-metrics.libsonnet') +
// (import 'kube-prometheus/addons/anti-affinity.libsonnet') +
// (import 'kube-prometheus/addons/managed-cluster.libsonnet') +
// (import 'kube-prometheus/addons/node-ports.libsonnet') +
// (import 'kube-prometheus/addons/static-etcd.libsonnet') +
// (import 'kube-prometheus/addons/custom-metrics.libsonnet') +
// (import 'kube-prometheus/addons/external-metrics.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }

View File

@@ -1,11 +1,13 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+:: {
namespaces+: ['my-namespace', 'my-second-namespace'],
},
},
prometheus+:: {
exampleApplication: {
serviceMonitorMyNamespace: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
@@ -37,4 +39,5 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }

View File

@@ -1,8 +1,10 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+:: {
prometheus+: {
namespaces+: ['my-namespace', 'my-second-namespace'],
},
},

View File

@@ -1,5 +1,5 @@
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
((import 'kube-prometheus/main.libsonnet') + {
values+:: {
alertmanager+: {
config: importstr 'alertmanager-config.yaml',
},

View File

@@ -1,5 +1,5 @@
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
((import 'kube-prometheus/main.libsonnet') + {
values+:: {
alertmanager+: {
config: |||
global:

View File

@@ -1,9 +1,10 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-all-namespaces.libsonnet') + {
_config+:: {
namespace: 'monitoring',
prometheus+:: {
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/all-namespaces.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+: {
namespaces: [],
},
},

View File

@@ -1,5 +1,13 @@
local kp = (import './kube-prometheus/kube-prometheus.libsonnet');
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/anti-affinity.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +

View File

@@ -0,0 +1,92 @@
local filter = {
kubernetesControlPlane+: {
prometheusRule+:: {
spec+: {
groups: std.map(
function(group)
if group.name == 'kubernetes-apps' then
group {
rules: std.filter(
function(rule)
rule.alert != 'KubeStatefulSetReplicasMismatch',
group.rules
),
}
else
group,
super.groups
),
},
},
},
};
local update = {
kubernetesControlPlane+: {
prometheusRule+:: {
spec+: {
groups: std.map(
function(group)
if group.name == 'kubernetes-apps' then
group {
rules: std.map(
function(rule)
if rule.alert == 'KubePodCrashLooping' then
rule {
expr: 'rate(kube_pod_container_status_restarts_total{namespace=kube-system,job="kube-state-metrics"}[10m]) * 60 * 5 > 0',
}
else
rule,
group.rules
),
}
else
group,
super.groups
),
},
},
},
};
local add = {
exampleApplication:: {
prometheusRule+: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'example-application-rules',
namespace: $.values.common.namespace,
},
spec: (import 'existingrule.json'),
},
},
};
local kp = (import 'kube-prometheus/main.libsonnet') +
filter +
update +
add + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) } +
{ ['exampleApplication-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }

View File

@@ -1,7 +1,8 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};

View File

@@ -1,20 +1,28 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-eks.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
kubePrometheus+: {
platform: 'eks',
},
},
prometheusRules+:: {
groups+: [
{
name: 'example-group',
rules: [
kubernetesControlPlane+: {
prometheusRuleEksCNI+: {
spec+: {
groups+: [
{
record: 'aws_eks_available_ip',
expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < 10',
name: 'example-group',
rules: [
{
record: 'aws_eks_available_ip',
expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < 10',
},
],
},
],
},
],
},
},
};

View File

@@ -1,8 +1,9 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/static-etcd.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
etcd+:: {
ips: ['127.0.0.1'],
clientCA: importstr 'etcd-client-ca.crt',

View File

@@ -1,10 +1,12 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/static-etcd.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
// Reference info: https://github.com/coreos/kube-prometheus/blob/master/README.md#static-etcd-configuration
etcd+:: {
etcd+: {
// Configure this to be the IP(s) to scrape - i.e. your etcd node(s) (use commas to separate multiple values).
ips: ['127.0.0.1'],

View File

@@ -1 +1 @@
{"groups":[{"name":"example-group","rules":[{"alert":"Watchdog","annotations":{"description":"This is a Watchdog meant to ensure that the entire alerting pipeline is functional."},"expr":"vector(1)","labels":{"severity":"none"}}]}]}
{"groups":[{"name":"example-group","rules":[{"alert":"ExampleAlert","annotations":{"description":"This is an example alert."},"expr":"vector(1)","labels":{"severity":"warning"}}]}]}

View File

@@ -1,9 +1,9 @@
groups:
- name: example-group
rules:
- alert: Watchdog
- alert: ExampleAlert
expr: vector(1)
labels:
severity: "none"
severity: "warning"
annotations:
description: This is a Watchdog meant to ensure that the entire alerting pipeline is functional.
description: This is an example alert.

View File

@@ -5,35 +5,37 @@ local prometheus = grafana.prometheus;
local template = grafana.template;
local graphPanel = grafana.graphPanel;
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
},
grafana+:: {
dashboards+:: {
'my-dashboard.json':
dashboard.new('My Dashboard')
.addTemplate(
{
current: {
text: 'Prometheus',
value: 'Prometheus',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+:: {
namespace: 'monitoring',
},
grafana+: {
dashboards+:: {
'my-dashboard.json':
dashboard.new('My Dashboard')
.addTemplate(
{
current: {
text: 'Prometheus',
value: 'Prometheus',
},
hide: 0,
label: null,
name: 'datasource',
options: [],
query: 'prometheus',
refresh: 1,
regex: '',
type: 'datasource',
},
hide: 0,
label: null,
name: 'datasource',
options: [],
query: 'prometheus',
refresh: 1,
regex: '',
type: 'datasource',
},
)
.addRow(
row.new()
.addPanel(graphPanel.new('My Panel', span=6, datasource='$datasource')
.addTarget(prometheus.target('vector(1)')))
),
)
.addRow(
row.new()
.addPanel(graphPanel.new('My Panel', span=6, datasource='$datasource')
.addTarget(prometheus.target('vector(1)')))
),
},
},
},
};

View File

@@ -1,10 +1,12 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
},
grafana+:: {
rawDashboards+:: {
'my-dashboard.json': (importstr 'example-grafana-dashboard.json'),
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+:: {
namespace: 'monitoring',
},
grafana+: {
rawDashboards+:: {
'my-dashboard.json': (importstr 'example-grafana-dashboard.json'),
},
},
},
};

View File

@@ -1,13 +1,12 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
},
grafanaDashboards+:: { // monitoring-mixin compatibility
'my-dashboard.json': (import 'example-grafana-dashboard.json'),
},
grafana+:: {
dashboards+:: { // use this method to import your dashboards to Grafana
'my-dashboard.json': (import 'example-grafana-dashboard.json'),
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+:: {
namespace: 'monitoring',
},
grafana+: {
dashboards+:: { // use this method to import your dashboards to Grafana
'my-dashboard.json': (import 'example-grafana-dashboard.json'),
},
},
},
};

View File

@@ -0,0 +1,36 @@
local kp =
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
grafana+: {
config+: {
sections: {
'auth.ldap': {
enabled: true,
config_file: '/etc/grafana/ldap.toml',
allow_sign_up: true,
},
},
},
ldap: |||
[[servers]]
host = "127.0.0.1"
port = 389
use_ssl = false
start_tls = false
ssl_skip_verify = false
bind_dn = "cn=admins,dc=example,dc=com"
bind_password = 'grafana'
search_filter = "(cn=%s)"
search_base_dns = ["dc=example,dc=com"]
|||,
},
},
};
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }

View File

@@ -0,0 +1,25 @@
local kp =
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
},
// Disable all grafana-related objects apart from dashboards and datasource
grafana: {
dashboardSources:: {},
deployment:: {},
serviceAccount:: {},
serviceMonitor:: {},
service:: {},
},
};
// Manifestation
{
[component + '-' + resource + '.json']: kp[component][resource]
for component in std.objectFields(kp)
for resource in std.objectFields(kp[component])
}

View File

@@ -14,10 +14,12 @@ local ingress(name, namespace, rules) = {
};
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/main.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
values+:: {
common+: {
namespace: 'monitoring',
},
grafana+:: {
config+: {
sections+: {
@@ -47,15 +49,19 @@ local kp =
ingress+:: {
'alertmanager-main': ingress(
'alertmanager-main',
$._config.namespace,
$.values.common.namespace,
[{
host: 'alertmanager.example.com',
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'alertmanager-main',
port: 'web',
port: {
name: 'web',
},
},
},
}],
@@ -64,15 +70,19 @@ local kp =
),
grafana: ingress(
'grafana',
$._config.namespace,
$.values.common.namespace,
[{
host: 'grafana.example.com',
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'grafana',
port: 'http',
port: {
name: 'http',
},
},
},
}],
@@ -81,15 +91,19 @@ local kp =
),
'prometheus-k8s': ingress(
'prometheus-k8s',
$._config.namespace,
$.values.common.namespace,
[{
host: 'prometheus.example.com',
http: {
paths: [{
path: '/',
pathType: 'Prefix',
backend: {
service: {
name: 'prometheus-k8s',
port: 'web',
port: {
name: 'web',
},
},
},
}],
@@ -105,7 +119,7 @@ local kp =
kind: 'Secret',
metadata: {
name: 'basic-auth',
namespace: $._config.namespace,
namespace: $.values.common.namespace,
},
data: { auth: std.base64(importstr 'auth') },
type: 'Opaque',

View File

@@ -1,7 +1,9 @@
local mixin = import 'kube-prometheus/kube-prometheus-config-mixins.libsonnet';
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local mixin = import 'kube-prometheus/addons/config-mixins.libsonnet';
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
} + mixin.withImageRepository('internal-registry.com/organization');

View File

@@ -1,2 +0,0 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-bootkube.libsonnet')

View File

@@ -1,3 +0,0 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kops.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kops-coredns.libsonnet')

View File

@@ -1,2 +0,0 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kops.libsonnet')

View File

@@ -1,2 +0,0 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kube-aws.libsonnet')

View File

@@ -1,2 +0,0 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet')

View File

@@ -1,2 +0,0 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubespray.libsonnet')

View File

@@ -1,2 +1,2 @@
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-node-ports.libsonnet')
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/node-ports.libsonnet')

View File

@@ -0,0 +1,8 @@
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
platform: 'example-platform',
},
},
}

View File

@@ -1,4 +1,4 @@
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
((import 'kube-prometheus/main.libsonnet') + {
nodeExporter+: {
daemonset+: {
metadata+: {

View File

@@ -0,0 +1,20 @@
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
kubernetesControlPlane+: {
kubeProxy: true,
},
},
};
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }

View File

@@ -1,26 +1,32 @@
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
(import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};
local manifests =
// Uncomment line below to enable vertical auto scaling of kube-state-metrics
//{ ['ksm-autoscaler-' + name]: kp.ksmAutoscaler[name] for name in std.objectFields(kp.ksmAutoscaler) } +
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) };
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) };
local kustomizationResourceFile(name) = './manifests/' + name + '.yaml';
local kustomization = {

View File

@@ -1,15 +1,16 @@
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet') +
(import 'kube-prometheus/main.libsonnet') +
// Note that NodePort type services is likely not a good idea for your production use case, it is only used for demonstration purposes here.
(import 'kube-prometheus/kube-prometheus-node-ports.libsonnet') +
(import 'kube-prometheus/addons/node-ports.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
alertmanager+:: {
values+:: {
common+: {
namespace: 'monitoring',
},
alertmanager+: {
config: importstr 'alertmanager-config.yaml',
},
grafana+:: {
grafana+: {
config: { // http://docs.grafana.org/installation/configuration/
sections: {
// Do not require grafana users to login/authenticate
@@ -17,12 +18,15 @@ local kp =
},
},
},
kubePrometheus+: {
platform: 'kubeadm',
},
},
// For simplicity, each of the following values for 'externalUrl':
// * assume that `minikube ip` prints "192.168.99.100"
// * hard-code the NodePort for each app
prometheus+:: {
prometheus+: {
prometheus+: {
// Reference info: https://coreos.com/operators/prometheus/docs/latest/api.html#prometheusspec
spec+: {
@@ -38,7 +42,7 @@ local kp =
},
},
},
alertmanager+:: {
alertmanager+: {
alertmanager+: {
// Reference info: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#alertmanagerspec
spec+: {

View File

@@ -0,0 +1,30 @@
local addMixin = (import 'kube-prometheus/lib/mixin.libsonnet');
local etcdMixin = addMixin({
name: 'etcd',
mixin: (import 'github.com/etcd-io/etcd/contrib/mixin/mixin.libsonnet') + {
_config+: {}, // mixin configuration object
},
});
local kp = (import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
grafana+: {
// Adding new dashboard to grafana. This will modify grafana configMap with dashboards
dashboards+: etcdMixin.grafanaDashboards,
},
},
};
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
// Rendering prometheusRules object. This is an object compatible with prometheus-operator CRD definition for prometheusRule
{ 'external-mixins/etcd-mixin-prometheus-rules': etcdMixin.prometheusRules }

View File

@@ -0,0 +1,23 @@
local kp =
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/podsecuritypolicies.libsonnet');
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
// Add the restricted psp to setup
{ 'setup/0podsecuritypolicy-restricted': kp.restrictedPodSecurityPolicy } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }

View File

@@ -1,25 +1,37 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusAlerts+:: {
groups+: [
{
name: 'example-group',
rules: [
exampleApplication: {
prometheusRuleExample: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
},
spec: {
groups: [
{
alert: 'Watchdog',
expr: 'vector(1)',
labels: {
severity: 'none',
},
annotations: {
description: 'This is a Watchdog meant to ensure that the entire alerting pipeline is functional.',
},
name: 'example-group',
rules: [
{
alert: 'ExampleAlert',
expr: 'vector(1)',
labels: {
severity: 'warning',
},
annotations: {
description: 'This is an example alert.',
},
},
],
},
],
},
],
},
},
};
@@ -30,4 +42,5 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }

View File

@@ -1,19 +1,31 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusRules+:: {
groups+: [
{
name: 'example-group',
rules: [
exampleApplication: {
prometheusRuleExample: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
},
spec: {
groups: [
{
record: 'some_recording_rule_name',
expr: 'vector(1)',
name: 'example-group',
rules: [
{
record: 'some_recording_rule_name',
expr: 'vector(1)',
},
],
},
],
},
],
},
},
};
@@ -24,4 +36,5 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }

View File

@@ -1,9 +1,21 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusAlerts+:: {
groups+: (import 'existingrule.json').groups,
exampleApplication: {
prometheusRuleExample: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
name: 'my-prometheus-rule',
namespace: $.values.common.namespace,
},
spec: {
groups: (import 'existingrule.json').groups,
},
},
},
};
@@ -14,4 +26,5 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + {
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['example-application-' + name]: kp.exampleApplication[name] for name in std.objectFields(kp.exampleApplication) }

View File

@@ -1,4 +1,4 @@
((import 'kube-prometheus/kube-prometheus.libsonnet') + {
((import 'kube-prometheus/main.libsonnet') + {
prometheus+: {
prometheus+: {
metadata+: {

View File

@@ -1,14 +1,15 @@
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/main.libsonnet') +
// Uncomment the following imports to enable its patches
// (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-managed-cluster.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-node-ports.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') +
// (import 'kube-prometheus/kube-prometheus-thanos-sidecar.libsonnet') +
// (import 'kube-prometheus/addons/anti-affinity.libsonnet') +
// (import 'kube-prometheus/addons/managed-cluster.libsonnet') +
// (import 'kube-prometheus/addons/node-ports.libsonnet') +
// (import 'kube-prometheus/addons/static-etcd.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheus+:: {

View File

@@ -1,7 +1,9 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-strip-limits.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/strip-limits.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
};

View File

@@ -0,0 +1,33 @@
local kp =
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
prometheus+: {
thanos: {
version: '0.19.0',
image: 'quay.io/thanos/thanos:v0.19.0',
objectStorageConfig: {
key: 'thanos.yaml', // How the file inside the secret is called
name: 'thanos-objectstorage', // This is the name of your Kubernetes secret with the config
},
},
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }

View File

@@ -1,23 +1,19 @@
{
_config+:: {
tolerations+:: [
{
key: 'key1',
operator: 'Equal',
value: 'value1',
effect: 'NoSchedule',
},
{
key: 'key2',
operator: 'Exists',
},
],
},
prometheus+: {
prometheus+: {
spec+: {
tolerations: [t for t in $._config.tolerations],
tolerations: [
{
key: 'key1',
operator: 'Equal',
value: 'value1',
effect: 'NoSchedule',
},
{
key: 'key2',
operator: 'Exists',
},
],
},
},
},

View File

@@ -1,33 +1,39 @@
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'kube-prometheus/kube-prometheus-weave-net.libsonnet') + {
_config+:: {
namespace: 'monitoring',
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/weave-net/weave-net.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
},
prometheusAlerts+:: {
groups: std.map(
function(group)
if group.name == 'weave-net' then
group {
rules: std.map(
function(rule)
if rule.alert == 'WeaveNetFastDPFlowsLow' then
rule {
expr: 'sum(weave_flows) < 20000',
}
else if rule.alert == 'WeaveNetIPAMUnreachable' then
rule {
expr: 'weave_ipam_unreachable_percentage > 25',
}
else
rule
,
group.rules
),
}
else
group,
super.groups
),
kubernetesControlPlane+: {
prometheusRuleWeaveNet+: {
spec+: {
groups: std.map(
function(group)
if group.name == 'weave-net' then
group {
rules: std.map(
function(rule)
if rule.alert == 'WeaveNetFastDPFlowsLow' then
rule {
expr: 'sum(weave_flows) < 20000',
}
else if rule.alert == 'WeaveNetIPAMUnreachable' then
rule {
expr: 'weave_ipam_unreachable_percentage > 25',
}
else
rule
,
group.rules
),
}
else
group,
super.groups
),
},
},
},
};

33
examples/windows.jsonnet Normal file
View File

@@ -0,0 +1,33 @@
local kp =
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/addons/windows.libsonnet') +
{
values+:: {
common+: {
namespace: 'monitoring',
},
windowsScrapeConfig+:: {
static_configs: [{
targets: ['10.240.0.65:5000', '10.240.0.63:5000'],
}],
},
},
};
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } +
{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
kubectl apply -f examples/example-app

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
kubectl delete -f examples/example-app

View File

@@ -0,0 +1,22 @@
{
prometheus+:: {
clusterRole+: {
rules+: [
{
apiGroups: [''],
resources: ['services', 'endpoints', 'pods'],
verbs: ['get', 'list', 'watch'],
},
{
apiGroups: ['networking.k8s.io'],
resources: ['ingresses'],
verbs: ['get', 'list', 'watch'],
},
],
},
// There is no need for specific namespaces RBAC as this addon grants
// all required permissions for every namespace
roleBindingSpecificNamespaces:: null,
roleSpecificNamespaces:: null,
},
}

View File

@@ -0,0 +1,99 @@
{
values+:: {
alertmanager+: {
podAntiAffinity: 'soft',
podAntiAffinityTopologyKey: 'kubernetes.io/hostname',
},
prometheus+: {
podAntiAffinity: 'soft',
podAntiAffinityTopologyKey: 'kubernetes.io/hostname',
},
blackboxExporter+: {
podAntiAffinity: 'soft',
podAntiAffinityTopologyKey: 'kubernetes.io/hostname',
},
prometheusAdapter+: {
podAntiAffinity: 'soft',
podAntiAffinityTopologyKey: 'kubernetes.io/hostname',
},
},
antiaffinity(labelSelector, namespace, type, topologyKey):: {
local podAffinityTerm = {
namespaces: [namespace],
topologyKey: topologyKey,
labelSelector: {
matchLabels: labelSelector,
},
},
affinity: {
podAntiAffinity: if type == 'soft' then {
preferredDuringSchedulingIgnoredDuringExecution: [{
weight: 100,
podAffinityTerm: podAffinityTerm,
}],
} else if type == 'hard' then {
requiredDuringSchedulingIgnoredDuringExecution: [
podAffinityTerm,
],
} else error 'podAntiAffinity must be either "soft" or "hard"',
},
},
alertmanager+: {
alertmanager+: {
spec+:
$.antiaffinity(
$.alertmanager._config.selectorLabels,
$.values.common.namespace,
$.values.alertmanager.podAntiAffinity,
$.values.alertmanager.podAntiAffinityTopologyKey,
),
},
},
prometheus+: {
prometheus+: {
spec+:
$.antiaffinity(
$.prometheus._config.selectorLabels,
$.values.common.namespace,
$.values.prometheus.podAntiAffinity,
$.values.prometheus.podAntiAffinityTopologyKey,
),
},
},
blackboxExporter+: {
deployment+: {
spec+: {
template+: {
spec+:
$.antiaffinity(
$.blackboxExporter._config.selectorLabels,
$.values.common.namespace,
$.values.blackboxExporter.podAntiAffinity,
$.values.blackboxExporter.podAntiAffinityTopologyKey,
),
},
},
},
},
prometheusAdapter+: {
deployment+: {
spec+: {
template+: {
spec+:
$.antiaffinity(
$.prometheusAdapter._config.selectorLabels,
$.values.common.namespace,
$.values.prometheusAdapter.podAntiAffinity,
$.values.prometheusAdapter.podAntiAffinityTopologyKey,
),
},
},
},
},
}

View File

@@ -0,0 +1,110 @@
{
values+:: {
awsVpcCni: {
// `minimumWarmIPs` should be inferior or equal to `WARM_IP_TARGET`.
//
// References:
// https://github.com/aws/amazon-vpc-cni-k8s/blob/v1.9.0/docs/eni-and-ip-target.md
// https://github.com/aws/amazon-vpc-cni-k8s/blob/v1.9.0/pkg/ipamd/ipamd.go#L61-L71
minimumWarmIPs: 10,
minimumWarmIPsTime: '10m',
},
},
kubernetesControlPlane+: {
serviceAwsVpcCni: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: 'aws-node',
namespace: 'kube-system',
labels: { 'app.kubernetes.io/name': 'aws-node' },
},
spec: {
ports: [
{
name: 'cni-metrics-port',
port: 61678,
targetPort: 61678,
},
],
selector: { 'app.kubernetes.io/name': 'aws-node' },
clusterIP: 'None',
},
},
serviceMonitorAwsVpcCni: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata: {
name: 'aws-node',
namespace: $.values.common.namespace,
labels: {
'app.kubernetes.io/name': 'aws-node',
},
},
spec: {
jobLabel: 'app.kubernetes.io/name',
selector: {
matchLabels: {
'app.kubernetes.io/name': 'aws-node',
},
},
namespaceSelector: {
matchNames: [
'kube-system',
],
},
endpoints: [
{
port: 'cni-metrics-port',
interval: '30s',
path: '/metrics',
relabelings: [
{
action: 'replace',
regex: '(.*)',
replacement: '$1',
sourceLabels: ['__meta_kubernetes_pod_node_name'],
targetLabel: 'instance',
},
],
},
],
},
},
prometheusRuleAwsVpcCni: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
labels: $.prometheus._config.commonLabels + $.prometheus._config.mixin.ruleLabels,
name: 'aws-vpc-cni-rules',
namespace: $.prometheus._config.namespace,
},
spec: {
groups: [
{
name: 'aws-vpc-cni.rules',
rules: [
{
expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < %s' % $.values.awsVpcCni.minimumWarmIPs,
labels: {
severity: 'critical',
},
annotations: {
summary: 'AWS VPC CNI has a low warm IP pool',
description: |||
Instance {{ $labels.instance }} has only {{ $value }} warm IPs which is lower than set threshold of %s.
It could mean the current subnet is out of available IP addresses or the CNI is unable to request them from the EC2 API.
||| % $.values.awsVpcCni.minimumWarmIPs,
},
'for': $.values.awsVpcCni.minimumWarmIPsTime,
alert: 'AwsVpcCniWarmIPsLow',
},
],
},
],
},
},
},
}

View File

@@ -0,0 +1,36 @@
local imageName(image) =
local parts = std.split(image, '/');
local len = std.length(parts);
if len == 3 then
// registry.com/org/image
parts[2]
else if len == 2 then
// org/image
parts[1]
else if len == 1 then
// image, ie. busybox
parts[0]
else
error 'unknown image format: ' + image;
// withImageRepository is a mixin that replaces all images prefixes by repository. eg.
// quay.io/coreos/addon-resizer -> $repository/addon-resizer
// grafana/grafana -> grafana $repository/grafana
local withImageRepository(repository) = {
local oldRepos = super.values.common.images,
local substituteRepository(image, repository) =
if repository == null then image else repository + '/' + imageName(image),
values+:: {
common+:: {
images:: {
[field]: substituteRepository(oldRepos[field], repository)
for field in std.objectFields(oldRepos)
},
},
},
};
{
withImageRepository:: withImageRepository,
}

View File

@@ -2,9 +2,9 @@
// For more details on usage visit https://github.com/DirectXMan12/k8s-prometheus-adapter#quick-links
{
_config+:: {
prometheusAdapter+:: {
namespace: $._config.namespace,
values+:: {
prometheusAdapter+: {
namespace: $.values.common.namespace,
// Rules for custom-metrics
config+:: {
rules+: [
@@ -78,7 +78,7 @@
},
},
prometheusAdapter+:: {
prometheusAdapter+: {
customMetricsApiService: {
apiVersion: 'apiregistration.k8s.io/v1',
kind: 'APIService',
@@ -88,7 +88,7 @@
spec: {
service: {
name: $.prometheusAdapter.service.metadata.name,
namespace: $._config.prometheusAdapter.namespace,
namespace: $.values.prometheusAdapter.namespace,
},
group: 'custom.metrics.k8s.io',
version: 'v1beta1',
@@ -106,7 +106,7 @@
spec: {
service: {
name: $.prometheusAdapter.service.metadata.name,
namespace: $._config.prometheusAdapter.namespace,
namespace: $.values.prometheusAdapter.namespace,
},
group: 'custom.metrics.k8s.io',
version: 'v1beta2',
@@ -141,7 +141,7 @@
subjects: [{
kind: 'ServiceAccount',
name: $.prometheusAdapter.serviceAccount.metadata.name,
namespace: $._config.prometheusAdapter.namespace,
namespace: $.values.prometheusAdapter.namespace,
}],
},
customMetricsClusterRoleBindingHPA: {

View File

@@ -0,0 +1,139 @@
[
// Drop all kubelet metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'kubelet_(pod_worker_latency_microseconds|pod_start_latency_microseconds|cgroup_manager_latency_microseconds|pod_worker_start_latency_microseconds|pleg_relist_latency_microseconds|pleg_relist_interval_microseconds|runtime_operations|runtime_operations_latency_microseconds|runtime_operations_errors|eviction_stats_age_microseconds|device_plugin_registration_count|device_plugin_alloc_latency_microseconds|network_plugin_operations_latency_microseconds)',
action: 'drop',
},
// Drop all scheduler metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'scheduler_(e2e_scheduling_latency_microseconds|scheduling_algorithm_predicate_evaluation|scheduling_algorithm_priority_evaluation|scheduling_algorithm_preemption_evaluation|scheduling_algorithm_latency_microseconds|binding_latency_microseconds|scheduling_latency_seconds)',
action: 'drop',
},
// Drop all apiserver metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'apiserver_(request_count|request_latencies|request_latencies_summary|dropped_requests|storage_data_key_generation_latencies_microseconds|storage_transformation_failures_total|storage_transformation_latencies_microseconds|proxy_tunnel_sync_latency_secs)',
action: 'drop',
},
// Drop all docker metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'kubelet_docker_(operations|operations_latency_microseconds|operations_errors|operations_timeout)',
action: 'drop',
},
// Drop all reflector metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'reflector_(items_per_list|items_per_watch|list_duration_seconds|lists_total|short_watches_total|watch_duration_seconds|watches_total)',
action: 'drop',
},
// Drop all etcd metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'etcd_(helper_cache_hit_count|helper_cache_miss_count|helper_cache_entry_count|object_counts|request_cache_get_latencies_summary|request_cache_add_latencies_summary|request_latencies_summary)',
action: 'drop',
},
// Drop all transformation metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: 'transformation_(transformation_latencies_microseconds|failures_total)',
action: 'drop',
},
// Drop all other metrics which are deprecated in kubernetes.
{
sourceLabels: ['__name__'],
regex: '(' + std.join('|',
[
'admission_quota_controller_adds',
'admission_quota_controller_depth',
'admission_quota_controller_longest_running_processor_microseconds',
'admission_quota_controller_queue_latency',
'admission_quota_controller_unfinished_work_seconds',
'admission_quota_controller_work_duration',
'APIServiceOpenAPIAggregationControllerQueue1_adds',
'APIServiceOpenAPIAggregationControllerQueue1_depth',
'APIServiceOpenAPIAggregationControllerQueue1_longest_running_processor_microseconds',
'APIServiceOpenAPIAggregationControllerQueue1_queue_latency',
'APIServiceOpenAPIAggregationControllerQueue1_retries',
'APIServiceOpenAPIAggregationControllerQueue1_unfinished_work_seconds',
'APIServiceOpenAPIAggregationControllerQueue1_work_duration',
'APIServiceRegistrationController_adds',
'APIServiceRegistrationController_depth',
'APIServiceRegistrationController_longest_running_processor_microseconds',
'APIServiceRegistrationController_queue_latency',
'APIServiceRegistrationController_retries',
'APIServiceRegistrationController_unfinished_work_seconds',
'APIServiceRegistrationController_work_duration',
'autoregister_adds',
'autoregister_depth',
'autoregister_longest_running_processor_microseconds',
'autoregister_queue_latency',
'autoregister_retries',
'autoregister_unfinished_work_seconds',
'autoregister_work_duration',
'AvailableConditionController_adds',
'AvailableConditionController_depth',
'AvailableConditionController_longest_running_processor_microseconds',
'AvailableConditionController_queue_latency',
'AvailableConditionController_retries',
'AvailableConditionController_unfinished_work_seconds',
'AvailableConditionController_work_duration',
'crd_autoregistration_controller_adds',
'crd_autoregistration_controller_depth',
'crd_autoregistration_controller_longest_running_processor_microseconds',
'crd_autoregistration_controller_queue_latency',
'crd_autoregistration_controller_retries',
'crd_autoregistration_controller_unfinished_work_seconds',
'crd_autoregistration_controller_work_duration',
'crdEstablishing_adds',
'crdEstablishing_depth',
'crdEstablishing_longest_running_processor_microseconds',
'crdEstablishing_queue_latency',
'crdEstablishing_retries',
'crdEstablishing_unfinished_work_seconds',
'crdEstablishing_work_duration',
'crd_finalizer_adds',
'crd_finalizer_depth',
'crd_finalizer_longest_running_processor_microseconds',
'crd_finalizer_queue_latency',
'crd_finalizer_retries',
'crd_finalizer_unfinished_work_seconds',
'crd_finalizer_work_duration',
'crd_naming_condition_controller_adds',
'crd_naming_condition_controller_depth',
'crd_naming_condition_controller_longest_running_processor_microseconds',
'crd_naming_condition_controller_queue_latency',
'crd_naming_condition_controller_retries',
'crd_naming_condition_controller_unfinished_work_seconds',
'crd_naming_condition_controller_work_duration',
'crd_openapi_controller_adds',
'crd_openapi_controller_depth',
'crd_openapi_controller_longest_running_processor_microseconds',
'crd_openapi_controller_queue_latency',
'crd_openapi_controller_retries',
'crd_openapi_controller_unfinished_work_seconds',
'crd_openapi_controller_work_duration',
'DiscoveryController_adds',
'DiscoveryController_depth',
'DiscoveryController_longest_running_processor_microseconds',
'DiscoveryController_queue_latency',
'DiscoveryController_retries',
'DiscoveryController_unfinished_work_seconds',
'DiscoveryController_work_duration',
'kubeproxy_sync_proxy_rules_latency_microseconds',
'non_structural_schema_condition_controller_adds',
'non_structural_schema_condition_controller_depth',
'non_structural_schema_condition_controller_longest_running_processor_microseconds',
'non_structural_schema_condition_controller_queue_latency',
'non_structural_schema_condition_controller_retries',
'non_structural_schema_condition_controller_unfinished_work_seconds',
'non_structural_schema_condition_controller_work_duration',
'rest_client_request_latency_seconds',
'storage_operation_errors_total',
'storage_operation_status_count',
]) + ')',
action: 'drop',
},
]

View File

@@ -2,9 +2,9 @@
// For more details on usage visit https://github.com/DirectXMan12/k8s-prometheus-adapter#quick-links
{
_config+:: {
prometheusAdapter+:: {
namespace: $._config.namespace,
values+:: {
prometheusAdapter+: {
namespace: $.values.common.namespace,
// Rules for external-metrics
config+:: {
externalRules+: [
@@ -24,7 +24,7 @@
},
},
prometheusAdapter+:: {
prometheusAdapter+: {
externalMetricsApiService: {
apiVersion: 'apiregistration.k8s.io/v1',
kind: 'APIService',
@@ -34,7 +34,7 @@
spec: {
service: {
name: $.prometheusAdapter.service.metadata.name,
namespace: $._config.prometheusAdapter.namespace,
namespace: $.values.prometheusAdapter.namespace,
},
group: 'external.metrics.k8s.io',
version: 'v1beta1',
@@ -70,7 +70,7 @@
subjects: [{
kind: 'ServiceAccount',
name: $.prometheusAdapter.serviceAccount.metadata.name,
namespace: $._config.prometheusAdapter.namespace,
namespace: $.values.prometheusAdapter.namespace,
}],
},
externalMetricsClusterRoleBindingHPA: {

View File

@@ -1,5 +1,5 @@
{
prometheus+:: {
prometheus+: {
serviceMonitorKubelet+:
{
spec+: {

View File

@@ -1,14 +1,15 @@
{
_config+:: {
versions+:: { clusterVerticalAutoscaler: '0.8.1' },
imageRepos+:: { clusterVerticalAutoscaler: 'gcr.io/google_containers/cpvpa-amd64' },
kubeStateMetrics+:: {
values+:: {
clusterVerticalAutoscaler: {
version: '0.8.1',
image: 'gcr.io/google_containers/cpvpa-amd64:v0.8.1',
baseCPU: '1m',
stepCPU: '1m',
baseMemory: '1Mi',
stepMemory: '2Mi',
},
},
ksmAutoscaler+:: {
ksmAutoscaler+: {
clusterRole: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'ClusterRole',
@@ -29,7 +30,7 @@
kind: 'ClusterRole',
name: 'ksm-autoscaler',
},
subjects: [{ kind: 'ServiceAccount', name: 'ksm-autoscaler', namespace: $._config.namespace }],
subjects: [{ kind: 'ServiceAccount', name: 'ksm-autoscaler', namespace: $.values.common.namespace }],
},
roleBinding: {
@@ -37,7 +38,7 @@
kind: 'RoleBinding',
metadata: {
name: 'ksm-autoscaler',
namespace: $._config.namespace,
namespace: $.values.common.namespace,
},
roleRef: {
apiGroup: 'rbac.authorization.k8s.io',
@@ -52,7 +53,7 @@
kind: 'Role',
metadata: {
name: 'ksm-autoscaler',
namespace: $._config.namespace,
namespace: $.values.common.namespace,
},
rules: [
{
@@ -75,7 +76,7 @@
kind: 'ServiceAccount',
metadata: {
name: 'ksm-autoscaler',
namespace: $._config.namespace,
namespace: $.values.common.namespace,
},
},
@@ -83,14 +84,21 @@
local podLabels = { app: 'ksm-autoscaler' };
local c = {
name: 'ksm-autoscaler',
image: $._config.imageRepos.clusterVerticalAutoscaler + ':v' + $._config.versions.clusterVerticalAutoscaler,
image: $.values.clusterVerticalAutoscaler.image,
args: [
'/cpvpa',
'--target=deployment/kube-state-metrics',
'--namespace=' + $._config.namespace,
'--namespace=' + $.values.common.namespace,
'--logtostderr=true',
'--poll-period-seconds=10',
'--default-config={"kube-state-metrics":{"requests":{"cpu":{"base":"' + $._config.kubeStateMetrics.baseCPU + '","step":"' + $._config.kubeStateMetrics.stepCPU + '","nodesPerStep":1},"memory":{"base":"' + $._config.kubeStateMetrics.baseMemory + '","step":"' + $._config.kubeStateMetrics.stepMemory + '","nodesPerStep":1}},"limits":{"cpu":{"base":"' + $._config.kubeStateMetrics.baseCPU + '","step":"' + $._config.kubeStateMetrics.stepCPU + '","nodesPerStep":1},"memory":{"base":"' + $._config.kubeStateMetrics.baseMemory + '","step":"' + $._config.kubeStateMetrics.stepMemory + '","nodesPerStep":1}}}}',
'--default-config={"kube-state-metrics":{"requests":{"cpu":{"base":"' + $.values.clusterVerticalAutoscaler.baseCPU +
'","step":"' + $.values.clusterVerticalAutoscaler.stepCPU +
'","nodesPerStep":1},"memory":{"base":"' + $.values.clusterVerticalAutoscaler.baseMemory +
'","step":"' + $.values.clusterVerticalAutoscaler.stepMemory +
'","nodesPerStep":1}},"limits":{"cpu":{"base":"' + $.values.clusterVerticalAutoscaler.baseCPU +
'","step":"' + $.values.clusterVerticalAutoscaler.stepCPU +
'","nodesPerStep":1},"memory":{"base":"' + $.values.clusterVerticalAutoscaler.baseMemory +
'","step":"' + $.values.clusterVerticalAutoscaler.stepMemory + '","nodesPerStep":1}}}}',
],
resources: {
requests: { cpu: '20m', memory: '10Mi' },
@@ -102,7 +110,7 @@
kind: 'Deployment',
metadata: {
name: 'ksm-autoscaler',
namespace: $._config.namespace,
namespace: $.values.common.namespace,
labels: podLabels,
},
spec: {

View File

@@ -0,0 +1,39 @@
local addArgs(args, name, containers) = std.map(
function(c) if c.name == name then
c {
args+: args,
}
else c,
containers,
);
{
kubeStateMetrics+: {
deployment+: {
spec+: {
template+: {
spec+: {
containers: addArgs(
[|||
--metric-denylist=
kube_.+_created,
kube_.+_metadata_resource_version,
kube_replicaset_metadata_generation,
kube_replicaset_status_observed_generation,
kube_pod_restart_policy,
kube_pod_init_container_status_terminated,
kube_pod_init_container_status_running,
kube_pod_container_status_terminated,
kube_pod_container_status_running,
kube_pod_completion_time,
kube_pod_status_scheduled
|||],
'kube-state-metrics',
super.containers
),
},
},
},
},
},
}

View File

@@ -0,0 +1,20 @@
// On managed Kubernetes clusters some of the control plane components are not exposed to customers.
// Disable scrape jobs, service monitors, and alert groups for these components by overwriting 'main.libsonnet' defaults
{
kubernetesControlPlane+: {
serviceMonitorKubeControllerManager:: null,
serviceMonitorKubeScheduler:: null,
} + {
prometheusRule+: {
spec+: {
local g = super.groups,
groups: [
h
for h in g
if !std.setMember(h.name, ['kubernetes-system-controller-manager', 'kubernetes-system-scheduler'])
],
},
},
},
}

View File

@@ -0,0 +1,264 @@
local restrictedPodSecurityPolicy = {
apiVersion: 'policy/v1beta1',
kind: 'PodSecurityPolicy',
metadata: {
name: 'kube-prometheus-restricted',
},
spec: {
privileged: false,
// Required to prevent escalations to root.
allowPrivilegeEscalation: false,
// This is redundant with non-root + disallow privilege escalation,
// but we can provide it for defense in depth.
requiredDropCapabilities: ['ALL'],
// Allow core volume types.
volumes: [
'configMap',
'emptyDir',
'secret',
// Assume that persistentVolumes set up by the cluster admin are safe to use.
'persistentVolumeClaim',
],
hostNetwork: false,
hostIPC: false,
hostPID: false,
runAsUser: {
// Require the container to run without root privileges.
rule: 'MustRunAsNonRoot',
},
seLinux: {
// This policy assumes the nodes are using AppArmor rather than SELinux.
rule: 'RunAsAny',
},
supplementalGroups: {
rule: 'MustRunAs',
ranges: [{
// Forbid adding the root group.
min: 1,
max: 65535,
}],
},
fsGroup: {
rule: 'MustRunAs',
ranges: [{
// Forbid adding the root group.
min: 1,
max: 65535,
}],
},
readOnlyRootFilesystem: false,
},
};
{
restrictedPodSecurityPolicy: restrictedPodSecurityPolicy,
alertmanager+: {
role: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'Role',
metadata: {
name: 'alertmanager-' + $.values.alertmanager.name,
namespace: $.values.common.namespace,
},
rules: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: [restrictedPodSecurityPolicy.metadata.name],
}],
},
roleBinding: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'RoleBinding',
metadata: {
name: 'alertmanager-' + $.values.alertmanager.name,
namespace: $.values.common.namespace,
},
roleRef: {
apiGroup: 'rbac.authorization.k8s.io',
kind: 'Role',
name: 'alertmanager-' + $.values.alertmanager.name,
},
subjects: [{
kind: 'ServiceAccount',
name: 'alertmanager-' + $.values.alertmanager.name,
namespace: $.values.alertmanager.namespace,
}],
},
},
blackboxExporter+: {
clusterRole+: {
rules+: [
{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: ['blackbox-exporter-psp'],
},
],
},
podSecurityPolicy:
local blackboxExporterPspPrivileged =
if $.blackboxExporter._config.privileged then
{
metadata+: {
name: 'blackbox-exporter-psp',
},
spec+: {
privileged: true,
allowedCapabilities: ['NET_RAW'],
runAsUser: {
rule: 'RunAsAny',
},
},
}
else
{
metadata+: {
name: 'blackbox-exporter-psp',
},
};
restrictedPodSecurityPolicy + blackboxExporterPspPrivileged,
},
grafana+: {
role: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'Role',
metadata: {
name: 'grafana',
namespace: $.values.common.namespace,
},
rules: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: [restrictedPodSecurityPolicy.metadata.name],
}],
},
roleBinding: {
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'RoleBinding',
metadata: {
name: 'grafana',
namespace: $.values.common.namespace,
},
roleRef: {
apiGroup: 'rbac.authorization.k8s.io',
kind: 'Role',
name: 'grafana',
},
subjects: [{
kind: 'ServiceAccount',
name: $.grafana.serviceAccount.metadata.name,
namespace: $.grafana.serviceAccount.metadata.namespace,
}],
},
},
kubeStateMetrics+: {
clusterRole+: {
rules+: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: ['kube-state-metrics-psp'],
}],
},
podSecurityPolicy: restrictedPodSecurityPolicy {
metadata+: {
name: 'kube-state-metrics-psp',
},
spec+: {
runAsUser: {
rule: 'RunAsAny',
},
},
},
},
nodeExporter+: {
clusterRole+: {
rules+: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: ['node-exporter-psp'],
}],
},
podSecurityPolicy: restrictedPodSecurityPolicy {
metadata+: {
name: 'node-exporter-psp',
},
spec+: {
allowedHostPaths+: [
{
pathPrefix: '/proc',
readOnly: true,
},
{
pathPrefix: '/sys',
readOnly: true,
},
{
pathPrefix: '/',
readOnly: true,
},
],
hostNetwork: true,
hostPID: true,
hostPorts: [
{
max: $.nodeExporter._config.port,
min: $.nodeExporter._config.port,
},
],
readOnlyRootFilesystem: true,
volumes+: [
'hostPath',
],
},
},
},
prometheusAdapter+: {
clusterRole+: {
rules+: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: [restrictedPodSecurityPolicy.metadata.name],
}],
},
},
prometheusOperator+: {
clusterRole+: {
rules+: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: [restrictedPodSecurityPolicy.metadata.name],
}],
},
},
prometheus+: {
clusterRole+: {
rules+: [{
apiGroups: ['policy'],
resources: ['podsecuritypolicies'],
verbs: ['use'],
resourceNames: [restrictedPodSecurityPolicy.metadata.name],
}],
},
},
}

View File

@@ -1,5 +1,5 @@
(import 'github.com/etcd-io/etcd/Documentation/etcd-mixin/mixin.libsonnet') + {
_config+:: {
(import 'github.com/etcd-io/etcd/contrib/mixin/mixin.libsonnet') + {
values+:: {
etcd: {
ips: [],
clientCA: null,
@@ -9,14 +9,14 @@
insecureSkipVerify: null,
},
},
prometheus+:: {
prometheus+: {
serviceEtcd: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: 'etcd',
namespace: 'kube-system',
labels: { 'k8s-app': 'etcd' },
labels: { 'app.kubernetes.io/name': 'etcd' },
},
spec: {
ports: [
@@ -31,12 +31,12 @@
metadata: {
name: 'etcd',
namespace: 'kube-system',
labels: { 'k8s-app': 'etcd' },
labels: { 'app.kubernetes.io/name': 'etcd' },
},
subsets: [{
addresses: [
{ ip: etcdIP }
for etcdIP in $._config.etcd.ips
for etcdIP in $.values.etcd.ips
],
ports: [
{ name: 'metrics', port: 2379, protocol: 'TCP' },
@@ -50,11 +50,11 @@
name: 'etcd',
namespace: 'kube-system',
labels: {
'k8s-app': 'etcd',
'app.kubernetes.io/name': 'etcd',
},
},
spec: {
jobLabel: 'k8s-app',
jobLabel: 'app.kubernetes.io/name',
endpoints: [
{
port: 'metrics',
@@ -65,14 +65,14 @@
caFile: '/etc/prometheus/secrets/kube-etcd-client-certs/etcd-client-ca.crt',
keyFile: '/etc/prometheus/secrets/kube-etcd-client-certs/etcd-client.key',
certFile: '/etc/prometheus/secrets/kube-etcd-client-certs/etcd-client.crt',
[if $._config.etcd.serverName != null then 'serverName']: $._config.etcd.serverName,
[if $._config.etcd.insecureSkipVerify != null then 'insecureSkipVerify']: $._config.etcd.insecureSkipVerify,
[if $.values.etcd.serverName != null then 'serverName']: $.values.etcd.serverName,
[if $.values.etcd.insecureSkipVerify != null then 'insecureSkipVerify']: $.values.etcd.insecureSkipVerify,
},
},
],
selector: {
matchLabels: {
'k8s-app': 'etcd',
'app.kubernetes.io/name': 'etcd',
},
},
},
@@ -84,12 +84,12 @@
type: 'Opaque',
metadata: {
name: 'kube-etcd-client-certs',
namespace: $._config.namespace,
namespace: $.values.common.namespace,
},
data: {
'etcd-client-ca.crt': std.base64($._config.etcd.clientCA),
'etcd-client.key': std.base64($._config.etcd.clientKey),
'etcd-client.crt': std.base64($._config.etcd.clientCert),
'etcd-client-ca.crt': std.base64($.values.etcd.clientCA),
'etcd-client.key': std.base64($.values.etcd.clientKey),
'etcd-client.crt': std.base64($.values.etcd.clientCert),
},
},
prometheus+: {

View File

@@ -0,0 +1,48 @@
// Strips spec.containers[].limits for certain containers
// https://github.com/prometheus-operator/kube-prometheus/issues/72
{
local noLimit(c) =
//if std.objectHas(c, 'resources') && c.name != 'kube-state-metrics'
if c.name != 'kube-state-metrics'
then c { resources+: { limits: {} } }
else c,
nodeExporter+: {
daemonset+: {
spec+: {
template+: {
spec+: {
containers: std.map(noLimit, super.containers),
},
},
},
},
},
kubeStateMetrics+: {
deployment+: {
spec+: {
template+: {
spec+: {
containers: std.map(noLimit, super.containers),
},
},
},
},
},
prometheusOperator+: {
deployment+: {
spec+: {
template+: {
spec+: {
local addArgs(c) =
if c.name == 'prometheus-operator'
then c { args+: ['--config-reloader-cpu-limit=0', '--config-reloader-memory-limit=0'] }
else c,
containers: std.map(addArgs, super.containers),
},
},
},
},
},
}

View File

@@ -0,0 +1,134 @@
[
{
alert: 'WeaveNetIPAMSplitBrain',
expr: 'max(weave_ipam_unreachable_percentage) - min(weave_ipam_unreachable_percentage) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'Percentage of all IP addresses owned by unreachable peers is not same for every node.',
description: 'actionable: Weave Net network has a split brain problem. Please find the problem and fix it.',
},
},
{
alert: 'WeaveNetIPAMUnreachable',
expr: 'weave_ipam_unreachable_percentage > 25',
'for': '10m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'Percentage of all IP addresses owned by unreachable peers is above threshold.',
description: 'actionable: Please find the problem and fix it.',
},
},
{
alert: 'WeaveNetIPAMPendingAllocates',
expr: 'sum(weave_ipam_pending_allocates) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'Number of pending allocates is above the threshold.',
description: 'actionable: Please find the problem and fix it.',
},
},
{
alert: 'WeaveNetIPAMPendingClaims',
expr: 'sum(weave_ipam_pending_claims) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'Number of pending claims is above the threshold.',
description: 'actionable: Please find the problem and fix it.',
},
},
{
alert: 'WeaveNetFastDPFlowsLow',
expr: 'sum(weave_flows) < 15000',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'Number of FastDP flows is below the threshold.',
description: 'actionable: Please find the reason for FastDP flows to go below the threshold and fix it.',
},
},
{
alert: 'WeaveNetFastDPFlowsOff',
expr: 'sum(weave_flows == bool 0) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'FastDP flows is zero.',
description: 'actionable: Please find the reason for FastDP flows to be off and fix it.',
},
},
{
alert: 'WeaveNetHighConnectionTerminationRate',
expr: 'rate(weave_connection_terminations_total[5m]) > 0.1',
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'A lot of connections are getting terminated.',
description: 'actionable: Please find the reason for the high connection termination rate and fix it.',
},
},
{
alert: 'WeaveNetConnectionsConnecting',
expr: 'sum(weave_connections{state="connecting"}) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'A lot of connections are in connecting state.',
description: 'actionable: Please find the reason for this and fix it.',
},
},
{
alert: 'WeaveNetConnectionsRetying',
expr: 'sum(weave_connections{state="retrying"}) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'A lot of connections are in retrying state.',
description: 'actionable: Please find the reason for this and fix it.',
},
},
{
alert: 'WeaveNetConnectionsPending',
expr: 'sum(weave_connections{state="pending"}) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'A lot of connections are in pending state.',
description: 'actionable: Please find the reason for this and fix it.',
},
},
{
alert: 'WeaveNetConnectionsFailed',
expr: 'sum(weave_connections{state="failed"}) > 0',
'for': '3m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'A lot of connections are in failed state.',
description: 'actionable: Please find the reason and fix it.',
},
},
]

View File

@@ -0,0 +1,73 @@
{
prometheus+: {
local p = self,
serviceWeaveNet: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: 'weave-net',
namespace: 'kube-system',
labels: { 'app.kubernetes.io/name': 'weave-net' },
},
spec: {
ports: [
{ name: 'weave-net-metrics', targetPort: 6782, port: 6782 },
],
selector: { name: 'weave-net' },
clusterIP: 'None',
},
},
serviceMonitorWeaveNet: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata: {
name: 'weave-net',
labels: {
'app.kubernetes.io/name': 'weave-net',
},
namespace: 'monitoring',
},
spec: {
jobLabel: 'app.kubernetes.io/name',
endpoints: [
{
port: 'weave-net-metrics',
path: '/metrics',
interval: '15s',
},
],
namespaceSelector: {
matchNames: [
'kube-system',
],
},
selector: {
matchLabels: {
'app.kubernetes.io/name': 'weave-net',
},
},
},
},
prometheusRuleWeaveNet: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
labels: p._config.mixin.ruleLabels,
name: 'weave-net-rules',
namespace: p._config.namespace,
},
spec: {
groups: [{
name: 'weave-net',
rules: (import './alerts.libsonnet'),
}],
},
},
mixin+:: {
grafanaDashboards+:: {
'weave-net.json': (import './grafana-weave-net.json'),
'weave-net-cluster.json': (import './grafana-weave-net-cluster.json'),
},
},
},
}

View File

@@ -0,0 +1,70 @@
local windowsdashboards = import 'github.com/kubernetes-monitoring/kubernetes-mixin/dashboards/windows.libsonnet';
local windowsrules = import 'github.com/kubernetes-monitoring/kubernetes-mixin/rules/windows.libsonnet';
{
values+:: {
// This needs to follow prometheus naming convention and not prometheus-operator one
windowsScrapeConfig+:: {
job_name: 'windows-exporter',
static_configs: [
{
targets: [error 'must provide targets array'],
},
],
relabel_configs: [
{
action: 'replace',
regex: '(.*)',
replacement: '$1',
source_labels: [
'__meta_kubernetes_endpoint_address_target_name',
],
target_label: 'instance',
},
],
},
grafana+:: {
dashboards+:: windowsdashboards {
_config: $.kubernetesControlPlane.mixin._config {
wmiExporterSelector: 'job="' + $.values.windowsScrapeConfig.job_name + '"',
},
}.grafanaDashboards,
},
},
kubernetesControlPlane+: {
mixin+:: {
prometheusRules+:: {
groups+: windowsrules {
_config: $.kubernetesControlPlane.mixin._config {
wmiExporterSelector: 'job="' + $.values.windowsScrapeConfig.job_name + '"',
},
}.prometheusRules.groups,
},
},
},
prometheus+: {
local p = self,
local sc = [$.values.windowsScrapeConfig],
prometheus+: {
spec+: {
additionalScrapeConfigs: {
name: 'prometheus-' + p._config.name + '-additional-scrape-config',
key: 'prometheus-additional.yaml',
},
},
},
windowsConfig: {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
name: 'prometheus-' + p._config.name + '-additional-scrape-config',
namespace: p._config.namespace,
},
stringData: {
'prometheus-additional.yaml': std.manifestYamlDoc(sc),
},
},
},
}

View File

@@ -1,147 +0,0 @@
{
_config+:: {
namespace: 'default',
versions+:: {
alertmanager: 'v0.21.0',
},
imageRepos+:: {
alertmanager: 'quay.io/prometheus/alertmanager',
},
alertmanager+:: {
name: 'main',
config: {
global: {
resolve_timeout: '5m',
},
inhibit_rules: [{
source_match: {
severity: 'critical',
},
target_match_re: {
severity: 'warning|info',
},
equal: ['namespace', 'alertname'],
}, {
source_match: {
severity: 'warning',
},
target_match_re: {
severity: 'info',
},
equal: ['namespace', 'alertname'],
}],
route: {
group_by: ['namespace'],
group_wait: '30s',
group_interval: '5m',
repeat_interval: '12h',
receiver: 'Default',
routes: [
{ receiver: 'Watchdog', match: { alertname: 'Watchdog' } },
{ receiver: 'Critical', match: { severity: 'critical' } },
],
},
receivers: [
{ name: 'Default' },
{ name: 'Watchdog' },
{ name: 'Critical' },
],
},
replicas: 3,
},
},
alertmanager+:: {
secret: {
apiVersion: 'v1',
kind: 'Secret',
type: 'Opaque',
metadata: {
name: 'alertmanager-' + $._config.alertmanager.name,
namespace: $._config.namespace,
},
stringData: {
'alertmanager.yaml': if std.type($._config.alertmanager.config) == 'object'
then
std.manifestYamlDoc($._config.alertmanager.config)
else
$._config.alertmanager.config,
},
},
serviceAccount: {
apiVersion: 'v1',
kind: 'ServiceAccount',
metadata: {
name: 'alertmanager-' + $._config.alertmanager.name,
namespace: $._config.namespace,
},
},
service: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: 'alertmanager-' + $._config.alertmanager.name,
namespace: $._config.namespace,
labels: { alertmanager: $._config.alertmanager.name },
},
spec: {
ports: [
{ name: 'web', targetPort: 'web', port: 9093 },
],
selector: { app: 'alertmanager', alertmanager: $._config.alertmanager.name },
sessionAffinity: 'ClientIP',
},
},
serviceMonitor: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata: {
name: 'alertmanager',
namespace: $._config.namespace,
labels: {
'k8s-app': 'alertmanager',
},
},
spec: {
selector: {
matchLabels: {
alertmanager: $._config.alertmanager.name,
},
},
endpoints: [
{ port: 'web', interval: '30s' },
],
},
},
alertmanager: {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'Alertmanager',
metadata: {
name: $._config.alertmanager.name,
namespace: $._config.namespace,
labels: {
alertmanager: $._config.alertmanager.name,
},
},
spec: {
replicas: $._config.alertmanager.replicas,
version: $._config.versions.alertmanager,
image: $._config.imageRepos.alertmanager + ':' + $._config.versions.alertmanager,
nodeSelector: { 'kubernetes.io/os': 'linux' },
serviceAccountName: 'alertmanager-' + $._config.alertmanager.name,
securityContext: {
runAsUser: 1000,
runAsNonRoot: true,
fsGroup: 2000,
},
},
},
},
}

Some files were not shown because too many files have changed in this diff Show More