Skip to content

Commit

Permalink
[prometheus] Support retention size, attach volume labels to PVC (#3985)
Browse files Browse the repository at this point in the history
* Remove unused helper template prometheus.daemonset.apiVersion

Signed-off-by: zeritti <[email protected]>

* Attach labels to standalone PVC

Signed-off-by: zeritti <[email protected]>

* Minor corrections in comments

Signed-off-by: zeritti <[email protected]>

* Do not render resources unless set

Signed-off-by: zeritti <[email protected]>

* Update values schema

Signed-off-by: zeritti <[email protected]>

* Add support for data retention size

Signed-off-by: zeritti <[email protected]>

* Bump chart version

Signed-off-by: zeritti <[email protected]>

* Insert commonMetaLabels in values file

Signed-off-by: zeritti <[email protected]>

* Add header to values file

Signed-off-by: zeritti <[email protected]>

* Bump chart version

Signed-off-by: zeritti <[email protected]>

---------

Signed-off-by: zeritti <[email protected]>
Co-authored-by: MH <[email protected]>
  • Loading branch information
zeritti and zanhsieh authored Nov 12, 2023
1 parent dd9d5d7 commit 26ff0a7
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 15 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: prometheus
appVersion: v2.47.2
version: 25.5.0
version: 25.6.0
kubeVersion: ">=1.19.0-0"
description: Prometheus is a monitoring system and time series database.
home: https://prometheus.io/
Expand Down
10 changes: 4 additions & 6 deletions charts/prometheus/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ Return the appropriate apiVersion for deployment.
{{- define "prometheus.deployment.apiVersion" -}}
{{- print "apps/v1" -}}
{{- end -}}
{{/*
Return the appropriate apiVersion for daemonset.
*/}}
{{- define "prometheus.daemonset.apiVersion" -}}
{{- print "apps/v1" -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for networkpolicy.
*/}}
Expand All @@ -133,6 +128,7 @@ Return the appropriate apiVersion for poddisruptionbudget.
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for rbac.
*/}}
Expand All @@ -143,6 +139,7 @@ Return the appropriate apiVersion for rbac.
{{- print "rbac.authorization.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
Expand All @@ -169,6 +166,7 @@ Return if ingress supports ingressClassName.
{{- define "ingress.supportsIngressClassName" -}}
{{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18.x" (include "prometheus.kubeVersion" .))) -}}
{{- end -}}

{{/*
Return if ingress supports pathType.
*/}}
Expand Down
11 changes: 9 additions & 2 deletions charts/prometheus/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ spec:
ports:
- containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
{{- end }}
{{- with .Values.configmapReload.prometheus.resources }}
resources:
{{ toYaml .Values.configmapReload.prometheus.resources | indent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config-volume
mountPath: /etc/config
Expand Down Expand Up @@ -123,6 +125,9 @@ spec:
{{- else }}
{{- if .Values.server.retention }}
- --storage.tsdb.retention.time={{ .Values.server.retention }}
{{- end }}
{{- if .Values.server.retentionSize }}
- --storage.tsdb.retention.size={{ .Values.server.retentionSize }}
{{- end }}
- --config.file={{ .Values.server.configPath }}
{{- if .Values.server.storagePath }}
Expand Down Expand Up @@ -213,8 +218,10 @@ spec:
periodSeconds: {{ .Values.server.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.server.startupProbe.timeoutSeconds }}
{{- end }}
{{- with .Values.server.resources }}
resources:
{{ toYaml .Values.server.resources | indent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config-volume
mountPath: /etc/config
Expand Down
3 changes: 3 additions & 0 deletions charts/prometheus/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
{{- end }}
labels:
{{- include "prometheus.server.labels" . | nindent 4 }}
{{- with .Values.server.persistentVolume.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ template "prometheus.server.fullname" . }}
namespace: {{ include "prometheus.namespace" . }}
spec:
Expand Down
11 changes: 9 additions & 2 deletions charts/prometheus/templates/sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ spec:
ports:
- containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
{{- end }}
{{- with .Values.configmapReload.prometheus.resources }}
resources:
{{ toYaml .Values.configmapReload.prometheus.resources | indent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config-volume
mountPath: /etc/config
Expand Down Expand Up @@ -128,6 +130,9 @@ spec:
{{- end }}
{{- if .Values.server.retention }}
- --storage.tsdb.retention.time={{ .Values.server.retention }}
{{- end }}
{{- if .Values.server.retentionSize }}
- --storage.tsdb.retention.size={{ .Values.server.retentionSize }}
{{- end }}
- --config.file={{ .Values.server.configPath }}
{{- if .Values.server.storagePath }}
Expand Down Expand Up @@ -215,8 +220,10 @@ spec:
periodSeconds: {{ .Values.server.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.server.startupProbe.timeoutSeconds }}
{{- end }}
{{- with .Values.server.resources }}
resources:
{{ toYaml .Values.server.resources | indent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config-volume
mountPath: /etc/config
Expand Down
9 changes: 9 additions & 0 deletions charts/prometheus/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@
}
}
},
"portName": {
"type": "string"
},
"prefixURL": {
"type": "string"
},
Expand Down Expand Up @@ -463,6 +466,9 @@
"retention": {
"type": "string"
},
"retentionSize": {
"type": "string"
},
"revisionHistoryLimit": {
"type": "integer"
},
Expand All @@ -486,6 +492,9 @@
"service": {
"type": "object",
"properties": {
"additionalPorts": {
"type": "array"
},
"annotations": {
"type": "object"
},
Expand Down
21 changes: 17 additions & 4 deletions charts/prometheus/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# yaml-language-server: $schema=values.schema.json
# Default values for prometheus.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

rbac:
create: true

Expand All @@ -16,6 +21,9 @@ serviceAccounts:
annotations: {}
# automountServiceAccountToken:

## Additional labels to attach to all resources
commonMetaLabels: {}

## Monitors ConfigMap changes and POSTs to a URL
## Ref: https://github.com/prometheus-operator/prometheus-operator/tree/main/cmd/prometheus-config-reloader
##
Expand Down Expand Up @@ -198,6 +206,7 @@ server:
# List of flags to override default parameters, e.g:
# - --enable-feature=agent
# - --storage.agent.retention.max-time=30m
# - --config.file=/etc/config/prometheus.yml
defaultFlagsOverride: []

extraFlags:
Expand Down Expand Up @@ -364,7 +373,7 @@ server:
# - "example.com"

## Node tolerations for server scheduling to nodes with taints
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
##
tolerations: []
# - key: "key"
Expand All @@ -373,7 +382,7 @@ server:
# effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)"

## Node labels for Prometheus server pod assignment
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
##
nodeSelector: {}

Expand Down Expand Up @@ -679,6 +688,10 @@ server:
##
retention: "15d"

## Prometheus' data retention size. Supported units: B, KB, MB, GB, TB, PB, EB.
##
retentionSize: ""

## Prometheus server ConfigMap entries for rule files (allow prometheus labels interpolation)
ruleFiles: {}

Expand Down Expand Up @@ -1206,7 +1219,7 @@ kube-state-metrics:
##
enabled: true

## promtheus-node-exporter sub-chart configurable values
## prometheus-node-exporter sub-chart configurable values
## Please see https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-node-exporter
##
prometheus-node-exporter:
Expand All @@ -1220,7 +1233,7 @@ prometheus-node-exporter:
containerSecurityContext:
allowPrivilegeEscalation: false

## pprometheus-pushgateway sub-chart configurable values
## prometheus-pushgateway sub-chart configurable values
## Please see https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-pushgateway
##
prometheus-pushgateway:
Expand Down

0 comments on commit 26ff0a7

Please sign in to comment.