Skip to content

Commit 2dc529d

Browse files
authored
Update cli-arguments.md
1 parent 6a99244 commit 2dc529d

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

docs/developer/cli-arguments.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ spec:
2424
<!-- markdownlint-disable blanks-around-fences -->
2525
<!-- markdownlint-disable link-image-reference-definitions -->
2626
[embedmd]:# (../../help.txt)
27+
2728
```txt
2829
$ kube-state-metrics -h
2930
kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects.
@@ -90,8 +91,6 @@ Flags:
9091

9192
Use "kube-state-metrics [command] --help" for more information about a command.
9293
```
93-
<!-- markdownlint-enable link-image-reference-definitions -->
94-
<!-- markdownlint-enable blanks-around-fences -->
9594

9695
## Examples
9796

@@ -124,10 +123,13 @@ kube-state-metrics \
124123
--metric-labels-allowlist="namespaces=[kubernetes.io/team],pods=[owner]" \
125124
--namespaces-denylist="default,kube-system"
126125
```
126+
127127
## Config-file support
128+
128129
You can provide a YAML config file using the `--config` flag instead of (or in addition to) command-line flags. Any flags passed on the command line will override values in the config file.
129130

130131
Example `config.yaml`:
132+
131133
```yaml
132134
port: 9090
133135
serverIdleTimeout: "2m"
@@ -137,15 +139,19 @@ metricAllowlist:
137139
```
138140
139141
Run with config file:
142+
140143
```bash
141144
kube-state-metrics --config=config.yaml --port=8085
142145
```
143146

144147
## Mutual-exclusion of allowlists and denylists
148+
145149
For metrics, annotations, and labels, allowlists and denylists cannot be used together. If both are specified, the allowlist takes precedence and the denylist is ignored.
146150

147151
## Kubernetes Deployment example
152+
148153
You can embed any of the flags in a Deployment manifest under `args:`:
154+
149155
```yaml
150156
spec:
151157
template:
@@ -155,21 +161,27 @@ spec:
155161
args:
156162
- "--metric-allowlist=kube_pod_info,kube_node_*"
157163
- "--server-idle-timeout=2m"
158-
```
164+
```
159165
160166
## Experimental flags
167+
161168
The following flags are experimental and subject to change:
162-
- `--auto-gomemlimit`, `--auto-gomemlimit-ratio`
163-
- `--auth-filter`
164-
- `--shard`, `--total-shards`
165-
- `--track-unscheduled-pods`
169+
170+
* `--auto-gomemlimit`, `--auto-gomemlimit-ratio`
171+
* `--auth-filter`
172+
* `--shard`, `--total-shards`
173+
* `--track-unscheduled-pods`
166174

167175
## Custom Resource State metrics
176+
168177
You can enable custom resource state metrics using:
178+
169179
```bash
170180
kube-state-metrics --custom-resource-state-config-file=crs-config.yaml
171181
```
182+
172183
Example `crs-config.yaml`:
184+
173185
```yaml
174186
resources:
175187
pods:
@@ -179,8 +191,12 @@ resources:
179191
```
180192

181193
## Auth-filter example
194+
182195
Protect the metrics endpoint with Kubernetes RBAC by enabling the auth filter and providing a kubeconfig:
196+
183197
```bash
184198
kube-state-metrics --auth-filter --kubeconfig=/etc/kubernetes/kubeconfig
185199
```
200+
186201
Ensure the service account used has a Role or ClusterRole granting `get` on `metrics.k8s.io` in the desired namespace.
202+

0 commit comments

Comments
 (0)