Commit Graph

143 Commits

Author SHA1 Message Date
Pranshu Srivastava f8360a8903
Add end-to-end testing to verify hot-reloading
Add end-to-end testing to verify hot-reloading for event-based changes
stemming from the config file. Also,
* sent in a doc fix that was missed
earlier:
https://github.com/kubernetes/kube-state-metrics/pull/1890/files#diff-380eca5a922c0ddbf67f04daefc6823e7ef0e197434d3a826d39c7063cdfa6d6R15,
* updated fsnotify and viper dependencies (v1.6.0 and v1.14.0
  respectively).

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2022-11-16 20:26:22 +05:30
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
Pranshu Srivastava b926fd968e
Incorporate Cobra
s/pflags/cobra/g:
* Use spf13/cobra to handle all flags and sub-commands.
* Remove all spf13/pflag usage, and fallback to the in-build flag
  package if, and when needed.
* Add completion support.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2022-11-10 18:25:12 +05:30
Catherine Fang f9d29ba761 Refactoring 2022-11-04 08:44:00 -04:00
Catherine Fang 87a7793c7f Clean 2022-11-04 08:44:00 -04:00
Catherine Fang 3b50fbcd16 Validate options 2022-11-04 08:44:00 -04: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
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
Noah Perks Sloan d0aa4a3bdd refactor: inline config as a flag
This is more flexible than the env variable, as a configuration can still set an env variable and use substitution in the args. e.g.,

