From 7c4bc743b8b09d84185dcf11586fc9578a209d91 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Fri, 25 Oct 2019 14:10:27 +0530 Subject: [PATCH] [bitnami/etcd] adds servicemonitor support Signed-off-by: Sameer Naik --- bitnami/etcd/Chart.yaml | 2 +- bitnami/etcd/README.md | 13 ++++++--- bitnami/etcd/templates/servicemonitor.yaml | 34 ++++++++++++++++++++++ bitnami/etcd/values-production.yaml | 23 +++++++++++++++ bitnami/etcd/values.yaml | 24 +++++++++++++++ 5 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 bitnami/etcd/templates/servicemonitor.yaml diff --git a/bitnami/etcd/Chart.yaml b/bitnami/etcd/Chart.yaml index eee4385ee..b2f89ebce 100644 --- a/bitnami/etcd/Chart.yaml +++ b/bitnami/etcd/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: etcd -version: 4.3.13 +version: 4.4.0 appVersion: 3.4.3 description: etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines keywords: diff --git a/bitnami/etcd/README.md b/bitnami/etcd/README.md index 4e4ecda6c..81ecc652c 100644 --- a/bitnami/etcd/README.md +++ b/bitnami/etcd/README.md @@ -48,11 +48,11 @@ The command removes all the Kubernetes components associated with the chart and The following tables lists the configurable parameters of the etcd chart and their default values. -| Parameter | Description | Default | -| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | +| Parameter | Description | Default | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------| | `global.imageRegistry` | Global Docker image registry | `nil` | | `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | -| `global.storageClass` | Global storage class for dynamic provisioning | `nil` | +| `global.storageClass` | Global storage class for dynamic provisioning | `nil` | | `image.registry` | etcd image registry | `docker.io` | | `image.repository` | etcd image name | `bitnami/etcd` | | `image.tag` | etcd image tag | `{TAG_NAME}` | @@ -64,7 +64,7 @@ The following tables lists the configurable parameters of the etcd chart and the | `volumePermissions.enabled` | Enable init container that changes volume permissions in the data directory (for cases where the default k8s `runAsUser` and `fsUser` values do not work) | `false` | | `volumePermissions.image.registry` | Init container volume-permissions image registry | `docker.io` | | `volumePermissions.image.repository` | Init container volume-permissions image name | `bitnami/minideb` | -| `volumePermissions.image.tag` | Init container volume-permissions image tag | `stretch` | +| `volumePermissions.image.tag` | Init container volume-permissions image tag | `stretch` | | `volumePermissions.image.pullPolicy` | Init container volume-permissions image pull policy | `Always` | | `volumePermissions.resources` | Init container resource requests/limit | `nil` | | `statefulset.updateStrategy` | Update strategy for the stateful set | `RollingUpdate` | @@ -123,6 +123,11 @@ The following tables lists the configurable parameters of the etcd chart and the | `tolerations` | Tolerations for pod assignment. The value is evaluated as a template. | `{}` | | `metrics.enabled` | Enable Prometheus exporter to expose etcd metrics | `false` | | `metrics.podAnnotations` | Annotations for enabling prometheus to access the metrics endpoint | {`prometheus.io/scrape: "true",prometheus.io/port: "2379"`} | +| `metrics.serviceMonitor.enabled` | if `true`, creates a Prometheus Operator ServiceMonitor (also requires `metrics.enabled` to be `true`) | `false` | +| `metrics.serviceMonitor.namespace` | Namespace in which Prometheus is running | `nil` | +| `metrics.serviceMonitor.interval` | Interval at which metrics should be scraped. | `nil` (Prometheus Operator default value) | +| `metrics.serviceMonitor.scrapeTimeout` | Timeout after which the scrape is ended | `nil` (Prometheus Operator default value) | +| `metrics.serviceMonitor.selector` | Prometheus instance selector labels | `nil` | | `startFromSnapshot.enabled` | Initialize new cluster recovering an existing snapshot | `false` | | `startFromSnapshot.existingClaim` | PVC containing the existing snapshot | `nil` | | `startFromSnapshot.snapshotFilename` | Snapshot filename | `nil` | diff --git a/bitnami/etcd/templates/servicemonitor.yaml b/bitnami/etcd/templates/servicemonitor.yaml new file mode 100644 index 000000000..6f996165f --- /dev/null +++ b/bitnami/etcd/templates/servicemonitor.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "etcd.fullname" . }} + {{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace }} + {{- end }} + labels: + app.kubernetes.io/name: {{ template "etcd.name" . }} + helm.sh/chart: {{ template "etcd.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- range $key, $value := .Values.metrics.serviceMonitor.selector }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ template "etcd.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + endpoints: + - port: client + path: "/metrics" + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} +{{- end }} diff --git a/bitnami/etcd/values-production.yaml b/bitnami/etcd/values-production.yaml index 65036898e..fba3e675e 100644 --- a/bitnami/etcd/values-production.yaml +++ b/bitnami/etcd/values-production.yaml @@ -248,6 +248,29 @@ metrics: prometheus.io/scrape: "true" prometheus.io/port: "2379" + ## Prometheus Operator ServiceMonitor configuration + ## + serviceMonitor: + enabled: false + ## Namespace in which Prometheus is running + ## + # namespace: monitoring + + ## Interval at which metrics should be scraped. + ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint + ## + # interval: 10s + + ## Timeout after which the scrape is ended + ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint + ## + # scrapeTimeout: 10s + + ## ServiceMonitor selector labels + ## ref: https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#prometheus-configuration + ## + # selector: + ## Start a new etcd cluster recovering the data from an existing snaptshot before ## initializing the members ## diff --git a/bitnami/etcd/values.yaml b/bitnami/etcd/values.yaml index 2fb1a1cb3..4841dbb75 100644 --- a/bitnami/etcd/values.yaml +++ b/bitnami/etcd/values.yaml @@ -240,6 +240,30 @@ metrics: prometheus.io/scrape: "true" prometheus.io/port: "2379" + ## Prometheus Operator ServiceMonitor configuration + ## + serviceMonitor: + enabled: false + ## Namespace in which Prometheus is running + ## + # namespace: monitoring + + ## Interval at which metrics should be scraped. + ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint + ## + # interval: 10s + + ## Timeout after which the scrape is ended + ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint + ## + # scrapeTimeout: 10s + + ## ServiceMonitor selector labels + ## ref: https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#prometheus-configuration + ## + # selector: + # prometheus: my-prometheus + ## Start a new etcd cluster recovering the data from an existing snaptshot before ## initializing the members ##