[stable/kube-state-metrics] allow configuring collectors (#2124)

kube-state-metrics has a collector for each kind of Kubernetes resource
it collects metrics from. Each of those collectors directly influences
the RBAC requirements for the Pods. Additionally due to the nature of
how kube-state-metrics is versioned and released it is not easy to
determine which collectors are using "alpha" APIs, which are not
necessarily enabled in a cluster, but kube-state-metrics by default has
all collectors enabled.
This commit is contained in:
Frederic Branczyk
2017-11-17 09:52:33 +01:00
committed by Reinhard Nägele
parent 939e573a10
commit 92fd7ac0e1
6 changed files with 151 additions and 26 deletions
+23 -9
View File
@@ -12,12 +12,26 @@ $ helm install stable/kube-state-metrics
## Configuration
| Parameter | Description | Default |
|---------------------------|---------------------------------------------------------|---------------------------------------------|
| `image.repository` | The image repository to pull from | gcr.io/google_containers/kube-state-metrics |
| `image.tag` | The image tag to pull from | v1.0.1 |
| `image.pullPolicy` | Image pull policy | IfNotPresent |
| `service.port` | The port of the container | 8080 |
| `prometheusScrape` | Whether or not enable prom scrape | True |
| `rbac.create` | If true, create & use RBAC resources | False |
| `rbac.serviceAccountName` | ServiceAccount to be used (ignored if rbac.create=true) | default |
| Parameter | Description | Default |
|-------------------------------------|---------------------------------------------------------|---------------------------------------------|
| `image.repository` | The image repository to pull from | gcr.io/google_containers/kube-state-metrics |
| `image.tag` | The image tag to pull from | v1.0.1 |
| `image.pullPolicy` | Image pull policy | IfNotPresent |
| `service.port` | The port of the container | 8080 |
| `prometheusScrape` | Whether or not enable prom scrape | True |
| `rbac.create` | If true, create & use RBAC resources | False |
| `rbac.serviceAccountName` | ServiceAccount to be used (ignored if rbac.create=true) | default |
| `resources` | kube-state-metrics resource requests and limits | {} |
| `collectors.daemonsets` | Enable the daemonsets collector. | true |
| `collectors.deployments` | Enable the deployments collector. | true |
| `collectors.limitranges` | Enable the limitranges collector. | true |
| `collectors.nodes` | Enable the nodes collector. | true |
| `collectors.pods` | Enable the pods collector. | true |
| `collectors.replicasets` | Enable the replicasets collector. | true |
| `collectors.replicationcontrollers` | Enable the replicationcontrollers collector. | true |
| `collectors.resourcequotas` | Enable the resourcequotas collector. | true |
| `collectors.services` | Enable the services collector. | true |
| `collectors.jobs` | Enable the jobs collector. | true |
| `collectors.cronjobs` | Enable the cronjobs collector. | true |
| `collectors.statefulsets` | Enable the statefulsets collector. | true |
| `collectors.persistentvolumeclaims` | Enable the persistentvolumeclaims collector. | true |
@@ -1,5 +1,6 @@
kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects.
The exposed metrics can be found here: https://github.com/kubernetes/kube-state-metrics/#node-metrics.
The exposed metrics can be found here:
https://github.com/kubernetes/kube-state-metrics/tree/master/Documentation#documentation.
The metrics are exported on the HTTP endpoint /metrics on the listening port.
In your case, {{ template "kube-state-metrics.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}/metrics
@@ -9,29 +9,82 @@ metadata:
release: {{ .Release.Name }}
name: {{ template "kube-state-metrics.fullname" . }}
rules:
- apiGroups: [""]
resources:
- nodes
- pods
- services
- resourcequotas
- replicationcontrollers
- limitranges
- persistentvolumeclaims
verbs: ["list", "watch"]
{{ if .Values.collectors.daemonsets }}
- apiGroups: ["extensions"]
resources:
- daemonsets
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.deployments }}
- apiGroups: ["extensions"]
resources:
- deployments
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.limitranges }}
- apiGroups: [""]
resources:
- limitranges
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.nodes }}
- apiGroups: [""]
resources:
- nodes
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.pods }}
- apiGroups: [""]
resources:
- pods
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.replicasets }}
- apiGroups: ["extensions"]
resources:
- replicasets
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.replicationcontrollers }}
- apiGroups: [""]
resources:
- replicationcontrollers
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.resourcequotas }}
- apiGroups: [""]
resources:
- resourcequotas
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.services }}
- apiGroups: [""]
resources:
- services
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.jobs }}
- apiGroups: ["batch"]
resources:
- jobs
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.cronjobs }}
- apiGroups: ["batch"]
resources:
- cronjobs
verbs: ["list", "watch"]
{{ end -}}
{{ if .Values.collectors.statefulsets }}
- apiGroups: ["apps"]
resources:
- statefulsets
verbs: ["list", "watch"]
- apiGroups: ["batch"]
{{ end -}}
{{ if .Values.collectors.persistentvolumeclaims }}
- apiGroups: [""]
resources:
- cronjobs
- jobs
- persistentvolumeclaims
verbs: ["list", "watch"]
{{ end }}
{{- end -}}
@@ -13,7 +13,7 @@ roleRef:
kind: ClusterRole
name: {{ template "kube-state-metrics.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "kube-state-metrics.fullname" . }}
namespace: {{ .Release.Namespace }}
- kind: ServiceAccount
name: {{ template "kube-state-metrics.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
@@ -18,6 +18,46 @@ spec:
serviceAccountName: {{ if .Values.rbac.create }}{{ template "kube-state-metrics.fullname" . }}{{ else }}"{{ .Values.rbac.serviceAccountName }}"{{ end }}
containers:
- name: {{ .Chart.Name }}
args:
{{ if .Values.collectors.daemonsets }}
- --collectors=daemonsets
{{ end }}
{{ if .Values.collectors.deployments }}
- --collectors=deployments
{{ end }}
{{ if .Values.collectors.limitranges }}
- --collectors=limitranges
{{ end }}
{{ if .Values.collectors.nodes }}
- --collectors=nodes
{{ end }}
{{ if .Values.collectors.pods }}
- --collectors=pods
{{ end }}
{{ if .Values.collectors.replicasets }}
- --collectors=replicasets
{{ end }}
{{ if .Values.collectors.replicationcontrollers }}
- --collectors=replicationcontrollers
{{ end }}
{{ if .Values.collectors.resourcequotas }}
- --collectors=resourcequotas
{{ end }}
{{ if .Values.collectors.services }}
- --collectors=services
{{ end }}
{{ if .Values.collectors.jobs }}
- --collectors=jobs
{{ end }}
{{ if .Values.collectors.cronjobs }}
- --collectors=cronjobs
{{ end }}
{{ if .Values.collectors.statefulsets }}
- --collectors=statefulsets
{{ end }}
{{ if .Values.collectors.persistentvolumeclaims }}
- --collectors=persistentvolumeclaims
{{ end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
+17
View File
@@ -15,3 +15,20 @@ rbac:
create: false
# Ignored if rbac.create is true
serviceAccountName: default
# Available collectors for kube-state-metrics. By default all available
# collectors are enabled.
collectors:
daemonsets: true
deployments: true
limitranges: true
nodes: true
pods: true
replicasets: true
replicationcontrollers: true
resourcequotas: true
services: true
jobs: true
cronjobs: true
statefulsets: true
persistentvolumeclaims: true