Skip to content

Commit 93e79fc

Browse files
committed
Remove RBAC resources from default exposed metric set
These resources might create a lot of metrics, so we won't enable them by default for now. Signed-off-by: Manuel Rüger <[email protected]>
1 parent 5b017f7 commit 93e79fc

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

docs/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ As of v2.3.0, kube-state-metrics supports additional opt-in metrics via the CLI
2727

2828
## Exposed Metrics
2929

30-
Per group of metrics there is one file for each metrics. See each file for specific documentation about the exposed metrics:
30+
Per group of metrics there is one file for each metrics.
31+
See each file for specific documentation about the exposed metrics:
32+
33+
### Default Resources
3134

3235
- [CertificateSigningRequest Metrics](certificatesigningrequest-metrics.md)
33-
- [ClusterRole Metrics](clusterrole-metrics.md)
34-
- [ClusterRoleBinding Metrics](clusterrolebinding-metrics.md)
3536
- [ConfigMap Metrics](configmap-metrics.md)
3637
- [CronJob Metrics](cronjob-metrics.md)
3738
- [DaemonSet Metrics](daemonset-metrics.md)
@@ -53,17 +54,22 @@ Per group of metrics there is one file for each metrics. See each file for speci
5354
- [ReplicaSet Metrics](replicaset-metrics.md)
5455
- [ReplicationController Metrics](replicationcontroller-metrics.md)
5556
- [ResourceQuota Metrics](resourcequota-metrics.md)
56-
- [Role Metrics](role-metrics.md)
57-
- [RoleBinding Metrics](rolebinding-metrics.md)
5857
- [Secret Metrics](secret-metrics.md)
5958
- [Service Metrics](service-metrics.md)
60-
- [ServiceAccount Metrics](serviceaccount-metrics.md)
6159
- [StatefulSet Metrics](statefulset-metrics.md)
6260
- [StorageClass Metrics](storageclass-metrics.md)
6361
- [ValidatingWebhookConfiguration Metrics](validatingwebhookconfiguration-metrics.md)
64-
- [VerticalPodAutoscaler Metrics](verticalpodautoscaler-metrics.md)
6562
- [VolumeAttachment Metrics](volumeattachment-metrics.md)
6663

64+
### Optional Resources
65+
66+
- [ClusterRole Metrics](clusterrole-metrics.md)
67+
- [ClusterRoleBinding Metrics](clusterrolebinding-metrics.md)
68+
- [Role Metrics](role-metrics.md)
69+
- [RoleBinding Metrics](rolebinding-metrics.md)
70+
- [ServiceAccount Metrics](serviceaccount-metrics.md)
71+
- [VerticalPodAutoscaler Metrics](verticalpodautoscaler-metrics.md)
72+
6773
## Join Metrics
6874

6975
When an additional, not provided by default label is needed, a [Prometheus matching operator](https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching)

docs/cli-arguments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Usage of ./kube-state-metrics:
5050
--pod string Name of the pod that contains the kube-state-metrics container. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
5151
--pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
5252
--port int Port to expose metrics on. (default 8080)
53-
--resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,clusterrolebindings,clusterroles,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,rolebindings,roles,secrets,serviceaccounts,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments"
53+
--resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments"
5454
--shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0)
5555
--skip_headers If true, avoid header prefixes in the log messages
5656
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)

pkg/options/resource.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ var (
2727
// DefaultResources represents the default set of resources in kube-state-metrics.
2828
DefaultResources = ResourceSet{
2929
"certificatesigningrequests": struct{}{},
30-
"clusterrolebindings": struct{}{},
31-
"clusterroles": struct{}{},
3230
"configmaps": struct{}{},
3331
"cronjobs": struct{}{},
3432
"daemonsets": struct{}{},
@@ -50,10 +48,7 @@ var (
5048
"replicasets": struct{}{},
5149
"replicationcontrollers": struct{}{},
5250
"resourcequotas": struct{}{},
53-
"rolebindings": struct{}{},
54-
"roles": struct{}{},
5551
"secrets": struct{}{},
56-
"serviceaccounts": struct{}{},
5752
"services": struct{}{},
5853
"statefulsets": struct{}{},
5954
"storageclasses": struct{}{},

tests/e2e/main_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,20 @@ func TestDefaultCollectorMetricsAvailable(t *testing.T) {
252252
}
253253

254254
resources := map[string]struct{}{}
255+
nonDefaultResources := map[string]bool{
256+
"clusterrole": true,
257+
"clusterrolebinding": true,
258+
"role": true,
259+
"rolebinding": true,
260+
"serviceaccount": true,
261+
"verticalpodautoscaler": true,
262+
}
263+
nonResources := map[string]bool{
264+
"builder": true,
265+
"utils": true,
266+
"testutils": true,
267+
}
268+
255269
files, err := os.ReadDir("../../internal/store/")
256270
if err != nil {
257271
t.Fatalf("failed to read dir to get all resouces name: %v", err)
@@ -263,11 +277,11 @@ func TestDefaultCollectorMetricsAvailable(t *testing.T) {
263277
if len(params) != 2 {
264278
continue
265279
}
266-
if params[1] == "builder" || params[1] == "utils" || params[1] == "testutils" {
280+
if nonResources[params[1]] {
267281
// Non resource file
268282
continue
269283
}
270-
if params[1] == "verticalpodautoscaler" {
284+
if nonDefaultResources[params[1]] {
271285
// Resource disabled by default
272286
continue
273287
}

0 commit comments

Comments
 (0)