[bitnami/prometheus-operator] Add Thanos sidecar container (#1890)

[bitnami/prometheus-operator] Add Thanos sidecar container

Signed-off-by: juan131 <juan@bitnami.com>
This commit is contained in:
Juan Ariza Toledano
2020-02-07 09:33:19 +01:00
committed by GitHub
parent bd035aafe9
commit 87c4ca57ba
8 changed files with 271 additions and 75 deletions

View File

@@ -2,7 +2,7 @@ apiVersion: v1
appVersion: 0.35.1
description: The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of Prometheus instances.
name: prometheus-operator
version: 0.11.2
version: 0.12.0
keywords:
- prometheus
- alertmanager

View File

@@ -141,76 +141,89 @@ The following table lists the configurable parameters of the Prometheus Operator
### Prometheus Parameters
| Parameter | Description | Default |
|-----------------------------------------------|--------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| `prometheus.enabled` | Deploy Prometheus to the cluster | `true` |
| `prometheus.image.registry` | Prometheus image registry | `docker.io` |
| `prometheus.image.repository` | Prometheus Image name | `bitnami/prometheus` |
| `prometheus.image.tag` | Prometheus Image tag | `{TAG_NAME}` |
| `prometheus.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
| `prometheus.serviceAccount.create` | Specify whether to create a ServiceAccount for Prometheus | `true` |
| `prometheus.serviceAccount.name` | The name of the ServiceAccount to create | Generated using the `prometheus-operator.prometheus.fullname` template |
| `prometheus.securityContext.enabled` | Enable security context | `true` |
| `prometheus.securityContext.fsGroup` | Group ID for the container filesystem | `1001` |
| `prometheus.securityContext.runAsUser` | User ID for the container | `1001` |
| `prometheus.podDisruptionBudget.enabled` | Create a pod disruption budget for Prometheus | `true` |
| `prometheus.podDisruptionBudget.minAvailable` | Minimum number / percentage of pods that should remain scheduled | `1` |
| `prometheus.podDisruptionBudget.minAvailable` | Maximum number / percentage of pods that may be made unavailable | `nil` |
| `prometheus.service.type` | Kubernetes service type | `ClusterIP` |
| `prometheus.service.port` | Prometheus service port | `9090` |
| `prometheus.service.clusterIP` | Specific cluster IP when service type is cluster IP. Use `None` for headless service | `nil` |
| `prometheus.service.nodePort` | Kubernetes Service nodePort | `nil` |
| `prometheus.service.loadBalancerIP` | `loadBalancerIP` if service type is `LoadBalancer` | `nil` |
| `prometheus.service.loadBalancerSourceRanges` | Address that are allowed when svc is `LoadBalancer` | `[]` |
| `prometheus.service.annotations` | Additional annotations for Prometheus service | `{}` |
| `prometheus.serviceMonitor.enabled` | Creates a ServiceMonitor to monitor Prometheus itself | `true` |
| `prometheus.serviceMonitor.interval` | Scrape interval (use by default, falling back to Prometheus' default) | `nil` |
| `prometheus.serviceMonitor.metricRelabelings` | Metric relabeling | `[]` |
| `prometheus.serviceMonitor.relabelings` | Relabel configs | `[]` |
| `prometheus.ingress.enabled` | Enable ingress controller resource | `false` |
| `prometheus.ingress.certManager` | Add annotations for cert-manager | `false` |
| `prometheus.ingress.annotations` | Ingress annotations | `[]` |
| `prometheus.ingress.hosts[0].name` | Hostname to your Prometheus installation | `prometheus.local` |
| `prometheus.ingress.hosts[0].path` | Path within the url structure | `/` |
| `prometheus.ingress.tls[0].hosts[0]` | TLS hosts | `prometheus.local` |
| `prometheus.ingress.tls[0].secretName` | TLS Secret (certificates) | `prometheus.local-tls` |
| `prometheus.resources` | CPU/Memory resource requests/limits for node | `{}` |
| `prometheus.nodeAffinity` | Node Affinity (this value is evaluated as a template) | `{}` |
| `prometheus.podAntiAffinity` | Pod anti-affinity policy | `soft` |
| `prometheus.podAffinity` | Affinity, in addition to antiAffinity (this value is evaluated as a template) | `{}` |
| `prometheus.nodeSelector` | Node labels for pod assignment (this value is evaluated as a template) | `{}` |
| `prometheus.tolerations` | List of node taints to tolerate (this value is evaluated as a template) | `[]` |
| `prometheus.replicaCount` | Number of Prometheus replicas desired | `1` |
| `prometheus.logLevel` | Log level for Prometheus | `info` |
| `prometheus.logFormat` | Log format for Prometheus | `logfmt` |
| `prometheus.podMetadata` | Standard objects metadata | `{}` |
| `prometheus.scrapeInterval` | Interval between consecutive scrapes | `` |
| `prometheus.evaluationInterval` | Interval between consecutive evaluations | `` |
| `prometheus.listenLocal` | ListenLocal makes the Prometheus server listen on loopback | `false` |
| `prometheus.enableAdminAPI` | Enable Prometheus adminitrative API | `false` |
| `prometheus.alertingEndpoints` | Alertmanagers to which alerts will be sent | `[]` |
| `prometheus.externalLabels` | External labels to add to any time series | `{}` |
| `prometheus.replicaExternalLabelName` | Name of the external label used to denote replica name | `` |
| `prometheus.replicaExternalLabelNameClear` | Clear external label used to denote replica name | `false` |
| `prometheus.prometheusExternalLabelName` | Name of the external label used to denote Prometheus instance name | `` |
| `prometheus.prometheusExternalLabelNameClear` | Clear external label used to denote Prometheus instance name | `false` |
| `prometheus.secrets` | Secrets that should be mounted into the Prometheus Pods | `[]` |
| `prometheus.configMaps` | ConfigMaps that should be mounted into the Prometheus Pods | `[]` |
| `prometheus.querySpec` | The query command line flags when starting Prometheus | `{}` |
| `prometheus.ruleNamespaceSelector` | Namespaces to be selected for PrometheusRules discovery | `{}` |
| `prometheus.ruleSelector` | PrometheusRules to be selected for target discovery | `{}` |
| `prometheus.serviceMonitorSelector` | If {}, select all ServiceMonitors | `{}` |
| `prometheus.serviceMonitorNamespaceSelector` | Namespaces to be selected for ServiceMonitor discovery | `{}` |
| `prometheus.retention` | Metrics retention days | `10d` |
| `prometheus.retentionSize` | Maximum size of metrics | `` |
| `prometheus.walCompression` | Enable compression of the write-ahead log using Snappy | `false` |
| `prometheus.paused` | If true, the Operator won't process any Prometheus configuration changes | `false` |
| `prometheus.remoteRead` | The remote_read spec configuration for Prometheus | `[]` |
| `prometheus.remoteWrite` | The remote_write spec configuration for Prometheus | `[]` |
| `prometheus.storageSpec` | Prometheus StorageSpec for persistent data | `{}` |
| `prometheus.priorityClassName` | Priority class assigned to the Pods | `` |
| `prometheus.containers` | Containers allows injecting additional containers | `[]` |
| `prometheus.additionalScrapeConfigsExternal` | Enable additional scrape configs that are managed externally to this chart | `false` See [docs](#additional-scrape-configurations) for details. |
| Parameter | Description | Default |
|------------------------------------------------------|--------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| `prometheus.enabled` | Deploy Prometheus to the cluster | `true` |
| `prometheus.image.registry` | Prometheus image registry | `docker.io` |
| `prometheus.image.repository` | Prometheus Image name | `bitnami/prometheus` |
| `prometheus.image.tag` | Prometheus Image tag | `{TAG_NAME}` |
| `prometheus.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
| `prometheus.serviceAccount.create` | Specify whether to create a ServiceAccount for Prometheus | `true` |
| `prometheus.serviceAccount.name` | The name of the ServiceAccount to create | Generated using the `prometheus-operator.prometheus.fullname` template |
| `prometheus.securityContext.enabled` | Enable security context | `true` |
| `prometheus.securityContext.fsGroup` | Group ID for the container filesystem | `1001` |
| `prometheus.securityContext.runAsUser` | User ID for the container | `1001` |
| `prometheus.podDisruptionBudget.enabled` | Create a pod disruption budget for Prometheus | `true` |
| `prometheus.podDisruptionBudget.minAvailable` | Minimum number / percentage of pods that should remain scheduled | `1` |
| `prometheus.podDisruptionBudget.minAvailable` | Maximum number / percentage of pods that may be made unavailable | `nil` |
| `prometheus.service.type` | Kubernetes service type | `ClusterIP` |
| `prometheus.service.port` | Prometheus service port | `9090` |
| `prometheus.service.clusterIP` | Specific cluster IP when service type is cluster IP. Use `None` for headless service | `nil` |
| `prometheus.service.nodePort` | Kubernetes Service nodePort | `nil` |
| `prometheus.service.loadBalancerIP` | `loadBalancerIP` if service type is `LoadBalancer` | `nil` |
| `prometheus.service.loadBalancerSourceRanges` | Address that are allowed when svc is `LoadBalancer` | `[]` |
| `prometheus.service.annotations` | Additional annotations for Prometheus service | `{}` |
| `prometheus.serviceMonitor.enabled` | Creates a ServiceMonitor to monitor Prometheus itself | `true` |
| `prometheus.serviceMonitor.interval` | Scrape interval (use by default, falling back to Prometheus' default) | `nil` |
| `prometheus.serviceMonitor.metricRelabelings` | Metric relabeling | `[]` |
| `prometheus.serviceMonitor.relabelings` | Relabel configs | `[]` |
| `prometheus.ingress.enabled` | Enable ingress controller resource | `false` |
| `prometheus.ingress.certManager` | Add annotations for cert-manager | `false` |
| `prometheus.ingress.annotations` | Ingress annotations | `[]` |
| `prometheus.ingress.hosts[0].name` | Hostname to your Prometheus installation | `prometheus.local` |
| `prometheus.ingress.hosts[0].path` | Path within the url structure | `/` |
| `prometheus.ingress.tls[0].hosts[0]` | TLS hosts | `prometheus.local` |
| `prometheus.ingress.tls[0].secretName` | TLS Secret (certificates) | `prometheus.local-tls` |
| `prometheus.resources` | CPU/Memory resource requests/limits for node | `{}` |
| `prometheus.nodeAffinity` | Node Affinity (this value is evaluated as a template) | `{}` |
| `prometheus.podAntiAffinity` | Pod anti-affinity policy | `soft` |
| `prometheus.podAffinity` | Affinity, in addition to antiAffinity (this value is evaluated as a template) | `{}` |
| `prometheus.nodeSelector` | Node labels for pod assignment (this value is evaluated as a template) | `{}` |
| `prometheus.tolerations` | List of node taints to tolerate (this value is evaluated as a template) | `[]` |
| `prometheus.replicaCount` | Number of Prometheus replicas desired | `1` |
| `prometheus.logLevel` | Log level for Prometheus | `info` |
| `prometheus.logFormat` | Log format for Prometheus | `logfmt` |
| `prometheus.podMetadata` | Standard objects metadata | `{}` |
| `prometheus.scrapeInterval` | Interval between consecutive scrapes | `` |
| `prometheus.evaluationInterval` | Interval between consecutive evaluations | `` |
| `prometheus.listenLocal` | ListenLocal makes the Prometheus server listen on loopback | `false` |
| `prometheus.enableAdminAPI` | Enable Prometheus adminitrative API | `false` |
| `prometheus.alertingEndpoints` | Alertmanagers to which alerts will be sent | `[]` |
| `prometheus.externalLabels` | External labels to add to any time series | `{}` |
| `prometheus.replicaExternalLabelName` | Name of the external label used to denote replica name | `` |
| `prometheus.replicaExternalLabelNameClear` | Clear external label used to denote replica name | `false` |
| `prometheus.prometheusExternalLabelName` | Name of the external label used to denote Prometheus instance name | `` |
| `prometheus.prometheusExternalLabelNameClear` | Clear external label used to denote Prometheus instance name | `false` |
| `prometheus.secrets` | Secrets that should be mounted into the Prometheus Pods | `[]` |
| `prometheus.configMaps` | ConfigMaps that should be mounted into the Prometheus Pods | `[]` |
| `prometheus.querySpec` | The query command line flags when starting Prometheus | `{}` |
| `prometheus.ruleNamespaceSelector` | Namespaces to be selected for PrometheusRules discovery | `{}` |
| `prometheus.ruleSelector` | PrometheusRules to be selected for target discovery | `{}` |
| `prometheus.serviceMonitorSelector` | If {}, select all ServiceMonitors | `{}` |
| `prometheus.serviceMonitorNamespaceSelector` | Namespaces to be selected for ServiceMonitor discovery | `{}` |
| `prometheus.retention` | Metrics retention days | `10d` |
| `prometheus.retentionSize` | Maximum size of metrics | `` |
| `prometheus.walCompression` | Enable compression of the write-ahead log using Snappy | `false` |
| `prometheus.paused` | If true, the Operator won't process any Prometheus configuration changes | `false` |
| `prometheus.remoteRead` | The remote_read spec configuration for Prometheus | `[]` |
| `prometheus.remoteWrite` | The remote_write spec configuration for Prometheus | `[]` |
| `prometheus.storageSpec` | Prometheus StorageSpec for persistent data | `{}` |
| `prometheus.priorityClassName` | Priority class assigned to the Pods | `` |
| `prometheus.containers` | Containers allows injecting additional containers | `[]` |
| `prometheus.additionalScrapeConfigsExternal` | Enable additional scrape configs that are managed externally to this chart | `false` See [docs](#additional-scrape-configurations) for details. |
| `prometheus.thanos.create` | Create a Thanos sidecar container | `false` |
| `prometheus.thanos.image.registry` | Thanos image registry | `docker.io` |
| `prometheus.thanos.image.repository` | Thanos image name | `bitnami/prometheus` |
| `prometheus.thanos.image.tag` | Thanos image tag | `{TAG_NAME}` |
| `prometheus.thanos.image.pullPolicy` | Thanos image pull policy | `IfNotPresent` |
| `prometheus.thanos.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
| `prometheus.thanos.service.port` | Thanos service port | `10901` |
| `prometheus.thanos.service.clusterIP` | Specific cluster IP when service type is cluster IP. Use `None` for headless service | `nil` |
| `prometheus.thanos.service.nodePort` | Kubernetes Service nodePort | `nil` |
| `prometheus.thanos.service.loadBalancerIP` | `loadBalancerIP` if service type is `LoadBalancer` | `nil` |
| `prometheus.thanos.service.loadBalancerSourceRanges` | Address that are allowed when svc is `LoadBalancer` | `[]` |
| `prometheus.thanos.service.annotations` | Additional annotations for Prometheus service | `{}` |
| `prometheus.serviceMonitor.enabled` | Creates a ServiceMonitor to monitor Prometheus itself | `true` |
### Alertmanager Parameters

View File

@@ -221,6 +221,29 @@ Also, we can't use a single if because lazy evaluation is not an option
{{- end -}}
{{- end -}}
{{/*
Return the proper Thanos Image name
*/}}
{{- define "prometheus-operator.prometheus.thanosImage" -}}
{{- $registryName := .Values.prometheus.thanos.image.registry -}}
{{- $repositoryName := .Values.prometheus.thanos.image.repository -}}
{{- $tag := .Values.prometheus.thanos.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Alertmanager BaseImage name
*/}}

View File

@@ -141,8 +141,28 @@ spec:
key: additional-scrape-configs.yaml
{{- end }}
{{- include "prometheus-operator.prometheus.imagePullSecrets" . | indent 2 }}
{{- if .Values.prometheus.containers }}
containers: {{- include "prometheus-operator.tplValue" (dict "value" .Values.prometheus.containers "context" $) | nindent 4 }}
{{- if or .Values.prometheus.containers .Values.prometheus.thanos.create }}
containers:
{{- if .Values.prometheus.thanos.create }}
- name: thanos-sidecar
image: {{ template "prometheus-operator.prometheus.thanosImage" . }}
imagePullPolicy: {{ .Values.prometheus.thanos.image.pullPolicy }}
args:
- sidecar
- --prometheus.url=http://localhost:9090
- --grpc-address=0.0.0.0:10901
- --http-address=0.0.0.0:10902
ports:
- name: grpc-thanos
containerPort: 10901
protocol: TCP
- name: http-thanos
containerPort: 10902
protocol: TCP
{{- end }}
{{- if .Values.prometheus.containers }}
{{- include "prometheus-operator.tplValue" (dict "value" .Values.prometheus.containers "context" $) | indent 4 }}
{{- end }}
{{- end }}
{{- if .Values.prometheus.priorityClassName }}
priorityClassName: {{ .Values.prometheus.priorityClassName }}

View File

@@ -4,8 +4,8 @@ kind: Service
metadata:
name: {{ template "prometheus-operator.prometheus.fullname" . }}
labels: {{- include "prometheus-operator.prometheus.labels" . | nindent 4 }}
{{- with .Values.prometheus.service.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- if .Values.prometheus.service.annotations }}
annotations: {{- include "prometheus-operator.tplValue" (dict "value" .Values.prometheus.service.annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.prometheus.service.type }}
@@ -24,6 +24,7 @@ spec:
- name: http
port: {{ .Values.prometheus.service.port }}
targetPort: 9090
protocol: TCP
{{- if and .Values.prometheus.service.nodePort (or (eq .Values.prometheus.service.type "NodePort") (eq .Values.prometheus.service.type "LoadBalancer")) }}
nodePort: {{ .Values.prometheus.service.nodePort }}
{{- end }}

View File

@@ -0,0 +1,35 @@
{{- if and .Values.prometheus.enabled .Values.prometheus.thanos.create }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "prometheus-operator.prometheus.fullname" . }}-thanos
labels: {{- include "prometheus-operator.prometheus.labels" . | nindent 4 }}
app.kubernetes.io/subcomponent: thanos
{{- if .Values.prometheus.thanos.service.annotations }}
annotations: {{- include "prometheus-operator.tplValue" (dict "value" .Values.prometheus.thanos.service.annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.prometheus.thanos.service.type }}
{{- if and .Values.prometheus.thanos.service.loadBalancerIP (eq .Values.prometheus.thanos.service.type "LoadBalancer") }}
loadBalancerIP: {{ .Values.prometheus.thanos.service.loadBalancerIP }}
{{- end }}
{{- if and (eq .Values.prometheus.thanos.service.type "LoadBalancer") .Values.prometheus.thanos.service.loadBalancerSourceRanges }}
{{- with .Values.prometheus.thanos.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if and (eq .Values.prometheus.thanos.service.type "ClusterIP") .Values.prometheus.thanos.service.clusterIP }}
clusterIP: {{ .Values.prometheus.thanos.service.clusterIP }}
{{- end }}
ports:
- name: grpc-thanos
port: {{ .Values.prometheus.thanos.service.port }}
targetPort: grpc-thanos
protocol: TCP
{{- if and .Values.prometheus.thanos.service.nodePort (or (eq .Values.prometheus.thanos.service.type "NodePort") (eq .Values.prometheus.thanos.service.type "LoadBalancer")) }}
nodePort: {{ .Values.prometheus.thanos.service.nodePort }}
{{- end }}
selector:
app: prometheus
prometheus: {{ template "prometheus-operator.prometheus.fullname" . }}
{{- end }}

View File

@@ -526,6 +526,58 @@ prometheus:
##
additionalScrapeConfigsExternal: false
## Thanos sidecar container configuration
##
thanos:
## Create a Thanos Sidecar container
##
create: false
## Bitnami Thanos image
## ref: https://hub.docker.com/r/bitnami/thanos/tags/
##
image:
registry: docker.io
repository: bitnami/thanos
tag: 0.10.1-scratch-r0
## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets (secrets must be manually created in the namespace)
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
# pullSecrets:
# - myRegistryKeySecretName
## Thanos Sidecar Service
##
service:
## Kubernetes service type and port number
##
type: ClusterIP
port: 10901
# clusterIP: None
## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
# nodePort: 30901
## Set the LoadBalancer service type to internal only.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
##
# loadBalancerIP:
## Load Balancer sources
## https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service
##
# loadBalancerSourceRanges:
# - 10.10.10.0/24
## Provide any additional annotations which may be required.
##
annotations: {}
## Configuration for alertmanager
## ref: https://prometheus.io/docs/alerting/alertmanager/
##

View File

@@ -526,6 +526,58 @@ prometheus:
##
additionalScrapeConfigsExternal: false
## Thanos sidecar container configuration
##
thanos:
## Create a Thanos Sidecar container
##
create: false
## Bitnami Thanos image
## ref: https://hub.docker.com/r/bitnami/thanos/tags/
##
image:
registry: docker.io
repository: bitnami/thanos
tag: 0.10.1-scratch-r0
## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets (secrets must be manually created in the namespace)
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
# pullSecrets:
# - myRegistryKeySecretName
## Thanos Sidecar Service
##
service:
## Kubernetes service type and port number
##
type: ClusterIP
port: 10901
# clusterIP: None
## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
# nodePort: 30901
## Set the LoadBalancer service type to internal only.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
##
# loadBalancerIP:
## Load Balancer sources
## https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service
##
# loadBalancerSourceRanges:
# - 10.10.10.0/24
## Provide any additional annotations which may be required.
##
annotations: {}
## Configuration for alertmanager
## ref: https://prometheus.io/docs/alerting/alertmanager/
##