Skip to content

Commit 95471d1

Browse files
committed
Merge tag 'v2.12.0' into os-master
2 parents e1dde66 + 1e8b837 commit 95471d1

File tree

1,223 files changed

+55032
-26532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,223 files changed

+55032
-26532
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ version: 2
22
updates:
33
- package-ecosystem: "gomod"
44
directory: "/"
5+
groups:
6+
k8s-dependencies:
7+
patterns:
8+
- "k8s.io*"
59
schedule:
610
interval: "weekly"
711
- package-ecosystem: "gomod"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
make install-tools
107107
108-
- name: Check that all metrics are documented
108+
- name: Check that all metrics are documented and templates have no delta
109109
run: |
110110
make doccheck
111111

CHANGELOG.md

Lines changed: 73 additions & 58 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ IMAGE = $(REGISTRY)/kube-state-metrics
2121
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
2222
USER ?= $(shell id -u -n)
2323
HOST ?= $(shell hostname)
24+
MARKDOWNLINT_CLI2_VERSION = 0.9.2
25+
2426

2527
export DOCKER_CLI_EXPERIMENTAL=enabled
2628

@@ -41,13 +43,14 @@ licensecheck:
4143
exit 1; \
4244
fi
4345

44-
lint: shellcheck licensecheck
46+
lint: shellcheck licensecheck lint-markdown-format
4547
golangci-lint run
4648

47-
lint-fix:
49+
lint-fix: fix-markdown-format
4850
golangci-lint run --fix -v
51+
4952

50-
doccheck: generate
53+
doccheck: generate validate-template
5154
@echo "- Checking if the generated documentation is up to date..."
5255
@git diff --exit-code
5356
@echo "- Checking if the documentation is in sync with the code..."
@@ -78,6 +81,18 @@ test-rules:
7881
shellcheck:
7982
${DOCKER_CLI} run -v "${PWD}:/mnt" koalaman/shellcheck:stable $(shell find . -type f -name "*.sh" -not -path "*vendor*")
8083

84+
lint-markdown-format:
85+
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --config .markdownlint-cli2.jsonc
86+
87+
fix-markdown-format:
88+
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --fix --config .markdownlint-cli2.jsonc
89+
90+
generate-template:
91+
gomplate -d config=./data.yaml --file README.md.tpl > README.md
92+
93+
validate-template: generate-template
94+
git diff --no-ext-diff --quiet --exit-code README.md
95+
8196
# Runs benchmark tests on the current git ref and the last release and compares
8297
# the two.
8398
test-benchmark-compare:
@@ -120,7 +135,7 @@ clean:
120135
e2e:
121136
./tests/e2e.sh
122137

