Commit Graph

30 Commits

Author SHA1 Message Date
Pranshu Srivastava eb80c09755
enhancement: add `livez` endpoint
Add a `livez` endpoint to identify network outages. This helps in
restarting the binary if such as case is observed.

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

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2024-06-25 14:35:16 +05:30
pokom b4f032ecfd Add additional flags for IdleTimeouts 2024-06-06 13:11:00 -04:00
pokom e97933bcb9 fix(server): Add read and write timeouts
There are a few documented scenarios where `kube-state-metrics` will
lock up(#995, #1028). I believe a much simpler solution to ensure
`kube-state-metrics` doesn't lock up and require a restart to server
`/metrics` requests is to add default read and write timeouts and to
allow them to be configurable. At Grafana, we've experienced a few
scenarios where `kube-state-metrics` running in larger clusters falls
behind and starts getting scraped multiple times. When this occurs,
`kube-state-metrics` becomes completely unresponsive and requires a
reboot. This is somewhat easily reproduceable(I'll provide a script in
an issue) and causes other critical workloads(KEDA, VPA) to fail in
weird ways.

Adds two flags:
- `server-read-timeout`
- `server-write-timeout`

Updates the metrics http server to set the `ReadTimeout` and
`WriteTimeout` to the configured values.
2024-06-05 14:18:43 -04:00
Manuel Rüger fd2a1f83f3 chore: Build with go 1.22 2024-04-05 00:20:04 +02:00
Manuel Rüger 768a0a4338 chore: Bump prometheus/common library 2024-03-28 20:45:36 +01:00
Fabian Heib e4d2bd48c8 Support filtering annotations allowlist by "*"
Resolves: add-wilcard-allowlist-annotations
2023-11-02 17:22:02 +01:00
Pranshu Srivastava 25a1d8da05
Add support for variable VKs in CRS config
Add support for variable VKs in CRS config, while maintaining a cache
of discovered GVKs in the cluster, and updating it every 30s.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2023-05-20 01:26:02 +05:30
Manuel Rüger 1529d94ec8 feat: Use exporter-toolkit landingpage
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-03-17 19:15:05 +01:00
Manuel Rüger cef8c1fa4c feat!: Remove VerticalPodAutoscaler
BREAKING CHANGE: VPA is now supported only via Custom Resource Metrics

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-03-16 14:37:44 +01:00
Manuel Rüger fa5346405a Use structured logging 2023-01-27 17:35:26 +01:00
Manuel Rüger b41d5caa46 Enhance UserAgent with more information
Before:
"User-Agent: v2.7.0"

After:
"User-Agent: kube-state-metrics/v2.7.0 (linux/amd64) kubernetes/1cda0bf9"
2023-01-23 14:12:02 +01:00
Manuel Rüger 06268ab5ef Reload CustomResourceState Config File on Change
This change adds hot reloading support for the customresourcestate
config file.

It also resolves a bug in which the customresourcestate config file was
included in the ksm config file, in which it did not get detected.

It also resolves a bug in which customresourcestatemetrics were not
added when set resources were non-default resources.

Fixes: https://github.com/kubernetes/kube-state-metrics/issues/1892
2023-01-09 17:32:09 +01:00
Manuel Rüger eb3bdbcb58 Add metrics for CustomResourceConfig file 2022-12-08 09:39:17 +01:00
Manuel Rüger ee891760b8 Add metrics for config file changes
This uses code pieces from prometheus/alertmanager in https://github.com/prometheus/alertmanager/blob/main/config/coordinator.go#LL56C26-L56C26
licensed under Apache-2.0.

kube_state_metrics_config_hash{type="config", filename="config.yml"} 4.0061079457904e+13
kube_state_metrics_config_last_reload_success_timestamp_seconds{type="config", filename="config.yml"} 1.6697483049487052e+09
kube_state_metrics_config_last_reload_successful{type="config",
filename="config.yml"} 1

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-12-02 15:41:57 +01:00
Pranshu Srivastava 9860f46776
Implement hot-reloading based on config changes
Reload KSM on-the-fly when a change is detected in the configuration.

Meta changes (will squash)
2022-11-16 20:26:12 +05:30
Manuel Rüger d39f1b138b go.mod: Bump exporter-toolkit to 0.8.1
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-11-10 08:00:52 +01:00
Kubernetes Prow Robot c0a03ad6bb
Merge pull request #1813 from bavarianbidi/crd_only_mode
introduce custom-resources-only flag ...
2022-11-08 03:44:20 -08:00
Mario Constanti 53af11625c introduce custom-resources-only flag ...
... to only monitor all known custom-resource configurations instead of
listing each of them explicitly

Signed-off-by: Mario Constanti <mario@constanti.de>
2022-11-07 07:31:41 +01:00
Catherine Fang 43c6073234 Refactoring 2022-11-04 15:07:37 -04:00
Catherine Fang f9d29ba761 Refactoring 2022-11-04 08:44:00 -04:00
Catherine Fang d523f8e0e4 Move merging fieldselectors into app/server.go and replace namespaceFitler with fieldSelectorFilter 2022-11-04 08:44:00 -04:00
Catherine Fang 87a7793c7f Clean 2022-11-04 08:44:00 -04:00
Catherine Fang 2c0c8d2e51 Sharding per node 2022-11-04 08:44:00 -04:00
Kubernetes Prow Robot 0d55500068
Merge pull request #1826 from rexagod/1786
Handle singular labels in allowlist
2022-10-21 09:27:51 -07:00
Manuel Rüger 6b7027ff41 Harden and add gosec linter
Remediate:
G104: Errors unhandled.
G109: Potential Integer overflow made by strconv.Atoi result conversion to int16/32
G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
G304: Potential file inclusion via variable
G601: Implicit memory aliasing in for loop.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-10-20 20:44:46 +02:00
Pranshu Srivastava 052f572ae7
Handle singular labels in allowlist
Handle singular labels in allowlist failing when such a label is
supplied, in order to keep the behaviour in sync with --resources.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2022-09-26 12:17:32 +05:30
Kubernetes Prow Robot 4bb1b38397
Merge pull request #1807 from dmpe/strcuturedlogging_part1
feat(logging): migration to structure logging for main.go, pkg/ & internal/ folders
2022-08-16 00:17:07 -07:00
Manuel Rüger 2f20203c09 Replace pkg/errors with stdlib errors
github.com/pkg/errors is archived and not maintained anymore.
Replace it with stdlib functions.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-08-15 20:25:09 +02:00
dmpe f406c1aa1d feat(logging): migrate to structured logging
Signed-off-by: dmpe <John Malc> <cincenko@outlook.com>
2022-08-13 14:18:56 +02:00
Garrybest 854bc7c36b Reform main function to adapt custom resource registry
Signed-off-by: Garrybest <garrybest@foxmail.com>
2021-12-14 21:31:33 +08:00