Skip to content

Commit fccf72b

Browse files
committed
docs: updated VPA CustomResourceStateMetrics docs to reflect what needs to be done for recommendations
Signed-off-by: Sherif Ayad <[email protected]>
1 parent 3a0eec4 commit fccf72b

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

docs/metrics/extend/customresourcestate-metrics.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,9 @@ kube_customresource_verticalpodautoscaler_status_recommendation_containerrecomme
325325

326326
#### VerticalPodAutoscaler
327327

328-
In v2.9.0 the `vericalpodautoscalers` resource was removed from the list of default resources. In order to generate metrics for `verticalpodautoscalers`, you can use the following Custom Resource State config:
328+
In v2.9.0 the `verticalpodautoscalers` resource was removed from the list of default resources. In order to generate Memory / CPU recommendation metrics for `verticalpodautoscalers`, you can use the following Custom Resource State config:
329329

330330
```yaml
331-
# Using --resource=verticalpodautoscalers, we get the following output:
332-
# HELP kube_verticalpodautoscaler_annotations Kubernetes annotations converted to Prometheus labels.
333-
# TYPE kube_verticalpodautoscaler_annotations gauge
334-
# kube_verticalpodautoscaler_annotations{namespace="default",verticalpodautoscaler="hamster-vpa",target_api_version="apps/v1",target_kind="Deployment",target_name="hamster"} 1
335-
# A similar result can be achieved by specifying the following in --custom-resource-state-config:
336331
kind: CustomResourceStateMetrics
337332
spec:
338333
resources:
@@ -347,19 +342,49 @@ spec:
347342
target_kind: [spec, targetRef, kind]
348343
target_name: [spec, targetRef, name]
349344
metrics:
350-
- name: "annotations"
351-
help: "Kubernetes annotations converted to Prometheus labels."
345+
- name: "vpa_containerrecommendations_target_memory"
346+
help: "VPA container recommendations for memory (in bytes)."
352347
each:
353348
type: Gauge
354349
gauge:
355-
path: [metadata, annotations]
356-
# This will output the following metric:
357-
# HELP kube_customresource_autoscaling_annotations Kubernetes annotations converted to Prometheus labels.
358-
# TYPE kube_customresource_autoscaling_annotations gauge
359-
# kube_customresource_autoscaling_annotations{customresource_group="autoscaling.k8s.io", customresource_kind="VerticalPodAutoscaler", customresource_version="v1", namespace="default",target_api_version="autoscaling.k8s.io/v1",target_kind="Deployment",target_name="hamster",verticalpodautoscaler="hamster-vpa"} 123
350+
path: [status, recommendation, containerRecommendations]
351+
valueFrom: [target, memory]
352+
labelsFromPath:
353+
container: [containerName]
354+
- name: "vpa_containerrecommendations_target_cpu"
355+
help: "VPA container recommendations for cpu (in cores)."
356+
each:
357+
type: Gauge
358+
gauge:
359+
path: [status, recommendation, containerRecommendations]
360+
valueFrom: [target, cpu]
361+
labelsFromPath:
362+
container: [containerName]
363+
```
364+
365+
The above configuration was tested on [this](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/examples/hamster.yaml) VPA configuration, outputting the following metrics:
366+
367+
```
368+
# HELP kube_customresource_vpa_containerrecommendations_target_memory VPA container recommendations for memory (in bytes).
369+
kube_customresource_vpa_containerrecommendations_target_memory{container="hamster",customresource_group="autoscaling.k8s.io",customresource_kind="VerticalPodAutoscaler",customresource_version="v1",namespace="default",target_api_version="autoscaling.k8s.io/v1",target_kind="Deployment",target_name="hamster",verticalpodautoscaler="hamster-vpa"} 1.048576e+08
370+
371+
# HELP kube_customresource_vpa_containerrecommendations_target_cpu VPA container recommendations for cpu (in cores).
372+
kube_customresource_vpa_containerrecommendations_target_cpu{container="hamster",customresource_group="autoscaling.k8s.io",customresource_kind="VerticalPodAutoscaler",customresource_version="v1",namespace="default",target_api_version="autoscaling.k8s.io/v1",target_kind="Deployment",target_name="hamster",verticalpodautoscaler="hamster-vpa"} 0.1
360373
```
361374

362-
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`).
375+
In RBAC-enabled clusters and to ensure that the VPA Metrics will be captured seamlessly, make sure that the Cluster Role / Role assigned to the Kube State Metrics has permissions to `list` & `watch` VPA resources (as well as `customresourcedefinitions`) e.g.:
376+
377+
```yaml
378+
- verbs:
379+
- list
380+
- watch
381+
apiGroups:
382+
- autoscaling.k8s.io
383+
- apiextensions.k8s.io
384+
resources:
385+
- verticalpodautoscalers
386+
- customresourcedefinitions
387+
```
363388

364389
#### All VerticalPodAutoscaler Metrics
365390

0 commit comments

Comments
 (0)