123-
generate: build-local
138+
generate: build-local generate-template
124139
@echo ">> generating docs"
125140
@./scripts/generate-help-text.sh
126141
embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print`
@@ -163,4 +178,4 @@ install-promtool:
163178
@wget -qO- "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.${OS}-${ARCH}.tar.gz" |\
164179
tar xvz --strip-components=1 prometheus-${PROMETHEUS_VERSION}.${OS}-${ARCH}/promtool
165180

166-
.PHONY: all build build-local all-push all-container container container-* do-push-* sub-push-* push push-multi-arch test-unit test-rules test-benchmark-compare clean e2e validate-modules shellcheck licensecheck lint lint-fix generate embedmd
181+
.PHONY: all build build-local all-push all-container container container-* do-push-* sub-push-* push push-multi-arch test-unit test-rules test-benchmark-compare clean e2e validate-modules shellcheck licensecheck lint lint-fix generate generate-template validate-template embedmd

README.md

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,36 @@ the raw metrics. Note that the metrics exposed on the `/metrics` endpoint
2929
reflect the current state of the Kubernetes cluster. When Kubernetes objects
3030
are deleted they are no longer visible on the `/metrics` endpoint.
3131

32+
> [!NOTE]
33+
> This README is generated from a [template](./README.md.tpl). Please make your changes there and run `make generate-template`.
34+
3235
## Table of Contents
3336

34-
- [Versioning](#versioning)
35-
- [Kubernetes Version](#kubernetes-version)
36-
- [Compatibility matrix](#compatibility-matrix)
37-
- [Resource group version compatibility](#resource-group-version-compatibility)
38-
- [Container Image](#container-image)
39-
- [Metrics Documentation](#metrics-documentation)
40-
- [Conflict resolution in label names](#conflict-resolution-in-label-names)
41-
- [Kube-state-metrics self metrics](#kube-state-metrics-self-metrics)
42-
- [Resource recommendation](#resource-recommendation)
43-
- [Latency](#latency)
44-
- [A note on costing](#a-note-on-costing)
45-
- [kube-state-metrics vs. metrics-server](#kube-state-metrics-vs-metrics-server)
46-
- [Scaling kube-state-metrics](#scaling-kube-state-metrics)
47-
- [Resource recommendation](#resource-recommendation)
48-
- [Horizontal sharding](#horizontal-sharding)
49-
- [Automated sharding](#automated-sharding)
50-
- [Daemonset sharding for pod metrics](#daemonset-sharding-for-pod-metrics)
51-
- [Setup](#setup)
52-
- [Building the Docker container](#building-the-docker-container)
53-
- [Usage](#usage)
54-
- [Kubernetes Deployment](#kubernetes-deployment)
55-
- [Limited privileges environment](#limited-privileges-environment)
56-
- [Helm Chart](#helm-chart)
57-
- [Development](#development)
58-
- [Developer Contributions](#developer-contributions)
37+
* [Versioning](#versioning)
38+
* [Kubernetes Version](#kubernetes-version)
39+
* [Compatibility matrix](#compatibility-matrix)
40+
* [Resource group version compatibility](#resource-group-version-compatibility)
41+
* [Container Image](#container-image)
42+
* [Metrics Documentation](#metrics-documentation)
43+
* [Conflict resolution in label names](#conflict-resolution-in-label-names)
44+
* [Kube-state-metrics self metrics](#kube-state-metrics-self-metrics)
45+
* [Resource recommendation](#resource-recommendation)
46+
* [Latency](#latency)
47+
* [A note on costing](#a-note-on-costing)
48+
* [kube-state-metrics vs. metrics-server](#kube-state-metrics-vs-metrics-server)
49+
* [Scaling kube-state-metrics](#scaling-kube-state-metrics)
50+
* [Resource recommendation](#resource-recommendation)
51+
* [Horizontal sharding](#horizontal-sharding)
52+
* [Automated sharding](#automated-sharding)
53+
* [Daemonset sharding for pod metrics](#daemonset-sharding-for-pod-metrics)
54+
* [Setup](#setup)
55+
* [Building the Docker container](#building-the-docker-container)
56+
* [Usage](#usage)
57+
* [Kubernetes Deployment](#kubernetes-deployment)
58+
* [Limited privileges environment](#limited-privileges-environment)
59+
* [Helm Chart](#helm-chart)
60+
* [Development](#development)
61+
* [Developer Contributions](#developer-contributions)
5962

6063
### Versioning
6164

@@ -74,13 +77,12 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If
7477

7578
| kube-state-metrics | Kubernetes client-go Version |
7679
|--------------------|:----------------------------:|
77-
| **v2.7.0** | v1.25 |
7880
| **v2.8.2** | v1.26 |
7981
| **v2.9.2** | v1.26 |
8082
| **v2.10.1** | v1.27 |
8183
| **v2.11.0** | v1.28 |
82-
| **main** | v1.28 |
83-
84+
| **v2.12.0** | v1.29 |
85+
| **main** | v1.29 |
8486

8587
#### Resource group version compatibility
8688

@@ -92,8 +94,8 @@ release.
9294

9395
The latest container image can be found at:
9496

95-
* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.11.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`)
96-
* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.11.0)
97+
* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`)
98+
* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.12.0)
9799

98100
### Metrics Documentation
99101

@@ -134,13 +136,15 @@ If you encounter those errors in the metrics, it is most likely a configuration
134136
at the logs of kube-state-metrics.
135137

136138
Example of the above mentioned metrics:
139+
137140
```
138141
kube_state_metrics_list_total{resource="*v1.Node",result="success"} 1
139142
kube_state_metrics_list_total{resource="*v1.Node",result="error"} 52
140143
kube_state_metrics_watch_total{resource="*v1beta1.Ingress",result="success"} 1
141144
```
142145

143146
kube-state-metrics also exposes some http request metrics, examples of those are:
147+
144148
```
145149
http_request_duration_seconds_bucket{handler="metrics",method="get",le="2.5"} 30
146150
http_request_duration_seconds_bucket{handler="metrics",method="get",le="5"} 30
@@ -151,6 +155,7 @@ http_request_duration_seconds_count{handler="metrics",method="get"} 30
151155
```
152156

153157
kube-state-metrics also exposes build and configuration metrics:
158+
154159
```
155160
kube_state_metrics_build_info{branch="main",goversion="go1.15.3",revision="6c9d775d",version="v2.0.0-beta"} 1
156161
kube_state_metrics_shard_ordinal{shard_ordinal="0"} 0
@@ -254,6 +259,7 @@ For pod metrics, they can be sharded per node with the following flag:
254259
Each kube-state-metrics pod uses FieldSelector (spec.nodeName) to watch/list pod metrics only on the same node.
255260