```yaml
args:
 - --custom-resource-state.config
 - $(KSM_CUSTOM_RESOURCE_STATE_CONFIG)
env:
 ...
```
2022-06-01 09:12:48 -05:00
Noah Perks Sloan 4b704fd90e fix: use a flag for the configuration file 2022-05-31 16:11:49 -05:00
Noah Perks Sloan ea795572d8 chore: goimports 2022-05-31 14:28:29 -05:00
Noah Perks Sloan e0e4f14412 feat: enable customresource metrics by configuration
The main use case is just surfacing fields from custom resources without having to write a lot of code for each one.
2022-05-31 14:24:28 -05: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
Julian van den Berkmortel da04a73f68
Add the opt-in metric family filter to expose or not to a metric family from the store (#1574) 2021-12-01 22:08:52 +01:00
Julian van den Berkmortel f78c8eb1c6
Add CompositeFamilyGeneratorFilter struct for combining multiple filters 2021-11-16 17:49:14 +01:00
Julian van den Berkmortel d767e99c98
Add FamilyGeneratorFilter interface and use it for the allow- / denylist 2021-11-16 17:49:13 +01:00
Min Wang fd183115fb
address comments 2021-10-19 11:20:18 -07:00
Min Wang 853ad1028a
adddress comments 2021-10-19 11:20:18 -07:00
Min Wang bde6d151ef
fix linter check 2021-10-19 11:20:18 -07:00
Min Wang c6ec339eea
address comments 2021-10-19 11:20:18 -07:00
Min Wang 77418c7dba
Add namespace denied list 2021-10-19 11:20:17 -07:00
Sylvain Rabot 0e45534441
Merge remote-tracking branch 'origin/master' into annotations 2021-08-19 16:31:20 +02:00
Lan Liang 185687e6ad Change useApiServerCache to useAPIServerCache 2021-08-16 22:16:24 +08:00
Sylvain Rabot 96d08df5d0
Merge remote-tracking branch 'origin/master' into annotations 2021-08-16 08:50:02 +02:00
Lan Liang 3bbd8d5a88 Add arg use-api-server-cache to set resourceVersion=0 for ListWatch 2021-08-13 13:12:36 +08:00
Kubernetes Prow Robot 1d61fc1461
Merge pull request #1499 from fpetkovski/fix-multiwatcher
Replace multiListerWatcher with independent listWatchers per namespace
2021-07-14 05:32:26 -07:00
Manuel Rüger d5dcb84ee7 go.mod: Update and minimize dependencies
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2021-07-13 18:11:26 +02:00
fpetkovski a6eb25e3c6 rename buildStore to buildStores 2021-06-29 13:30:46 +02:00
Sylvain Rabot 65bc62af5c
Add kube_*_annotations metrics
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-04-29 16:04:16 +02:00
Mayank Shah ec2a3ff831 Add support for native TLS
- introduce new flag `tls-config` to pass the path to tls config file

Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
2021-01-25 13:03:05 +05:30
Ben Ye 6a32904d1f add build_info metric for KSM
Signed-off-by: Ben Ye <yb532204897@gmail.com>
2021-01-06 10:50:02 -05:00
Lili Cosic 4093cb34de Adjust klog to klog/v2 2020-10-05 15:29:12 +02:00
Quentin Bisson 7250bc2b5c
Update go module path to k8s.io/kube-state-metrics/v2
Signed-off-by: Quentin Bisson <quentin@giantswarm.io>
2020-09-21 10:58:08 +02:00
Ben Ye 4d8d85f467 use promauto to register metrics
Signed-off-by: Ben Ye <yb532204897@gmail.com>
2020-09-13 19:07:47 -04:00
Lili Cosic 801690bd95 main.go: Add http request metric for kube-state-metrics main /metrics 2020-09-08 15:15:56 +02:00
Joel Whittaker-Smith 908f87b2cd apply boundaries to metrics and allow via flag what labels to include
Signed-off-by: Joel Whittaker-Smith <jdws.dev@gmail.com>
2020-08-26 12:42:30 +02:00
Mathis Raguin 8f78129e66
main: make all contexts child of a root context
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-27 14:44:46 +02:00
Mathis Raguin f323cdb944
main: move context to local scope
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-27 11:35:14 +02:00
Mathis Raguin 8bb033103d
main: fix linting
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-27 11:34:16 +02:00
Mathis Raguin 556ee3a8d6
main: use own context for each group and a timeout
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-27 11:19:50 +02:00
Mathis Raguin 3b6a93a35d
main: error handling in run group 2020-07-24 18:07:15 +02:00
Mathis Raguin e38b7aaefe
main: graceful shutdown
Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-24 17:59:17 +02:00
Mathis Raguin 56ce7ed701
main: move to run groups
The current implementation can be improved by handling Graceful
Shutdowns of the HTTP Servers.

Signed-off-by: Mathis Raguin <mathis@cri.epita.fr>
2020-07-24 17:25:18 +02:00
Alexander-Carpenter 69fe7da267 Rename collector to resource 2020-02-05 19:43:23 -06:00
yeya24 da2dadcd3e remove deprecated metrics
Signed-off-by: yeya24 <yb532204897@gmail.com>

remove deprecated options

Signed-off-by: yeya24 <yb532204897@gmail.com>
2020-02-05 08:48:23 -05:00
Thibault Le Reste cb655340d6 Rename black-/whitelist to allow/deny-list 2020-02-03 17:05:11 +01:00
cedric lamoriniere 369470d6ea builder.WithGenerateStoreFunc() is now mandatory
This commit introduces the fact that build.WithGenerateStoreFunc()
needs to be used for configuring properly the `Builder` (like any other
`With...` method.

* rename: `WithCustomGenerateStoreFunc` to `WithGenerateStoreFunc`.
* remove buildStorFunc defaulting in `NewBuilder()` function
* add `DefaultGenerateStoreFunc()` method in `BuilderInterface`
* update `Builder initialisation` in `main.go`

Signed-off-by: cedric lamoriniere <cedric.lamoriniere@datadoghq.com>
2020-01-08 13:45:05 +01:00
Frederic Branczyk f3d41de450
Add auto detecting of sharding
main_test.go: Add model based test for sharding

In order to ensure a sharded system behaves equal to an unsharded
system, a model based test has been introduced. It scrapes an unsharded
setup and compares its output with the union of a sharded setup
therefore ensuring semantic equality.
2019-08-30 22:45:35 +02:00
Frederic Branczyk 84d61f9a93
Introduce sharding 2019-08-30 13:51:30 +02:00
Tariq Ibrahim 51def15afa
use MustRegister instead of Register 2019-08-29 13:53:10 -07:00