Skip to content

Commit

Permalink
feat(kube-state-metrics): allow creation of custom resource state
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin <[email protected]>
  • Loading branch information
stucki-stuck committed Jan 31, 2025
1 parent 32912fd commit 23a8a63
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bitnami/kube-state-metrics/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,13 @@ rules:
- volumeattachments
verbs: ["list", "watch"]
{{- end }}
{{- if .Values.customResourceState.enabled }}
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs: ["list", "watch"]
{{- end }}
{{- if .Values.rbac.rules }}
{{- include "common.tplvalues.render" ( dict "value" .Values.rbac.rules "context" $ ) | nindent 2 }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions bitnami/kube-state-metrics/templates/crs-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.customResourceState.enabled}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-customresourcestate-configuration" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
configuration.yaml: |
{{- include "common.tplvalues.render" ( dict "value" .Values.customResourceState.configuration "context" $ ) | nindent 4 }}
{{- end }}
13 changes: 13 additions & 0 deletions bitnami/kube-state-metrics/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ spec:
{{- if .Values.kubeResources.volumeattachments }}
- --resources=volumeattachments
{{- end }}
{{- if .Values.customResourceState.enabled }}
- --custom-resource-state-config-file=/etc/customresourcestate/configuration.yaml
{{- end }}
{{- if .Values.namespaces }}
- --namespaces={{- include "common.tplvalues.render" ( dict "value" .Values.namespaces "context" $ ) }}
{{- end }}
Expand Down Expand Up @@ -239,6 +242,11 @@ spec:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if .Values.customResourceState.enabled }}
- name: customresourcestate-configuration
mountPath: /etc/customresourcestate
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand All @@ -248,6 +256,11 @@ spec:
volumes:
- name: empty-dir
emptyDir: {}
{{- if .Values.customResourceState.enabled}}
- name: customresourcestate-configuration
configMap:
name: {{ printf "%s-customresourcestate-configuration" (include "common.names.fullname" .) }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
{{- end }}
21 changes: 21 additions & 0 deletions bitnami/kube-state-metrics/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ rbac:
## @param rbac.pspEnabled Whether to create a PodSecurityPolicy and bound it with RBAC. WARNING: PodSecurityPolicy is deprecated in Kubernetes v1.21 or later, unavailable in v1.25 or later
##
pspEnabled: true
## @param rbac.rules Custom RBAC rules to set
## e.g:
## rules:
## - apiGroups:
## - ""
## resources:
## - pods
## verbs:
## - get
## - list
##
rules: []

## Service account for kube-state-metrics to use.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
## @param serviceAccount.create Specifies whether a ServiceAccount should be created
Expand Down Expand Up @@ -255,6 +268,14 @@ kubeResources:
verticalpodautoscalers: false
validatingwebhookconfigurations: false
volumeattachments: true
## Configure custom resource state metrics
## ref: https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md
## @param customResourceState.enabled Enabled custom resource state metrics
## @param customResourceState.configuration Configuration of the CustomResourceStateMetrics to be added. Evaluated as a template.
customResourceState:
enabled: false
configuration: {}
##
## Configure Pods Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
## @param podSecurityContext.enabled Enabled kube-state-metrics pods' Security Context
Expand Down

0 comments on commit 23a8a63

Please sign in to comment.