256261
A daemonset kube-state-metrics example:
262+
257263
```
258264
apiVersion: apps/v1
259265
kind: DaemonSet
@@ -304,6 +310,7 @@ go get k8s.io/kube-state-metrics
304310

305311
Simply run the following command in this root folder, which will create a
306312
self-contained, statically-linked binary and build a Docker image:
313+
307314
```
308315
make container
309316
```
@@ -331,15 +338,16 @@ To have Prometheus discover kube-state-metrics instances it is advised to create
331338
kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=$(gcloud info --format='value(config.account)')
332339
```
333340

334-
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.
341+
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>.
335342

336343
After running the above, if you see `Clusterrolebinding "cluster-admin-binding" created`, then you are able to continue with the setup of this service.
337344

338345
#### Limited privileges environment
339346

340347
If you want to run kube-state-metrics in an environment where you don't have cluster-reader role, you can:
341348

342-
- create a serviceaccount
349+
* create a serviceaccount
350+
343351
```yaml
344352
apiVersion: v1
345353
kind: ServiceAccount
@@ -348,7 +356,8 @@ metadata:
348356
namespace: your-namespace-where-kube-state-metrics-will-deployed
349357
```
350358
351-
- 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*)
359+
* 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*)
360+
352361
```yaml
353362
apiVersion: rbac.authorization.k8s.io/v1
354363
kind: RoleBinding
@@ -365,7 +374,7 @@ subjects:
365374
namespace: your-namespace-where-kube-state-metrics-will-deployed
366375
```
367376

368-
- 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
377+
* 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
369378

370379
```yaml
371380
spec:
@@ -380,7 +389,6 @@ spec:
380389

381390
For the full list of arguments available, see the documentation in [docs/cli-arguments.md](./docs/cli-arguments.md)
382391

383-
384392
#### Helm Chart
385393

386394
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.
@@ -392,12 +400,12 @@ running:
392400

393401
> Users can override the apiserver address in KUBE-CONFIG file with `--apiserver` command line.
394402

395-
go install
396-
kube-state-metrics --port=8080 --telemetry-port=8081 --kubeconfig=<KUBE-CONFIG> --apiserver=<APISERVER>
403+
go install
404+
kube-state-metrics --port=8080 --telemetry-port=8081 --kubeconfig=<KUBE-CONFIG> --apiserver=<APISERVER>
397405

398406
Then curl the metrics endpoint
399407

400-
curl localhost:8080/metrics
408+
curl localhost:8080/metrics
401409

402410
To run the e2e tests locally see the documentation in [tests/README.md](./tests/README.md).
403411

0 commit comments

Comments
 (0)