mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
Add suport for prometheus 2.1 (#2767)
* Add suport for prometheus 2.0 Most changes are in the configmap due to the new rules format and the different method of setting the alertmanager target. Migration notes: https://prometheus.io/docs/prometheus/latest/migration/ * Use auto discovery for finding the alertmanager. Add instructions for upgrading from previous chart versions. Removed Values.alertmanagerHostname. If using an external alertmanager you can set the host in prometheus.yml * Add migration instructions in order to keep your existing data * Update node-exporter image version * Don't run prometheus as root Use an init container to give the prometheus user access to the data volume instead. Update image tags in the readme. * Upgrade to prometheus 2.1
This commit is contained in:
committed by
k8s-ci-robot
parent
f8fd3fba9c
commit
7d5a3ff4b1
@@ -1,5 +1,5 @@
|
||||
name: prometheus
|
||||
version: 4.6.18
|
||||
version: 5.0.0
|
||||
description: Prometheus is a monitoring system and time series database.
|
||||
home: https://prometheus.io/
|
||||
icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png
|
||||
|
||||
@@ -38,6 +38,54 @@ $ helm delete my-release
|
||||
|
||||
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
||||
|
||||
## Prometheus 2.x
|
||||
|
||||
Prometheus version 2.x has made changes to alertmanager, storage and recording rules. Check out the migration guide [here](https://prometheus.io/docs/prometheus/2.0/migration/)
|
||||
|
||||
Users of this chart will need to update their alerting rules to the new format before they can upgrade.
|
||||
|
||||
## Upgrading from previous chart versions.
|
||||
|
||||
As of version 5.0, this chart uses Prometheus 2.1. This version of prometheus introduces a new data format and is not compatible with prometheus 1.x. It is recommended to install this as a new release, as updating existing releases will not work. See the [prometheus docs](https://prometheus.io/docs/prometheus/latest/migration/#storage) for instructions on retaining your old data.
|
||||
|
||||
### Example migration
|
||||
|
||||
Assuming you have an existing release of the prometheus chart, named `prometheus-old`. In order to update to prometheus 2.1 while keeping your old data do the following:
|
||||
|
||||
1. Update the `prometheus-old` release. Disable scraping and every component besides the prometheus server, similar to the configuration below:
|
||||
|
||||
```
|
||||
alertmanager:
|
||||
enabled: false
|
||||
alertmanagerFiles:
|
||||
alertmanager.yml: ""
|
||||
kubeStateMetrics:
|
||||
enabled: false
|
||||
nodeExporter:
|
||||
enabled: false
|
||||
pushgateway:
|
||||
enabled: false
|
||||
server:
|
||||
extraArgs:
|
||||
storage.local.retention: 720h
|
||||
serverFiles:
|
||||
alerts: ""
|
||||
prometheus.yml: ""
|
||||
rules: ""
|
||||
```
|
||||
|
||||
1. Deploy a new release of the chart with version 5.0+ using prometheus 2.x. In the values.yaml set the scrape config as usual, and also add the `prometheus-old` instance as a remote-read target.
|
||||
|
||||
```
|
||||
prometheus.yml: |
|
||||
...
|
||||
remote_read:
|
||||
- url: http://prometheus-old/api/v1/read
|
||||
...
|
||||
```
|
||||
|
||||
Old data will be available when you query the new prometheus instance.
|
||||
|
||||
## Configuration
|
||||
|
||||
The following tables lists the configurable parameters of the Prometheus chart and their default values.
|
||||
@@ -47,10 +95,10 @@ Parameter | Description | Default
|
||||
`alertmanager.enabled` | If true, create alertmanager | `true`
|
||||
`alertmanager.name` | alertmanager container name | `alertmanager`
|
||||
`alertmanager.image.repository` | alertmanager container image repository | `prom/alertmanager`
|
||||
`alertmanager.image.tag` | alertmanager container image tag | `v0.5.1`
|
||||
`alertmanager.image.tag` | alertmanager container image tag | `v0.13.0`
|
||||
`alertmanager.image.pullPolicy` | alertmanager container image pull policy | `IfNotPresent`
|
||||
`alertmanager.prefixURL` | The prefix slug at which the server can be accessed | ``
|
||||
`alertmanager.baseURL` | The external url at which the server can be accessed | ``
|
||||
`alertmanager.baseURL` | The external url at which the server can be accessed | `/`
|
||||
`alertmanager.extraArgs` | Additional alertmanager container arguments | `{}`
|
||||
`alertmanager.configMapOverrideName` | Prometheus alertmanager ConfigMap override where full-name is `{{.Release.Name}}-{{.Values.alertmanager.configMapOverrideName}}` and setting this value will prevent the default alertmanager ConfigMap from being generated | `""`
|
||||
`alertmanager.ingress.enabled` | If true, alertmanager Ingress will be created | `false`
|
||||
@@ -86,7 +134,7 @@ Parameter | Description | Default
|
||||
`kubeStateMetrics.enabled` | If true, create kube-state-metrics | `true`
|
||||
`kubeStateMetrics.name` | kube-state-metrics container name | `kube-state-metrics`
|
||||
`kubeStateMetrics.image.repository` | kube-state-metrics container image repository| `k8s.gcr.io/kube-state-metrics`
|
||||
`kubeStateMetrics.image.tag` | kube-state-metrics container image tag | `v0.4.1`
|
||||
`kubeStateMetrics.image.tag` | kube-state-metrics container image tag | `v1.1.0`
|
||||
`kubeStateMetrics.image.pullPolicy` | kube-state-metrics container image pull policy | `IfNotPresent`
|
||||
`kubeStateMetrics.args` | kube-state-metrics container arguments | `{}`
|
||||
`kubeStateMetrics.nodeSelector` | node labels for kube-state-metrics pod assignment | `{}`
|
||||
@@ -104,7 +152,7 @@ Parameter | Description | Default
|
||||
`nodeExporter.enabled` | If true, create node-exporter | `true`
|
||||
`nodeExporter.name` | node-exporter container name | `node-exporter`
|
||||
`nodeExporter.image.repository` | node-exporter container image repository| `prom/node-exporter`
|
||||
`nodeExporter.image.tag` | node-exporter container image tag | `v0.13.0`
|
||||
`nodeExporter.image.tag` | node-exporter container image tag | `v0.15.2`
|
||||
`nodeExporter.image.pullPolicy` | node-exporter container image pull policy | `IfNotPresent`
|
||||
`nodeExporter.extraArgs` | Additional node-exporter container arguments | `{}`
|
||||
`nodeExporter.extraHostPathMounts` | Additional node-exporter hostPath mounts | `[]`
|
||||
@@ -144,9 +192,8 @@ Parameter | Description | Default
|
||||
`rbac.create` | If true, create & use RBAC resources | `false`
|
||||
`server.name` | Prometheus server container name | `server`
|
||||
`server.image.repository` | Prometheus server container image repository | `prom/prometheus`
|
||||
`server.image.tag` | Prometheus server container image tag | `v1.5.1`
|
||||
`server.image.tag` | Prometheus server container image tag | `v2.1.0`
|
||||
`server.image.pullPolicy` | Prometheus server container image pull policy | `IfNotPresent`
|
||||
`server.alertmanagerURL` | (optional) alertmanager URL; only used if alertmanager.enabled = false | `""`
|
||||
`server.extraArgs` | Additional Prometheus server container arguments | `{}`
|
||||
`server.prefixURL` | The prefix slug at which the server can be accessed | ``
|
||||
`server.baseURL` | The external url at which the server can be accessed | ``
|
||||
@@ -180,8 +227,8 @@ Parameter | Description | Default
|
||||
`server.service.type` | type of Prometheus server service to create | `ClusterIP`
|
||||
`server.terminationGracePeriodSeconds` | Prometheus server Pod termination grace period | `300`
|
||||
`server.retention` | (optional) Prometheus data retention | `""`
|
||||
`serverFiles.alerts` | Prometheus server alerts configuration | `""`
|
||||
`serverFiles.rules` | Prometheus server rules configuration | `""`
|
||||
`serverFiles.alerts` | Prometheus server alerts configuration | `{}`
|
||||
`serverFiles.rules` | Prometheus server rules configuration | `{}`
|
||||
`serverFiles.prometheus.yml` | Prometheus server scrape configuration | example configuration
|
||||
`networkPolicy.enabled` | Enable NetworkPolicy | `false` |
|
||||
|
||||
|
||||
@@ -10,5 +10,33 @@ metadata:
|
||||
release: {{ .Release.Name }}
|
||||
name: {{ template "prometheus.server.fullname" . }}
|
||||
data:
|
||||
{{ toYaml .Values.serverFiles | indent 2 }}
|
||||
{{- end }}
|
||||
{{- $root := . -}}
|
||||
{{- range $key, $value := .Values.serverFiles }}
|
||||
{{ $key }}: |
|
||||
{{ toYaml $value | default "{}" | indent 4 }}
|
||||
{{- if eq $key "prometheus.yml" -}}
|
||||
{{- if $root.Values.alertmanager.enabled -}}
|
||||
alerting:
|
||||
alertmanagers:
|
||||
- kubernetes_sd_configs:
|
||||
- role: pod
|
||||
tls_config:
|
||||
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
relabel_configs:
|
||||
- source_labels: [__meta_kubernetes_namespace]
|
||||
regex: {{ $root.Release.Namespace }}
|
||||
action: keep
|
||||
- source_labels: [__meta_kubernetes_pod_label_app]
|
||||
regex: prometheus
|
||||
action: keep
|
||||
- source_labels: [__meta_kubernetes_pod_label_component]
|
||||
regex: alertmanager
|
||||
action: keep
|
||||
- source_labels: [__meta_kubernetes_pod_container_port_number]
|
||||
regex:
|
||||
action: drop
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -26,6 +26,15 @@ spec:
|
||||
release: {{ .Release.Name }}
|
||||
spec:
|
||||
serviceAccountName: {{ if .Values.rbac.create }}{{ template "prometheus.server.fullname" . }}{{ else }}"{{ .Values.server.serviceAccountName }}"{{ end }}
|
||||
initContainers:
|
||||
- name: "init-chown-data"
|
||||
image: "busybox"
|
||||
# 65534 is the nobody user that prometheus uses.
|
||||
command: ["chown", "-R", "65534:65534", "{{ .Values.server.persistentVolume.mountPath }}"]
|
||||
volumeMounts:
|
||||
- name: storage-volume
|
||||
mountPath: {{ .Values.server.persistentVolume.mountPath }}
|
||||
subPath: "{{ .Values.server.persistentVolume.subPath }}"
|
||||
containers:
|
||||
- name: {{ template "prometheus.name" . }}-{{ .Values.server.name }}-{{ .Values.configmapReload.name }}
|
||||
image: "{{ .Values.configmapReload.image.repository }}:{{ .Values.configmapReload.image.tag }}"
|
||||
@@ -44,16 +53,14 @@ spec:
|
||||
image: "{{ .Values.server.image.repository }}:{{ .Values.server.image.tag }}"
|
||||
imagePullPolicy: "{{ .Values.server.image.pullPolicy }}"
|
||||
args:
|
||||
{{- if or .Values.alertmanager.enabled .Values.server.alertmanagerURL }}
|
||||
- --alertmanager.url={{- if .Values.alertmanager.enabled }}http://{{ template "prometheus.alertmanager.fullname" . }}:{{ .Values.alertmanager.service.servicePort }}{{ .Values.alertmanager.prefixURL }}{{- else }}{{ .Values.server.alertmanagerURL }}{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.server.retention }}
|
||||
- --storage.local.retention={{ .Values.server.retention }}
|
||||
- --storage.tsdb.retention={{ .Values.server.retention }}
|
||||
{{- end }}
|
||||
- --config.file=/etc/config/prometheus.yml
|
||||
- --storage.local.path={{ .Values.server.persistentVolume.mountPath }}
|
||||
- --storage.tsdb.path={{ .Values.server.persistentVolume.mountPath }}
|
||||
- --web.console.libraries=/etc/prometheus/console_libraries
|
||||
- --web.console.templates=/etc/prometheus/consoles
|
||||
- --web.enable-lifecycle
|
||||
{{- range $key, $value := .Values.server.extraArgs }}
|
||||
- --{{ $key }}={{ $value }}
|
||||
{{- end }}
|
||||
|
||||
@@ -17,7 +17,7 @@ alertmanager:
|
||||
##
|
||||
image:
|
||||
repository: prom/alertmanager
|
||||
tag: v0.9.1
|
||||
tag: v0.13.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
## Additional alertmanager container arguments
|
||||
@@ -31,7 +31,7 @@ alertmanager:
|
||||
|
||||
## External URL which can access alertmanager
|
||||
## Maybe same with Ingress host name
|
||||
baseURL: ""
|
||||
baseURL: "/"
|
||||
|
||||
## Additional alertmanager container environment variable
|
||||
## For instance to add a http_proxy
|
||||
@@ -191,7 +191,7 @@ kubeStateMetrics:
|
||||
##
|
||||
image:
|
||||
repository: k8s.gcr.io/kube-state-metrics
|
||||
tag: v1.1.0-rc.0
|
||||
tag: v1.1.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
## kube-state-metrics container arguments
|
||||
@@ -253,7 +253,7 @@ nodeExporter:
|
||||
##
|
||||
image:
|
||||
repository: prom/node-exporter
|
||||
tag: v0.15.0
|
||||
tag: v0.15.2
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
## Custom Update Strategy
|
||||
@@ -332,13 +332,9 @@ server:
|
||||
##
|
||||
image:
|
||||
repository: prom/prometheus
|
||||
tag: v1.8.1
|
||||
tag: v2.1.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
## (optional) alertmanager URL
|
||||
## only used if alertmanager.enabled = false
|
||||
alertmanagerURL: ""
|
||||
|
||||
## The URL prefix at which the container can be accessed. Useful in the case the '-web.external-url' includes a slug
|
||||
## so that the various internal URLs are still able to access as they are in the default case.
|
||||
## (Optional)
|
||||
@@ -598,10 +594,10 @@ alertmanagerFiles:
|
||||
## Prometheus server ConfigMap entries
|
||||
##
|
||||
serverFiles:
|
||||
alerts: ""
|
||||
rules: ""
|
||||
alerts: {}
|
||||
rules: {}
|
||||
|
||||
prometheus.yml: |-
|
||||
prometheus.yml:
|
||||
rule_files:
|
||||
- /etc/config/rules
|
||||
- /etc/config/alerts
|
||||
|
||||
Reference in New Issue
Block a user