Merge pull request #2184 from opeco17/feat/introduce-markdown-formatter
feat: introduce Markdown linter and formatter
This commit is contained in:
commit
a7cb7f736a
|
|
@ -21,7 +21,8 @@ If the matter is security related, please disclose it privately see https://gith
|
|||
**Anything else we need to know?**:
|
||||
|
||||
**Environment**:
|
||||
- kube-state-metrics version:
|
||||
- Kubernetes version (use `kubectl version`):
|
||||
- Cloud provider or hardware configuration:
|
||||
- Other info:
|
||||
|
||||
* kube-state-metrics version:
|
||||
* Kubernetes version (use `kubectl version`):
|
||||
* Cloud provider or hardware configuration:
|
||||
* Other info:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"globs": [
|
||||
"**/*.md"
|
||||
],
|
||||
// ToDo: Following rules can't be fixed automatically. They should be enabled when fixed.
|
||||
"config": {
|
||||
"MD004": {
|
||||
"style": "asterisk"
|
||||
},
|
||||
"MD013": false, // https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md013---line-length
|
||||
"MD024": false, // https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md024---multiple-headers-with-the-same-content
|
||||
"MD033": false, // https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md033---inline-html
|
||||
"MD036": false, // https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md036---emphasis-used-instead-of-a-header
|
||||
"MD040": false, // https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md040---fenced-code-blocks-should-have-a-language-specified
|
||||
"MD041": false // https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md041---first-line-in-file-should-be-a-top-level-header
|
||||
}
|
||||
}
|
||||
67
CHANGELOG.md
67
CHANGELOG.md
|
|
@ -1,24 +1,25 @@
|
|||
## v2.10.0 / 2023-08-31
|
||||
|
||||
### Note
|
||||
- Label and annotation metrics aren't exposed by default anymore to reduce the memory usage of the default configuration of kube-state-metrics. Before this change, they used to only include the name and namespace of the objects which is not relevant to users not opting in these metrics.
|
||||
|
||||
* [BUGFIX] Log no _info suffix in name only once per reading the configuration for custommetrics by @chrischdi in https://github.com/kubernetes/kube-state-metrics/pull/2157
|
||||
* [BUGFIX] Don't crash on non-existent valueFrom path values by @chihshenghuang in https://github.com/kubernetes/kube-state-metrics/pull/2140
|
||||
* [BUGFIX] Index out of range in metrics_store.SanitizeHeaders by @mrueg in https://github.com/kubernetes/kube-state-metrics/pull/2166
|
||||
* [BUGFIX] Always extract the headers but only write it when we have custommetrics by @chrischdi in https://github.com/kubernetes/kube-state-metrics/pull/2154
|
||||
* [BUGFIX] Add filtering for Lease metrics by @ntoofu in https://github.com/kubernetes/kube-state-metrics/pull/2122
|
||||
* [FEATURE] Implement kube_pod_status_initialized_time by @opeco17 in https://github.com/kubernetes/kube-state-metrics/pull/2148
|
||||
* [FEATURE] Disable labels and annotations metrics when metric-annotations-… by @opeco17 in https://github.com/kubernetes/kube-state-metrics/pull/2145
|
||||
* [FEATURE] Add webhooks client config service metrics by @dgrisonnet in https://github.com/kubernetes/kube-state-metrics/pull/2114
|
||||
* [FEATURE] Support kube_persistentvolumeclaim_deletion_timestamp by @maxime1907 in https://github.com/kubernetes/kube-state-metrics/pull/2074
|
||||
* [FEATURE] Support kube_persistentvolume_deletion_timestamp by @maxime1907 in https://github.com/kubernetes/kube-state-metrics/pull/2075
|
||||
* [FEATURE] Adds new metric `kube_pod_service_account` by @swarup-stripe in https://github.com/kubernetes/kube-state-metrics/pull/2096
|
||||
* [FEATURE] Add volumemode to PVC info metric by @machadovilaca in https://github.com/kubernetes/kube-state-metrics/pull/2134
|
||||
* [FEATURE] Enable metric-annotations-allowlist and metric-labels-allowlist for ResourceQuota by @opeco17 in https://github.com/kubernetes/kube-state-metrics/pull/2175
|
||||
* [FEATURE] Allow field KV general matching by @rexagod in https://github.com/kubernetes/kube-state-metrics/pull/2067
|
||||
* [FEATURE] Support hot reload for kubeconfig by @opeco17 in https://github.com/kubernetes/kube-state-metrics/pull/2144
|
||||
* [FEATURE] Add support for endpoint topology routing hints by @MarkSRobinson in https://github.com/kubernetes/kube-state-metrics/pull/2090
|
||||
* Label and annotation metrics aren't exposed by default anymore to reduce the memory usage of the default configuration of kube-state-metrics. Before this change, they used to only include the name and namespace of the objects which is not relevant to users not opting in these metrics.
|
||||
|
||||
* [BUGFIX] Log no _info suffix in name only once per reading the configuration for custommetrics by @chrischdi in <https://github.com/kubernetes/kube-state-metrics/pull/2157>
|
||||
* [BUGFIX] Don't crash on non-existent valueFrom path values by @chihshenghuang in <https://github.com/kubernetes/kube-state-metrics/pull/2140>
|
||||
* [BUGFIX] Index out of range in metrics_store.SanitizeHeaders by @mrueg in <https://github.com/kubernetes/kube-state-metrics/pull/2166>
|
||||
* [BUGFIX] Always extract the headers but only write it when we have custommetrics by @chrischdi in <https://github.com/kubernetes/kube-state-metrics/pull/2154>
|
||||
* [BUGFIX] Add filtering for Lease metrics by @ntoofu in <https://github.com/kubernetes/kube-state-metrics/pull/2122>
|
||||
* [FEATURE] Implement kube_pod_status_initialized_time by @opeco17 in <https://github.com/kubernetes/kube-state-metrics/pull/2148>
|
||||
* [FEATURE] Disable labels and annotations metrics when metric-annotations-… by @opeco17 in <https://github.com/kubernetes/kube-state-metrics/pull/2145>
|
||||
* [FEATURE] Add webhooks client config service metrics by @dgrisonnet in <https://github.com/kubernetes/kube-state-metrics/pull/2114>
|
||||
* [FEATURE] Support kube_persistentvolumeclaim_deletion_timestamp by @maxime1907 in <https://github.com/kubernetes/kube-state-metrics/pull/2074>
|
||||
* [FEATURE] Support kube_persistentvolume_deletion_timestamp by @maxime1907 in <https://github.com/kubernetes/kube-state-metrics/pull/2075>
|
||||
* [FEATURE] Adds new metric `kube_pod_service_account` by @swarup-stripe in <https://github.com/kubernetes/kube-state-metrics/pull/2096>
|
||||
* [FEATURE] Add volumemode to PVC info metric by @machadovilaca in <https://github.com/kubernetes/kube-state-metrics/pull/2134>
|
||||
* [FEATURE] Enable metric-annotations-allowlist and metric-labels-allowlist for ResourceQuota by @opeco17 in <https://github.com/kubernetes/kube-state-metrics/pull/2175>
|
||||
* [FEATURE] Allow field KV general matching by @rexagod in <https://github.com/kubernetes/kube-state-metrics/pull/2067>
|
||||
* [FEATURE] Support hot reload for kubeconfig by @opeco17 in <https://github.com/kubernetes/kube-state-metrics/pull/2144>
|
||||
* [FEATURE] Add support for endpoint topology routing hints by @MarkSRobinson in <https://github.com/kubernetes/kube-state-metrics/pull/2090>
|
||||
|
||||
## v2.9.2 / 2023-05-30
|
||||
|
||||
|
|
@ -34,8 +35,8 @@ The changes mentioned below are only the user-facing ones. For a list of the com
|
|||
|
||||
### Note
|
||||
|
||||
- The deprecated experimental VerticalPodAutoscaler metrics are no longer supported, and have been removed. We recommend to use CustomResourceState metrics to gather metrics from custom resources like the Vertical Pod Autoscaler.
|
||||
- #2004 regulated label names to adhere with [OTel-Prometheus standards](https://github.com/open-telemetry/opentelemetry-specification/blob/8946dfc6a2302f78b0224fcc3f4dfb816a7bb1f4/specification/compatibility/prometheus_and_openmetrics.md?plain=1#L224-L229), so existing label names that do not follow the same may be replaced by the ones that do. Please refer to the PR for more details.
|
||||
* The deprecated experimental VerticalPodAutoscaler metrics are no longer supported, and have been removed. We recommend to use CustomResourceState metrics to gather metrics from custom resources like the Vertical Pod Autoscaler.
|
||||
* #2004 regulated label names to adhere with [OTel-Prometheus standards](https://github.com/open-telemetry/opentelemetry-specification/blob/8946dfc6a2302f78b0224fcc3f4dfb816a7bb1f4/specification/compatibility/prometheus_and_openmetrics.md?plain=1#L224-L229), so existing label names that do not follow the same may be replaced by the ones that do. Please refer to the PR for more details.
|
||||
|
||||
* [BUGFIX] Adhere to OTel-Prometheus standard for labels #2004 @rexagod
|
||||
* [BUGFIX] Respect relative paths for label resolutions #2007 @rexagod
|
||||
|
|
@ -118,6 +119,7 @@ See: #1847
|
|||
* [BUGFIX] Allow lease metrics to be exported across all namespaces #1845 @lantingchiang
|
||||
|
||||
## v2.6.0 / 2022-08-26
|
||||
|
||||
* [FEATURE] Add local storage labels to kube_persistentvolume_info #1814 @nabokihms
|
||||
* [FEATURE] Add support for StateSet and Info metrics for Custom-Resource State #1777 @chrischdi
|
||||
* [FEATURE] Add support for Rolebinding resource metrics #1799 @kaitoii11
|
||||
|
|
@ -151,9 +153,11 @@ See: #1847
|
|||
* [BUGFIX] Properly initialize KSM Server test #1699 @fpetkovski
|
||||
|
||||
## v2.4.2 / 2022-02-10
|
||||
|
||||
* [BUGFIX] Publish images with with the correct tag
|
||||
|
||||
## v2.4.1 / 2022-02-10
|
||||
|
||||
* [FEATURE] Add `ingressclass` label to `kube_ingress_info` metric #1652 @adammw
|
||||
* [FEATURE] Extend KSM library to support custom resource metrics #1644 @Garrybest
|
||||
* [ENHANCEMENT] Use apiVersion `v1` for `PodDisruptionBudget` and `CronJob` resources #1491 @bison
|
||||
|
|
@ -181,6 +185,7 @@ See: #1847
|
|||
* [BUGFIX] Fix the image build job. Reverts #1602
|
||||
|
||||
## v2.2.2 / 2021-10-13
|
||||
|
||||
* [BUGFIX] Downgrade latest allowed go version to 1.16.9 #1601 @mrueg
|
||||
* [BUGFIX] Fix CI variable names used for building KSM images @mrueg
|
||||
|
||||
|
|
@ -254,6 +259,7 @@ Location on quay.io will not be updated anymore. Previously pushed images will b
|
|||
* [BUGFIX] Propagate resource version when sharded #1402
|
||||
|
||||
## v2.0.0-beta / 2020-12-04
|
||||
|
||||
Promotion to beta release after a period of no bugs.
|
||||
|
||||
## v2.0.0-alpha.3 / 2020-11-19
|
||||
|
|
@ -301,18 +307,18 @@ Metrics kube_pod_container_resource_requests, kube_pod_container_resource_limits
|
|||
Note that some of these were replaced with EXPERIMENTAL resource metrics. See #1168 for more details.
|
||||
`kube_pod_container_resource_requests` and `kube_pod_container_resource_limits` are the replacements with `resource` labels
|
||||
representing the resource name and `unit` labels representing the resource unit.
|
||||
- kube_pod_container_resource_requests_cpu_cores
|
||||
- kube_pod_container_resource_limits_cpu_cores
|
||||
- kube_pod_container_resource_requests_memory_bytes
|
||||
- kube_pod_container_resource_limits_memory_bytes
|
||||
- `kube_node_status_capacity` and `kube_node_status_allocatable` are the replacements with `resource` labels
|
||||
* kube_pod_container_resource_requests_cpu_cores
|
||||
* kube_pod_container_resource_limits_cpu_cores
|
||||
* kube_pod_container_resource_requests_memory_bytes
|
||||
* kube_pod_container_resource_limits_memory_bytes
|
||||
* `kube_node_status_capacity` and `kube_node_status_allocatable` are the replacements with `resource` labels
|
||||
representing the resource name and `unit` labels representing the resource unit.
|
||||
- kube_node_status_capacity_pods
|
||||
- kube_node_status_capacity_cpu_cores
|
||||
- kube_node_status_capacity_memory_bytes
|
||||
- kube_node_status_allocatable_pods
|
||||
- kube_node_status_allocatable_cpu_cores
|
||||
- kube_node_status_allocatable_memory_bytes
|
||||
* kube_node_status_capacity_pods
|
||||
* kube_node_status_capacity_cpu_cores
|
||||
* kube_node_status_capacity_memory_bytes
|
||||
* kube_node_status_allocatable_pods
|
||||
* kube_node_status_allocatable_cpu_cores
|
||||
* kube_node_status_allocatable_memory_bytes
|
||||
* [CHANGE] Rename black-/whitelist to allow/deny-list #1045
|
||||
New flags are --metric-allowlist and --metric-denylist
|
||||
* [CHANGE] Update telemetry port to 8081 #1049
|
||||
|
|
@ -339,7 +345,6 @@ All metrics with prefix of kube_hpa_ were renamed to kube_horizontalpodautoscale
|
|||
* [BUGFIX] Fix various CI issues (kube_volumeattachment_info nodeName -> node label rename) #1117
|
||||
* [BUGFIX] Fix maxUnavailable to round down instead up #1076
|
||||
|
||||
|
||||
## v1.9.7 / 2020-05-24
|
||||
|
||||
* [BUGFIX] internal/store/mutatingwebhookconfiguration.go: Switch to v1 #1144
|
||||
|
|
|
|||
|
|
@ -38,18 +38,17 @@ Here's a list of types that we use:
|
|||
| chore | Other changes that don't modify src or test files |
|
||||
| revert | Reverts a previous commit |
|
||||
|
||||
|
||||
### Further Information
|
||||
|
||||
- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests
|
||||
- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing)
|
||||
- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet/README.md) - Common resources for existing developers
|
||||
* [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests
|
||||
* [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing)
|
||||
* [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet/README.md) - Common resources for existing developers
|
||||
|
||||
## Mentorship
|
||||
|
||||
- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!
|
||||
* [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!
|
||||
|
||||
## Contact Information
|
||||
|
||||
- [Join Slack](http://slack.k8s.io) to sign up and join the Kubernetes Slack. Please make sure to read our [Slack Guidelines](https://github.com/kubernetes/community/blob/master/communication/slack-guidelines.md) before participating.
|
||||
- The [kube-state-metrics slack channel](https://kubernetes.slack.com/messages/CJJ529RUY) provides an effective communication platform to reach out to members and other users of the project. It offers an alternative to submitting a GitHub issue for when you have questions and issues.
|
||||
* [Join Slack](http://slack.k8s.io) to sign up and join the Kubernetes Slack. Please make sure to read our [Slack Guidelines](https://github.com/kubernetes/community/blob/master/communication/slack-guidelines.md) before participating.
|
||||
* The [kube-state-metrics slack channel](https://kubernetes.slack.com/messages/CJJ529RUY) provides an effective communication platform to reach out to members and other users of the project. It offers an alternative to submitting a GitHub issue for when you have questions and issues.
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@ kube-state-metrics is welcoming contributions from the community. If you are int
|
|||
As part of the Kubernetes project, we use the community membership process as described [here](https://github.com/kubernetes/community/blob/master/community-membership.md). We do not adhere strictly to the numbers of contributions and reviews. Still as becoming a maintainer is a trust-based process and we desire positive outcomes for the project, we look for a long-term interest and engagement.
|
||||
|
||||
## Adding a new reviewer
|
||||
|
||||
* Ensure the new reviewer is a member of the [kubernetes organization](https://github.com/kubernetes/org/blob/main/config/kubernetes/org.yaml).
|
||||
* Add the new reviewer to the [OWNERS](OWNERS) file to be able to review pull requests.
|
||||
* Add the new reviewer to the [kube-state-metrics-maintainers group](https://github.com/kubernetes/org/blob/main/config/kubernetes/sig-instrumentation/teams.yaml), to gain write access to the kube-state-metrics repository (e.g. for creating new releases).
|
||||
|
||||
|
||||
## Adding a new approver
|
||||
|
||||
* Ensure the new approver is already a reviewer in the [OWNERS](OWNERS) file.
|
||||
* Add the new approver to the [OWNERS](OWNERS) file to be able to approve pull requests.
|
||||
* Add the new approver to the [SECURITY_CONTACTS](SECURITY_CONTACTS) file to be able to get notified on security related incidents.
|
||||
|
|
|
|||
13
Makefile
13
Makefile
|
|
@ -21,6 +21,8 @@ IMAGE = $(REGISTRY)/kube-state-metrics
|
|||
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
|
||||
USER ?= $(shell id -u -n)
|
||||
HOST ?= $(shell hostname)
|
||||
MARKDOWNLINT_CLI2_VERSION = 0.9.2
|
||||
|
||||
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
|
||||
|
|
@ -41,12 +43,13 @@ licensecheck:
|
|||
exit 1; \
|
||||
fi
|
||||
|
||||
lint: shellcheck licensecheck
|
||||
lint: shellcheck licensecheck lint-markdown-format
|
||||
golangci-lint run
|
||||
|
||||
lint-fix:
|
||||
lint-fix: fix-markdown-format
|
||||
golangci-lint run --fix -v
|
||||
|
||||
|
||||
doccheck: generate
|
||||
@echo "- Checking if the generated documentation is up to date..."
|
||||
@git diff --exit-code
|
||||
|
|
@ -78,6 +81,12 @@ test-rules:
|
|||
shellcheck:
|
||||
${DOCKER_CLI} run -v "${PWD}:/mnt" koalaman/shellcheck:stable $(shell find . -type f -name "*.sh" -not -path "*vendor*")
|
||||
|
||||
lint-markdown-format:
|
||||
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --config .markdownlint-cli2.jsonc
|
||||
|
||||
fix-markdown-format:
|
||||
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --fix --config .markdownlint-cli2.jsonc
|
||||
|
||||
# Runs benchmark tests on the current git ref and the last release and compares
|
||||
# the two.
|
||||
test-benchmark-compare:
|
||||
|
|
|
|||
69
README.md
69
README.md
|
|
@ -30,31 +30,31 @@ are deleted they are no longer visible on the `/metrics` endpoint.
|
|||
|
||||
## Table of Contents
|
||||
|
||||
- [Versioning](#versioning)
|
||||
- [Kubernetes Version](#kubernetes-version)
|
||||
- [Compatibility matrix](#compatibility-matrix)
|
||||
- [Resource group version compatibility](#resource-group-version-compatibility)
|
||||
- [Container Image](#container-image)
|
||||
- [Metrics Documentation](#metrics-documentation)
|
||||
- [Conflict resolution in label names](#conflict-resolution-in-label-names)
|
||||
- [Kube-state-metrics self metrics](#kube-state-metrics-self-metrics)
|
||||
- [Resource recommendation](#resource-recommendation)
|
||||
- [Latency](#latency)
|
||||
- [A note on costing](#a-note-on-costing)
|
||||
- [kube-state-metrics vs. metrics-server](#kube-state-metrics-vs-metrics-server)
|
||||
- [Scaling kube-state-metrics](#scaling-kube-state-metrics)
|
||||
- [Resource recommendation](#resource-recommendation)
|
||||
- [Horizontal sharding](#horizontal-sharding)
|
||||
- [Automated sharding](#automated-sharding)
|
||||
- [Daemonset sharding for pod metrics](#daemonset-sharding-for-pod-metrics)
|
||||
- [Setup](#setup)
|
||||
- [Building the Docker container](#building-the-docker-container)
|
||||
- [Usage](#usage)
|
||||
- [Kubernetes Deployment](#kubernetes-deployment)
|
||||
- [Limited privileges environment](#limited-privileges-environment)
|
||||
- [Helm Chart](#helm-chart)
|
||||
- [Development](#development)
|
||||
- [Developer Contributions](#developer-contributions)
|
||||
* [Versioning](#versioning)
|
||||
* [Kubernetes Version](#kubernetes-version)
|
||||
* [Compatibility matrix](#compatibility-matrix)
|
||||
* [Resource group version compatibility](#resource-group-version-compatibility)
|
||||
* [Container Image](#container-image)
|
||||
* [Metrics Documentation](#metrics-documentation)
|
||||
* [Conflict resolution in label names](#conflict-resolution-in-label-names)
|
||||
* [Kube-state-metrics self metrics](#kube-state-metrics-self-metrics)
|
||||
* [Resource recommendation](#resource-recommendation)
|
||||
* [Latency](#latency)
|
||||
* [A note on costing](#a-note-on-costing)
|
||||
* [kube-state-metrics vs. metrics-server](#kube-state-metrics-vs-metrics-server)
|
||||
* [Scaling kube-state-metrics](#scaling-kube-state-metrics)
|
||||
* [Resource recommendation](#resource-recommendation)
|
||||
* [Horizontal sharding](#horizontal-sharding)
|
||||
* [Automated sharding](#automated-sharding)
|
||||
* [Daemonset sharding for pod metrics](#daemonset-sharding-for-pod-metrics)
|
||||
* [Setup](#setup)
|
||||
* [Building the Docker container](#building-the-docker-container)
|
||||
* [Usage](#usage)
|
||||
* [Kubernetes Deployment](#kubernetes-deployment)
|
||||
* [Limited privileges environment](#limited-privileges-environment)
|
||||
* [Helm Chart](#helm-chart)
|
||||
* [Development](#development)
|
||||
* [Developer Contributions](#developer-contributions)
|
||||
|
||||
### Versioning
|
||||
|
||||
|
|
@ -80,7 +80,6 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If
|
|||
| **v2.10.0** | v1.27 |
|
||||
| **main** | v1.28 |
|
||||
|
||||
|
||||
#### Resource group version compatibility
|
||||
|
||||
Resources in Kubernetes can evolve, i.e., the group version for a resource may change from alpha to beta and finally GA
|
||||
|
|
@ -90,6 +89,7 @@ release.
|
|||
#### Container Image
|
||||
|
||||
The latest container image can be found at:
|
||||
|
||||
* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`)
|
||||
* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.10.0)
|
||||
|
||||
|
|
@ -132,6 +132,7 @@ If you encounter those errors in the metrics, it is most likely a configuration
|
|||
at the logs of kube-state-metrics.
|
||||
|
||||
Example of the above mentioned metrics:
|
||||
|
||||
```
|
||||
kube_state_metrics_list_total{resource="*v1.Node",result="success"} 1
|
||||
kube_state_metrics_list_total{resource="*v1.Node",result="error"} 52
|
||||
|
|
@ -139,6 +140,7 @@ kube_state_metrics_watch_total{resource="*v1beta1.Ingress",result="success"} 1
|
|||
```
|
||||
|
||||
kube-state-metrics also exposes some http request metrics, examples of those are:
|
||||
|
||||
```
|
||||
http_request_duration_seconds_bucket{handler="metrics",method="get",le="2.5"} 30
|
||||
http_request_duration_seconds_bucket{handler="metrics",method="get",le="5"} 30
|
||||
|
|
@ -149,6 +151,7 @@ http_request_duration_seconds_count{handler="metrics",method="get"} 30
|
|||
```
|
||||
|
||||
kube-state-metrics also exposes build and configuration metrics:
|
||||
|
||||
```
|
||||
kube_state_metrics_build_info{branch="main",goversion="go1.15.3",revision="6c9d775d",version="v2.0.0-beta"} 1
|
||||
kube_state_metrics_shard_ordinal{shard_ordinal="0"} 0
|
||||
|
|
@ -246,11 +249,13 @@ The downside of using an auto-sharded setup comes from the rollout strategy supp
|
|||
### Daemonset sharding for pod metrics
|
||||
|
||||
For pod metrics, they can be sharded per node with the following flag:
|
||||
|
||||
* `--node`
|
||||
|
||||
Each kube-state-metrics pod uses FieldSelector (spec.nodeName) to watch/list pod metrics only on the same node.
|
||||
|
||||
A daemonset kube-state-metrics example:
|
||||
|
||||
```
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
|
|
@ -285,6 +290,7 @@ go get k8s.io/kube-state-metrics
|
|||
|
||||
Simply run the following command in this root folder, which will create a
|
||||
self-contained, statically-linked binary and build a Docker image:
|
||||
|
||||
```
|
||||
make container
|
||||
```
|
||||
|
|
@ -312,7 +318,7 @@ To have Prometheus discover kube-state-metrics instances it is advised to create
|
|||
kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=$(gcloud info --format='value(config.account)')
|
||||
```
|
||||
|
||||
Note that your GCP identity is case sensitive but `gcloud info` as of Google Cloud SDK 221.0.0 is not. This means that if your IAM member contains capital letters, the above one-liner may not work for you. If you have 403 forbidden responses after running the above command and `kubectl apply -f examples/standard`, check the IAM member associated with your account at https://console.cloud.google.com/iam-admin/iam?project=PROJECT_ID. If it contains capital letters, you may need to set the --user flag in the command above to the case-sensitive role listed at https://console.cloud.google.com/iam-admin/iam?project=PROJECT_ID.
|
||||
Note that your GCP identity is case sensitive but `gcloud info` as of Google Cloud SDK 221.0.0 is not. This means that if your IAM member contains capital letters, the above one-liner may not work for you. If you have 403 forbidden responses after running the above command and `kubectl apply -f examples/standard`, check the IAM member associated with your account at <https://console.cloud.google.com/iam-admin/iam?project=PROJECT_ID>. If it contains capital letters, you may need to set the --user flag in the command above to the case-sensitive role listed at <https://console.cloud.google.com/iam-admin/iam?project=PROJECT_ID>.
|
||||
|
||||
After running the above, if you see `Clusterrolebinding "cluster-admin-binding" created`, then you are able to continue with the setup of this service.
|
||||
|
||||
|
|
@ -320,7 +326,8 @@ After running the above, if you see `Clusterrolebinding "cluster-admin-binding"
|
|||
|
||||
If you want to run kube-state-metrics in an environment where you don't have cluster-reader role, you can:
|
||||
|
||||
- create a serviceaccount
|
||||
* create a serviceaccount
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
|
|
@ -329,7 +336,8 @@ metadata:
|
|||
namespace: your-namespace-where-kube-state-metrics-will-deployed
|
||||
```
|
||||
|
||||
- give it `view` privileges on specific namespaces (using roleBinding) (*note: you can add this roleBinding to all the NS you want your serviceaccount to access*)
|
||||
* give it `view` privileges on specific namespaces (using roleBinding) (*note: you can add this roleBinding to all the NS you want your serviceaccount to access*)
|
||||
|
||||
```yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
|
|
@ -346,7 +354,7 @@ subjects:
|
|||
namespace: your-namespace-where-kube-state-metrics-will-deployed
|
||||
```
|
||||
|
||||
- then specify a set of namespaces (using the `--namespaces` option) and a set of kubernetes objects (using the `--resources`) that your serviceaccount has access to in the `kube-state-metrics` deployment configuration
|
||||
* then specify a set of namespaces (using the `--namespaces` option) and a set of kubernetes objects (using the `--resources`) that your serviceaccount has access to in the `kube-state-metrics` deployment configuration
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
|
|
@ -361,7 +369,6 @@ spec:
|
|||
|
||||
For the full list of arguments available, see the documentation in [docs/cli-arguments.md](./docs/cli-arguments.md)
|
||||
|
||||
|
||||
#### Helm Chart
|
||||
|
||||
Starting from the kube-state-metrics chart `v2.13.3` (kube-state-metrics image `v1.9.8`), the official [Helm chart](https://artifacthub.io/packages/helm/prometheus-community/kube-state-metrics/) is maintained in [prometheus-community/helm-charts](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics). Starting from kube-state-metrics chart `v3.0.0` only kube-state-metrics images of `v2.0.0 +` are supported.
|
||||
|
|
|
|||
|
|
@ -21,12 +21,14 @@ Maintaining the release branches for older minor releases happens on a best effo
|
|||
* Changelog entry
|
||||
* Only include user relevant changes
|
||||
* Entries in the [`CHANGELOG.md`](CHANGELOG.md) are meant to be in this order:
|
||||
|
||||
```
|
||||
[CHANGE]
|
||||
[FEATURE]
|
||||
[ENHANCEMENT]
|
||||
[BUGFIX]
|
||||
```
|
||||
|
||||
* All lines should be full sentences
|
||||
* kube-state-metrics image tag used in Kubernetes deployment yaml config.
|
||||
* Cut the new release branch, e.g. `release-1.2`, or merge/cherry-pick changes onto the minor release branch you intend to tag the release on
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ Any contribution to improving this documentation or adding sample usages will be
|
|||
|
||||
## Table of Contents
|
||||
|
||||
- [Metrics Stages](#metrics-stages)
|
||||
- [Exposed Metrics](#exposed-metrics)
|
||||
- [Join Metrics](#join-metrics)
|
||||
- [CLI arguments](#cli-arguments)
|
||||
* [Metrics Stages](#metrics-stages)
|
||||
* [Exposed Metrics](#exposed-metrics)
|
||||
* [Join Metrics](#join-metrics)
|
||||
* [CLI arguments](#cli-arguments)
|
||||
|
||||
## Metrics Stages
|
||||
|
||||
|
|
@ -32,44 +32,44 @@ See each file for specific documentation about the exposed metrics:
|
|||
|
||||
### Default Resources
|
||||
|
||||
- [CertificateSigningRequest Metrics](certificatesigningrequest-metrics.md)
|
||||
- [ConfigMap Metrics](configmap-metrics.md)
|
||||
- [CronJob Metrics](cronjob-metrics.md)
|
||||
- [DaemonSet Metrics](daemonset-metrics.md)
|
||||
- [Deployment Metrics](deployment-metrics.md)
|
||||
- [Endpoint Metrics](endpoint-metrics.md)
|
||||
- [Horizontal Pod Autoscaler Metrics](horizontalpodautoscaler-metrics.md)
|
||||
- [Ingress Metrics](ingress-metrics.md)
|
||||
- [Job Metrics](job-metrics.md)
|
||||
- [Lease Metrics](lease-metrics.md)
|
||||
- [LimitRange Metrics](limitrange-metrics.md)
|
||||
- [MutatingWebhookConfiguration Metrics](mutatingwebhookconfiguration-metrics.md)
|
||||
- [Namespace Metrics](namespace-metrics.md)
|
||||
- [NetworkPolicy Metrics](networkpolicy-metrics.md)
|
||||
- [Node Metrics](node-metrics.md)
|
||||
- [PersistentVolume Metrics](persistentvolume-metrics.md)
|
||||
- [PersistentVolumeClaim Metrics](persistentvolumeclaim-metrics.md)
|
||||
- [Pod Disruption Budget Metrics](poddisruptionbudget-metrics.md)
|
||||
- [Pod Metrics](pod-metrics.md)
|
||||
- [ReplicaSet Metrics](replicaset-metrics.md)
|
||||
- [ReplicationController Metrics](replicationcontroller-metrics.md)
|
||||
- [ResourceQuota Metrics](resourcequota-metrics.md)
|
||||
- [Secret Metrics](secret-metrics.md)
|
||||
- [Service Metrics](service-metrics.md)
|
||||
- [StatefulSet Metrics](statefulset-metrics.md)
|
||||
- [StorageClass Metrics](storageclass-metrics.md)
|
||||
- [ValidatingWebhookConfiguration Metrics](validatingwebhookconfiguration-metrics.md)
|
||||
- [VolumeAttachment Metrics](volumeattachment-metrics.md)
|
||||
* [CertificateSigningRequest Metrics](certificatesigningrequest-metrics.md)
|
||||
* [ConfigMap Metrics](configmap-metrics.md)
|
||||
* [CronJob Metrics](cronjob-metrics.md)
|
||||
* [DaemonSet Metrics](daemonset-metrics.md)
|
||||
* [Deployment Metrics](deployment-metrics.md)
|
||||
* [Endpoint Metrics](endpoint-metrics.md)
|
||||
* [Horizontal Pod Autoscaler Metrics](horizontalpodautoscaler-metrics.md)
|
||||
* [Ingress Metrics](ingress-metrics.md)
|
||||
* [Job Metrics](job-metrics.md)
|
||||
* [Lease Metrics](lease-metrics.md)
|
||||
* [LimitRange Metrics](limitrange-metrics.md)
|
||||
* [MutatingWebhookConfiguration Metrics](mutatingwebhookconfiguration-metrics.md)
|
||||
* [Namespace Metrics](namespace-metrics.md)
|
||||
* [NetworkPolicy Metrics](networkpolicy-metrics.md)
|
||||
* [Node Metrics](node-metrics.md)
|
||||
* [PersistentVolume Metrics](persistentvolume-metrics.md)
|
||||
* [PersistentVolumeClaim Metrics](persistentvolumeclaim-metrics.md)
|
||||
* [Pod Disruption Budget Metrics](poddisruptionbudget-metrics.md)
|
||||
* [Pod Metrics](pod-metrics.md)
|
||||
* [ReplicaSet Metrics](replicaset-metrics.md)
|
||||
* [ReplicationController Metrics](replicationcontroller-metrics.md)
|
||||
* [ResourceQuota Metrics](resourcequota-metrics.md)
|
||||
* [Secret Metrics](secret-metrics.md)
|
||||
* [Service Metrics](service-metrics.md)
|
||||
* [StatefulSet Metrics](statefulset-metrics.md)
|
||||
* [StorageClass Metrics](storageclass-metrics.md)
|
||||
* [ValidatingWebhookConfiguration Metrics](validatingwebhookconfiguration-metrics.md)
|
||||
* [VolumeAttachment Metrics](volumeattachment-metrics.md)
|
||||
|
||||
### Optional Resources
|
||||
|
||||
- [ClusterRole Metrics](clusterrole-metrics.md)
|
||||
- [ClusterRoleBinding Metrics](clusterrolebinding-metrics.md)
|
||||
- [EndpointSlice Metrics](endpointslice-metrics.md)
|
||||
- [IngressClass Metrics](ingressclass-metrics.md)
|
||||
- [Role Metrics](role-metrics.md)
|
||||
- [RoleBinding Metrics](rolebinding-metrics.md)
|
||||
- [ServiceAccount Metrics](serviceaccount-metrics.md)
|
||||
* [ClusterRole Metrics](clusterrole-metrics.md)
|
||||
* [ClusterRoleBinding Metrics](clusterrolebinding-metrics.md)
|
||||
* [EndpointSlice Metrics](endpointslice-metrics.md)
|
||||
* [IngressClass Metrics](ingressclass-metrics.md)
|
||||
* [Role Metrics](role-metrics.md)
|
||||
* [RoleBinding Metrics](rolebinding-metrics.md)
|
||||
* [ServiceAccount Metrics](serviceaccount-metrics.md)
|
||||
|
||||
## Join Metrics
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@ spec:
|
|||
- '--apiserver=<APISERVER>'
|
||||
```
|
||||
|
||||
## Available options:
|
||||
## Available options
|
||||
|
||||
[embedmd]:# (../help.txt)
|
||||
```txt
|
||||
$ kube-state-metrics -h
|
||||
kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects.
|
||||
|
|
|
|||
|
|
@ -7,4 +7,3 @@
|
|||
| kube_clusterrolebinding_info | Gauge | | `clusterrolebinding`=<clusterrolebinding-name> <br> `roleref_kind`=<role-kind> <br> `roleref_name`=<role-name> | EXPERIMENTAL |
|
||||
| kube_clusterrolebinding_created | Gauge | | `clusterrolebinding`=<clusterrolebinding-name> | EXPERIMENTAL |
|
||||
| kube_clusterrolebinding_metadata_resource_version | Gauge | | `clusterrolebinding`=<clusterrolebinding-name> | EXPERIMENTAL |
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ NOTE: The `customresource_group`, `customresource_version`, and `customresource_
|
|||
|
||||
Please be aware that kube-state-metrics needs list and watch permissions granted to `customresourcedefinitions.apiextensions.k8s.io` as well as to the resources you want to gather metrics from.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
The examples in this section will use the following custom resource:
|
||||
|
|
@ -287,7 +286,6 @@ spec:
|
|||
|
||||
The above configuration was tested on [this](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/examples/hamster.yaml) VPA configuration, with an added annotation (`foo: 123`).
|
||||
|
||||
|
||||
### Metric types
|
||||
|
||||
The configuration supports three kind of metrics from the [OpenMetrics specification](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md).
|
||||
|
|
@ -335,9 +333,9 @@ Supported types are:
|
|||
* for string the following logic applies
|
||||
* `"true"` and `"yes"` are mapped to `1.0` and `"false"` and `"no"` are mapped to `0.0` (all case-insensitive)
|
||||
* RFC3339 times are parsed to float timestamp
|
||||
* Quantities like "250m" or "512Gi" are parsed to float using https://github.com/kubernetes/apimachinery/blob/master/pkg/api/resource/quantity.go
|
||||
* Quantities like "250m" or "512Gi" are parsed to float using <https://github.com/kubernetes/apimachinery/blob/master/pkg/api/resource/quantity.go>
|
||||
* Percentages ending with a "%" are parsed to float
|
||||
* finally the string is parsed to float using https://pkg.go.dev/strconv#ParseFloat which should support all common number formats. If that fails an error is yielded
|
||||
* finally the string is parsed to float using <https://pkg.go.dev/strconv#ParseFloat> which should support all common number formats. If that fails an error is yielded
|
||||
|
||||
##### Example for status conditions on Kubernetes Controllers
|
||||
|
||||
|
|
@ -368,7 +366,7 @@ spec:
|
|||
valueFrom: ["status"]
|
||||
```
|
||||
|
||||
This will work for kubernetes controller CRs which expose status conditions according to the kubernetes api (https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Condition):
|
||||
This will work for kubernetes controller CRs which expose status conditions according to the kubernetes api (<https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Condition>):
|
||||
|
||||
```yaml
|
||||
status:
|
||||
|
|
@ -462,6 +460,7 @@ spec:
|
|||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```prometheus
|
||||
myteam_foos_uptime{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1"} 43.21
|
||||
```
|
||||
|
|
@ -480,6 +479,7 @@ spec:
|
|||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```prometheus
|
||||
uptime{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1"} 43.21
|
||||
```
|
||||
|
|
@ -562,5 +562,5 @@ kube_customresource_myobject_info{customresource_group="myteam.io",customresourc
|
|||
|
||||
#### Note
|
||||
|
||||
- For cases where the GVKs defined in a CRD have multiple versions under a single group for the same kind, as expected, the wildcard value will resolve to *all* versions, but a query for any specific version will return all resources under all versions, in that versions' representation. This basically means that for two such versions `A` and `B`, if a resource exists under `B`, it will reflect in the metrics generated for `A` as well, in addition to any resources of itself, and vice-versa. This logic is based on the [current `list`ing behavior](https://github.com/kubernetes/client-go/issues/1251#issuecomment-1544083071) of the client-go library.
|
||||
- The introduction of this feature further discourages (and discontinues) the use of native objects in the CRS featureset, since these do not have an explicit CRD associated with them, and conflict with internal stores defined specifically for such native resources. Please consider opening an issue or raising a PR if you'd like to expand on the current metric labelsets for them. Also, any such configuration will be ignored, and no metrics will be generated for the same.
|
||||
* For cases where the GVKs defined in a CRD have multiple versions under a single group for the same kind, as expected, the wildcard value will resolve to *all* versions, but a query for any specific version will return all resources under all versions, in that versions' representation. This basically means that for two such versions `A` and `B`, if a resource exists under `B`, it will reflect in the metrics generated for `A` as well, in addition to any resources of itself, and vice-versa. This logic is based on the [current `list`ing behavior](https://github.com/kubernetes/client-go/issues/1251#issuecomment-1544083071) of the client-go library.
|
||||
* The introduction of this feature further discourages (and discontinues) the use of native objects in the CRS featureset, since these do not have an explicit CRD associated with them, and conflict with internal stores defined specifically for such native resources. Please consider opening an issue or raising a PR if you'd like to expand on the current metric labelsets for them. Also, any such configuration will be ignored, and no metrics will be generated for the same.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
# Kube-State-Metrics - Performance Optimization Proposal
|
||||
|
||||
|
||||
---
|
||||
|
||||
Author: Max Inden (IndenML@gmail.com)
|
||||
Author: Max Inden (<IndenML@gmail.com>)
|
||||
|
||||
Date: 23. July 2018
|
||||
|
||||
|
|
@ -11,16 +10,14 @@ Target release: v1.5.0
|
|||
|
||||
---
|
||||
|
||||
|
||||
## Glossary
|
||||
|
||||
- kube-state-metrics: “Simple service that listens to the Kubernetes API server
|
||||
* kube-state-metrics: “Simple service that listens to the Kubernetes API server
|
||||
and generates metrics about the state of the objects”
|
||||
|
||||
- Time series: A single line in a /metrics response e.g.
|
||||
* Time series: A single line in a /metrics response e.g.
|
||||
“metric_name{label="value"} 1”
|
||||
|
||||
|
||||
## Problem Statement
|
||||
|
||||
There has been repeated reports of two issues running kube-state-metrics on
|
||||
|
|
@ -30,7 +27,6 @@ instances dropping the scrape interval request and marking the given time series
|
|||
as stale. Second kube-state-metrics uses a lot of memory and thereby being
|
||||
out-of-memory killed due to low set Kubernetes resource limits.
|
||||
|
||||
|
||||
## Goal
|
||||
|
||||
The goal of this proposal can be split into the following sub-goals ordered by
|
||||
|
|
@ -40,7 +36,6 @@ their priority:
|
|||
|
||||
2. Decrease overall runtime memory usage
|
||||
|
||||
|
||||
## Status Quo
|
||||
|
||||
Instead of requesting the needed information from the Kubernetes API-Server on
|
||||
|
|
@ -56,7 +51,6 @@ On a scrape request by e.g. Prometheus on the /metrics endpoint
|
|||
kube-state-metrics calculates the configured time series on demand based on the
|
||||
objects in its cache and converts them to the Prometheus string representation.
|
||||
|
||||
|
||||
## Proposal
|
||||
|
||||
Instead of a full representation of all Kubernetes objects with all its
|
||||
|
|
@ -139,10 +133,9 @@ pod_collector -> metrics_endpoint: concat(metrics)
|
|||
|
||||
</details>
|
||||
|
||||
|
||||
## FAQ / Follow up improvements
|
||||
|
||||
- If kube-state-metrics only listens on add, update and delete events, how is it
|
||||
* If kube-state-metrics only listens on add, update and delete events, how is it
|
||||
aware of already existing Kubernetes objects created before kube-state-metrics
|
||||
was started? Leveraging Kubernetes client-go, reflectors can initialize all
|
||||
existing objects before any add, update or delete events. To ensure no events
|
||||
|
|
@ -151,27 +144,27 @@ pod_collector -> metrics_endpoint: concat(metrics)
|
|||
costs, as Kubernetes client-go already gives decent guarantees on event
|
||||
delivery.
|
||||
|
||||
- What about metadata (HELP and description) in the /metrics output? As a first
|
||||
* What about metadata (HELP and description) in the /metrics output? As a first
|
||||
iteration they would be skipped until we have a better idea on the design.
|
||||
|
||||
- How can the cache map be concurrently accessed? The core golang map
|
||||
* How can the cache map be concurrently accessed? The core golang map
|
||||
implementation is not thread-safe. As a first iteration a simple mutex should
|
||||
be sufficient. Golang's sync.Map might be considered.
|
||||
|
||||
- To solve the problem of out of order events send by the Kubernetes API-Server
|
||||
* To solve the problem of out of order events send by the Kubernetes API-Server
|
||||
to kube-state-metrics, to each blob of time series inside the cache map it can
|
||||
keep the Kubernetes resource version. On add and update events, first compare
|
||||
the resource version of the event with than the resource version in the cache.
|
||||
Only move forward if the former is higher than the latter.
|
||||
|
||||
- In case the memory consumption of the time series string blobs is a problem
|
||||
* In case the memory consumption of the time series string blobs is a problem
|
||||
the following optimization can be considered: Among the time series strings,
|
||||
multiple sub-strings will be heavily duplicated like the metric name. Instead
|
||||
of saving unstructured strings inside the cache map, one can structure them,
|
||||
using pointers to deduplicate e.g. metric names.
|
||||
|
||||
- ...
|
||||
* ...
|
||||
|
||||
- Kube-state-metrics does not make use of all properties of all Kubernetes
|
||||
* Kube-state-metrics does not make use of all properties of all Kubernetes
|
||||
objects. Instead of unmarshalling unused properties, their json struct tags or
|
||||
their Protobuf representation could be removed.
|
||||
|
|
|
|||
|
|
@ -5,29 +5,28 @@ Any contribution to improving this documentation will be appreciated.
|
|||
|
||||
## Table of Contents
|
||||
|
||||
- [Add New Kubernetes Resource Metric Collector](#add-new-kubernetes-resource-metric-collector)
|
||||
- [Add New Metrics](#add-new-metrics)
|
||||
* [Add New Kubernetes Resource Metric Collector](#add-new-kubernetes-resource-metric-collector)
|
||||
* [Add New Metrics](#add-new-metrics)
|
||||
|
||||
### Add New Kubernetes Resource Metric Collector
|
||||
|
||||
The following steps are needed to introduce a new resource and its respective resource metrics.
|
||||
|
||||
- Reference your new resource(s) to the [docs/README.md](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/README.md#exposed-metrics).
|
||||
- Reference your new resource(s) in the [docs/cli-arguments.md](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/cli-arguments.md#available-options) as part of the `--resources` flag.
|
||||
- Create a new `<name-of-resource>.md` in the [docs](https://github.com/kubernetes/kube-state-metrics/tree/main/docs) directory to provide documentation on the resource(s) and metrics you implemented. Follow the formatting of all other resources.
|
||||
- Add the resource(s) you are representing to the [jsonnet/kube-state-metrics/kube-state-metrics.libsonnet](https://github.com/kubernetes/kube-state-metrics/blob/main/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet) under the appropriate `apiGroup` using the `verbs`: `list` and `watch`.
|
||||
- Run `make examples/standard`, this should re-generate [examples/standard/cluster-role.yaml](https://github.com/kubernetes/kube-state-metrics/blob/main/examples/standard/cluster-role.yaml) with the resource(s) added to [jsonnet/kube-state-metrics/kube-state-metrics.libsonnet](https://github.com/kubernetes/kube-state-metrics/blob/main/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet).
|
||||
- Reference and add build functions for the new resource(s) in [internal/store/builder.go](https://github.com/kubernetes/kube-state-metrics/blob/main/internal/store/builder.go).
|
||||
- Reference the new resource in [pkg/options/resource.go](https://github.com/kubernetes/kube-state-metrics/blob/main/pkg/options/resource.go).
|
||||
- Add a sample Kubernetes manifest to be used by tests in the [tests/manifests/](https://github.com/kubernetes/kube-state-metrics/tree/main/tests/manifests) directory.
|
||||
- Lastly, and most importantly, actually implement your new resource(s) and its test binary in [internal/store](https://github.com/kubernetes/kube-state-metrics/tree/main/internal/store). Follow the formatting and structure of other resources.
|
||||
* Reference your new resource(s) to the [docs/README.md](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/README.md#exposed-metrics).
|
||||
* Reference your new resource(s) in the [docs/cli-arguments.md](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/cli-arguments.md#available-options) as part of the `--resources` flag.
|
||||
* Create a new `<name-of-resource>.md` in the [docs](https://github.com/kubernetes/kube-state-metrics/tree/main/docs) directory to provide documentation on the resource(s) and metrics you implemented. Follow the formatting of all other resources.
|
||||
* Add the resource(s) you are representing to the [jsonnet/kube-state-metrics/kube-state-metrics.libsonnet](https://github.com/kubernetes/kube-state-metrics/blob/main/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet) under the appropriate `apiGroup` using the `verbs`: `list` and `watch`.
|
||||
* Run `make examples/standard`, this should re-generate [examples/standard/cluster-role.yaml](https://github.com/kubernetes/kube-state-metrics/blob/main/examples/standard/cluster-role.yaml) with the resource(s) added to [jsonnet/kube-state-metrics/kube-state-metrics.libsonnet](https://github.com/kubernetes/kube-state-metrics/blob/main/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet).
|
||||
* Reference and add build functions for the new resource(s) in [internal/store/builder.go](https://github.com/kubernetes/kube-state-metrics/blob/main/internal/store/builder.go).
|
||||
* Reference the new resource in [pkg/options/resource.go](https://github.com/kubernetes/kube-state-metrics/blob/main/pkg/options/resource.go).
|
||||
* Add a sample Kubernetes manifest to be used by tests in the [tests/manifests/](https://github.com/kubernetes/kube-state-metrics/tree/main/tests/manifests) directory.
|
||||
* Lastly, and most importantly, actually implement your new resource(s) and its test binary in [internal/store](https://github.com/kubernetes/kube-state-metrics/tree/main/internal/store). Follow the formatting and structure of other resources.
|
||||
|
||||
### Add New Metrics
|
||||
|
||||
- Make metrics experimental first when introducing them, refer [#1910](https://github.com/kubernetes/kube-state-metrics/pull/1910) for more information.
|
||||
* Make metrics experimental first when introducing them, refer [#1910](https://github.com/kubernetes/kube-state-metrics/pull/1910) for more information.
|
||||
|
||||
| Metric stability level | |
|
||||
|------------------------|--------------------|
|
||||
| EXPERIMENTAL | basemetrics.ALPHA |
|
||||
| STABLE | basemetrics.STABLE |
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# Network Policy Metrics
|
||||
|
||||
|
||||
| Metric name | Metric type | Description | Labels/tags | Status |
|
||||
| ------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------ |
|
||||
| kube_networkpolicy_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](./cli-arguments.md) | `namespace`=<namespace name> `networkpolicy`=<networkpolicy name> | EXPERIMENTAL |
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
Note:
|
||||
|
||||
- An empty string will be used if PVC has no storage class.
|
||||
* An empty string will be used if PVC has no storage class.
|
||||
|
||||
## Useful metrics queries
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
To run these tests, you need to provide two CLI flags:
|
||||
|
||||
- `--ksm-http-metrics-url`: url to access the kube-state-metrics service
|
||||
- `--ksm-telemetry-url`: url to access the kube-state-metrics telemetry endpoint
|
||||
* `--ksm-http-metrics-url`: url to access the kube-state-metrics service
|
||||
* `--ksm-telemetry-url`: url to access the kube-state-metrics telemetry endpoint
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue