Skip to content

Commit 2f1da3a

Browse files
Provide scaling example
1 parent f9d29ba commit 2f1da3a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ are deleted they are no longer visible on the `/metrics` endpoint.
4545
- [Resource recommendation](#resource-recommendation)
4646
- [Horizontal sharding](#horizontal-sharding)
4747
- [Automated sharding](#automated-sharding)
48+
- [Daemonset sharding for pod metrics](#daemonset-sharding-pod-metrics)
4849
- [Setup](#setup)
4950
- [Building the Docker container](#building-the-docker-container)
5051
- [Usage](#usage)
@@ -235,6 +236,31 @@ This way of deploying shards is useful when you want to manage KSM shards throug
235236

236237
The downside of using an auto-sharded setup comes from the rollout strategy supported by `StatefulSet`s. When managed by a `StatefulSet`, pods are replaced one at a time with each pod first getting terminated and then recreated. Besides such rollouts being slower, they will also lead to short downtime for each shard. If a Prometheus scrape happens during a rollout, it can miss some of the metrics exported by kube-state-metrics.
237238

239+
### Daemonset sharding for pod metrics
240+
241+
For pod metrics, they can be sharded per node with the following flag:
242+
* `--nodename`
243+
244+
Each kube-state-metrics pod uses FieldSelector (spec.nodeName) to watch/list pod metrics only on the same node.
245+
246+
A daemonset kube-state-metrics example:
247+
```
248+
apiVersion: apps/v1
249+
kind: DaemonSet
250+
metadata:
251+
name: kube-state-metrics
252+
spec:
253+
template:
254+
spec:
255+
containers:
256+
- name: kube-state-metrics
257+
args:
258+
- --resources=pods
259+
- --nodename=$(NODE_NAME)
260+
```
261+
262+
For other metrics, they can sharded via [Horizontal sharding](#horizontal-sharding).
263+
238264
### Setup
239265

240266
Install this project to your `$GOPATH` using `go get`:

0 commit comments

Comments
 (0)