Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheus] Support retention size, attach volume labels to PVC #3985

Merged
merged 12 commits into from
Nov 12, 2023
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