Skip to content

Commit 664072e

Browse files
committed
addressing reviews
1 parent d20965f commit 664072e

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,47 @@ Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding).
307307

308308
### High Availability
309309

310-
For high availability, run multiple kube-state-metrics replicas to prevent a single point of failure. A standard setup uses at least 2 replicas, pod anti-affinity rules to ensure they run on different nodes, and a PodDisruptionBudget (PDB) with `minAvailable: 1` to protect against voluntary disruptions.
310+
Multiple replicas increase the load on the Kubernetes API as a trade-off. Most likely you don't need HA if you scrape every 30s and you can tolerate a few missing scrapes (which usually is the case).
311311

312-
When scraping the individual pods directly in an HA setup, Prometheus will ingest duplicate metrics distinguished only by the instance label. This requires you to deduplicate the data in your queries, for example, by using `max without(instance) (your_metric)`. The correct aggregation function (max, sum, avg, etc.) is important and depends on the metric type, as using the wrong one can produce incorrect values for timestamps or during brief state transitions.
312+
For high availability, run multiple kube-state-metrics replicas to prevent a single point of failure. A common setup uses at least 2 replicas, pod anti-affinity rules to ensure they run on different nodes, and a PodDisruptionBudget (PDB) with `minAvailable: 1` to protect against voluntary disruptions.
313+
314+
```yaml
315+
apiVersion: apps/v1
316+
kind: Deployment
317+
metadata:
318+
name: kube-state-metrics
319+
spec:
320+
replicas: 2
321+
template:
322+
spec:
323+
affinity:
324+
podAntiAffinity:
325+
preferredDuringSchedulingIgnoredDuringExecution:
326+
- weight: 100
327+
podAffinityTerm:
328+
labelSelector:
329+
matchLabels:
330+
app: kube-state-metrics
331+
topologyKey: kubernetes.io/hostname
332+
containers:
333+
- name: kube-state-metrics
334+
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0
335+
ports:
336+
- containerPort: 8080
337+
name: http-metrics
338+
---
339+
apiVersion: policy/v1
340+
kind: PodDisruptionBudget
341+
metadata:
342+
name: kube-state-metrics-pdb
343+
spec:
344+
minAvailable: 1
345+
selector:
346+
matchLabels:
347+
app: kube-state-metrics
348+
```
349+
350+
Most users will scrape at the service level via a ServiceMonitor / Prometheus-Operator or similar. When scraping the individual pods directly in an HA setup, Prometheus will ingest duplicate metrics distinguished only by the instance label. This requires you to deduplicate the data in your queries, for example, by using `max without(instance) (your_metric)`. The correct aggregation function (max, sum, avg, etc.) is important and depends on the metric type, as using the wrong one can produce incorrect values for timestamps or during brief state transitions.
313351

314352
### Setup
315353

README.md.tpl

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,47 @@ Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding).
308308

309309
### High Availability
310310

311-
For high availability, run multiple kube-state-metrics replicas to prevent a single point of failure. A standard setup uses at least 2 replicas, pod anti-affinity rules to ensure they run on different nodes, and a PodDisruptionBudget (PDB) with `minAvailable: 1` to protect against voluntary disruptions.
311+
Multiple replicas increase the load on the Kubernetes API as a trade-off. Most likely you don't need HA if you scrape every 30s and you can tolerate a few missing scrapes (which usually is the case).
312312

313-
When scraping the individual pods directly in an HA setup, Prometheus will ingest duplicate metrics distinguished only by the instance label. This requires you to deduplicate the data in your queries, for example, by using `max without(instance) (your_metric)`. The correct aggregation function (max, sum, avg, etc.) is important and depends on the metric type, as using the wrong one can produce incorrect values for timestamps or during brief state transitions.
313+
For high availability, run multiple kube-state-metrics replicas to prevent a single point of failure. A common setup uses at least 2 replicas, pod anti-affinity rules to ensure they run on different nodes, and a PodDisruptionBudget (PDB) with `minAvailable: 1` to protect against voluntary disruptions.
314+
315+
```yaml
316+
apiVersion: apps/v1
317+
kind: Deployment
318+
metadata:
319+
name: kube-state-metrics
320+
spec:
321+
replicas: 2
322+
template:
323+
spec:
324+
affinity:
325+
podAntiAffinity:
326+
preferredDuringSchedulingIgnoredDuringExecution:
327+
- weight: 100
328+
podAffinityTerm:
329+
labelSelector:
330+
matchLabels:
331+
app: kube-state-metrics
332+
topologyKey: kubernetes.io/hostname
333+
containers:
334+
- name: kube-state-metrics
335+
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0
336+
ports:
337+
- containerPort: 8080
338+
name: http-metrics
339+
---
340+
apiVersion: policy/v1
341+
kind: PodDisruptionBudget
342+
metadata:
343+
name: kube-state-metrics-pdb
344+
spec:
345+
minAvailable: 1
346+
selector:
347+
matchLabels:
348+
app: kube-state-metrics
349+
```
350+
351+
Most users will scrape at the service level via a ServiceMonitor / Prometheus-Operator or similar. When scraping the individual pods directly in an HA setup, Prometheus will ingest duplicate metrics distinguished only by the instance label. This requires you to deduplicate the data in your queries, for example, by using `max without(instance) (your_metric)`. The correct aggregation function (max, sum, avg, etc.) is important and depends on the metric type, as using the wrong one can produce incorrect values for timestamps or during brief state transitions.
314352

315353
### Setup
316354

0 commit comments

Comments
 (0)