This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch prometheus
in repository https://gitbox.apache.org/repos/asf/couchdb-helm.git

commit 9609bb2841d4590f78c01140c7cd76eb21260b42
Author: Will Holley <[email protected]>
AuthorDate: Wed Nov 6 16:39:23 2019 +0000

    Add prometheus sidecar
---
 couchdb/Chart.yaml                 |   2 +-
 couchdb/README.md                  |  35 +++++++++++++++++++++++++++++++
 couchdb/templates/_helpers.tpl     |  13 ++++++++++++
 couchdb/templates/statefulset.yaml |  42 +++++++++++++++++++++++++++++++++++--
 couchdb/values.yaml                |  18 ++++++++++++++++
 docs/couchdb-2.5.0.tgz             | Bin 0 -> 8592 bytes
 docs/index.yaml                    |  33 ++++++++++++++++++++++++-----
 test/e2e-kind.sh                   |   6 ++++--
 8 files changed, 139 insertions(+), 10 deletions(-)

diff --git a/couchdb/Chart.yaml b/couchdb/Chart.yaml
index deb6de7..9a40d44 100644
--- a/couchdb/Chart.yaml
+++ b/couchdb/Chart.yaml
@@ -1,6 +1,6 @@
 apiVersion: v1
 name: couchdb
-version: 2.4.1
+version: 2.5.0
 appVersion: 2.3.1
 description: A database featuring seamless multi-master sync, that scales from
   big data to mobile, with an intuitive HTTP/JSON API and designed for
diff --git a/couchdb/README.md b/couchdb/README.md
index b48cd5b..b2b287e 100644
--- a/couchdb/README.md
+++ b/couchdb/README.md
@@ -106,6 +106,7 @@ CouchDB chart and their default values:
 | `persistentVolume.enabled`      | Boolean determining whether to attach a PV 
to each node | false
 | `persistentVolume.size`         | If enabled, the size of the persistent 
volume to attach                          | 10Gi
 | `enableSearch`                  | Adds a sidecar for Lucene-powered text 
search         | false                                  |
+| `telemetry.enabled`             | Adds a sidecar to expose CouchDB metrics 
to Prometheus| false                                  |
 
 A variety of other parameters are also configurable. See the comments in the
 `values.yaml` file for further details:
@@ -124,6 +125,9 @@ A variety of other parameters are also configurable. See 
the comments in the
 | `initImage.repository`            | busybox                                |
 | `initImage.tag`                   | latest                                 |
 | `initImage.pullPolicy`            | Always                                 |
+| `telemetryImage.repository`       | gesellix/couchdb-prometheus-exporter   |
+| `telemetryImage.tag`              | latest                                 |
+| `telemetryImage.pullPolicy`       | Always                                 |
 | `ingress.enabled`                 | false                                  |
 | `ingress.hosts`                   | chart-example.local                    |
 | `ingress.annotations`             |                                        |
@@ -145,6 +149,37 @@ A variety of other parameters are also configurable. See 
the comments in the
 | `serviceAccount.enabled`          | true                                   |
 | `serviceAccount.create`           | true                                   |
 | `serviceAccount.imagePullSecrets` |                                        |
+| `telemetry.databases`             |                                        |
+
+## Telemetry
+
+The chart optionally deploys the [CouchDB Prometheus 
exporter](https://github.com/gesellix/couchdb-prometheus-exporter) to each 
CouchDB node.
+Metrics are exposed on port 9984.
+
+Below is an example Prometheus scrape configuration that can be used to 
collect per-node CouchDB metrics:
+
+```
+- job_name: couchdb
+  scrape_interval: 10s
+  kubernetes_sd_configs:
+  - role: pod
+  relabel_configs:
+  - source_labels: [__meta_kubernetes_namespace]
+      action: replace
+      target_label: k8s_namespace
+  - source_labels: [__meta_kubernetes_pod_name]
+      action: replace
+      target_label: k8s_pod_name
+  - source_labels: [__address__]
+      action: replace
+      regex: ([^:]+)(?::\d+)?
+      replacement: ${1}:9984
+      target_label: __address__
+  - source_labels: [__meta_kubernetes_pod_label_app]
+      action: keep
+      regex: couchdb
+```
+
 
 ## Feedback, Issues, Contributing
 
diff --git a/couchdb/templates/_helpers.tpl b/couchdb/templates/_helpers.tpl
index 3a9288f..6f263a9 100644
--- a/couchdb/templates/_helpers.tpl
+++ b/couchdb/templates/_helpers.tpl
@@ -72,3 +72,16 @@ If serviceAccount.name is specified, use that, else use the 
couchdb instance nam
 {{- template "couchdb.fullname" . -}}
 {{- end -}}
 {{- end -}}
+
+{{/*
+In the event that we create both a headless service and a traditional one,
+ensure that the latter gets a unique name.
+*/}}
+{{- define "couchdb.telemetrysvcname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- printf "%s-telemetry-%s" .Values.fullnameOverride .Chart.Name | trunc 63 | 
trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- printf "%s-telemetry-%s" .Release.Name $name | trunc 63 | trimSuffix "-" 
-}}
+{{- end -}}
+{{- end -}}
diff --git a/couchdb/templates/statefulset.yaml 
b/couchdb/templates/statefulset.yaml
index 7c7b744..c9d4532 100644
--- a/couchdb/templates/statefulset.yaml
+++ b/couchdb/templates/statefulset.yaml
@@ -18,9 +18,13 @@ spec:
     metadata:
       labels:
 {{ include "couchdb.ss.selector" . | indent 8 }}
-{{- with .Values.annotations }}
       annotations:
-{{ toYaml . | indent 8 }}
+{{- with .Values.annotations }}
+{{- toYaml . | indent 8 }}
+{{- end }}
+{{- if .Values.telemetry.enabled }}
+        prometheus.io/scrape: 'true'
+        prometheus.io/port: '9984'
 {{- end }}
     spec:
       {{- if .Values.schedulerName }}
@@ -108,6 +112,40 @@ spec:
           - name: database-storage
             mountPath: /opt/couchdb-search/data
 {{- end }}
+{{- if .Values.telemetry.enabled }}
+        - name: telemetry
+          image: "{{ .Values.telemetryImage.repository }}:{{ 
.Values.telemetryImage.tag }}"
+          imagePullPolicy: {{ .Values.telemetryImage.pullPolicy }}
+          ports:
+            - name: telemetry
+              containerPort: 9984
+          args: ["--couchdb.uri=http://localhost:5984";]
+          livenessProbe:
+            httpGet:
+              path: /metrics
+              port: 9984
+          readinessProbe:
+            httpGet:
+              path: /metrics
+              port: 9984
+          resources:
+{{ toYaml .Values.telemetry.resources | indent 12 }}
+          env:
+            - name: DATABASES
+              value: {{ .Values.telemetry.databases }}
+{{- if not .Values.allowAdminParty }}
+            - name: "COUCHDB.USERNAME"
+              valueFrom:
+                secretKeyRef:
+                  name: {{ template "couchdb.fullname" . }}
+                  key: adminUsername
+            - name: "COUCHDB.PASSWORD"
+              valueFrom:
+                secretKeyRef:
+                  name: {{ template "couchdb.fullname" . }}
+                  key: adminPassword
+{{- end }}
+{{- end }}
 {{- if .Values.nodeSelector }}
       nodeSelector:
 {{ toYaml .Values.nodeSelector | indent 8 }}
diff --git a/couchdb/values.yaml b/couchdb/values.yaml
index f94faf7..57a259f 100644
--- a/couchdb/values.yaml
+++ b/couchdb/values.yaml
@@ -163,3 +163,21 @@ couchdbConfig:
 # This is used to generate FQDNs for peers when joining the CouchDB cluster.
 dns:
   clusterDomainSuffix: cluster.local
+
+# Adds a sidecar to expose CouchDB metrics as a prometheus endpoint
+# see 
https://github.com/gesellix/couchdb-prometheus-exporter/blob/master/README.md
+telemetryImage:
+  repository: gesellix/couchdb-prometheus-exporter
+  tag: latest
+  pullPolicy: Always
+telemetry:
+  enabled: false
+# Enable database-specific metrics. Comma delimited list of database names or 
"_all_dbs" for all.
+# databases: _all_dbs
+  resources:
+    requests:
+      cpu: 100m
+      memory: 128Mi
+    limits:
+      cpu: 1
+      memory: 1Gi
diff --git a/docs/couchdb-2.5.0.tgz b/docs/couchdb-2.5.0.tgz
new file mode 100644
index 0000000..ab91382
Binary files /dev/null and b/docs/couchdb-2.5.0.tgz differ
diff --git a/docs/index.yaml b/docs/index.yaml
index 1e3801a..a34f5da 100644
--- a/docs/index.yaml
+++ b/docs/index.yaml
@@ -3,7 +3,30 @@ entries:
   couchdb:
   - apiVersion: v1
     appVersion: 2.3.1
-    created: "2019-11-01T11:51:15.339935463+01:00"
+    created: 2019-11-06T16:36:51.999866Z
+    description: A database featuring seamless multi-master sync, that scales 
from
+      big data to mobile, with an intuitive HTTP/JSON API and designed for 
reliability.
+    digest: a9856ec04fd7ea4b04f6b6d7e582ad47ab71381b1b91f1de2230800480e45f94
+    home: https://couchdb.apache.org/
+    icon: 
http://couchdb.apache.org/CouchDB-visual-identity/logo/CouchDB-couch-symbol.svg
+    keywords:
+    - couchdb
+    - database
+    - nosql
+    maintainers:
+    - email: [email protected]
+      name: kocolosk
+    - email: [email protected]
+      name: willholley
+    name: couchdb
+    sources:
+    - https://github.com/apache/couchdb-docker
+    urls:
+    - https://apache.github.io/couchdb-helm/couchdb-2.5.0.tgz
+    version: 2.5.0
+  - apiVersion: v1
+    appVersion: 2.3.1
+    created: 2019-11-01T11:51:15.339935463+01:00
     description: A database featuring seamless multi-master sync, that scales 
from
       big data to mobile, with an intuitive HTTP/JSON API and designed for 
reliability.
     digest: db0815c2766f76049b58d0954b66e0b70bf673a7d11c1d3cd9e07c775c646c12
@@ -26,7 +49,7 @@ entries:
     version: 2.4.1
   - apiVersion: v1
     appVersion: 2.3.1
-    created: "2019-11-01T11:51:15.339429507+01:00"
+    created: 2019-11-01T11:51:15.339429507+01:00
     description: A database featuring seamless multi-master sync, that scales 
from
       big data to mobile, with an intuitive HTTP/JSON API and designed for 
reliability.
     digest: daddf6cc7fe8bb63d6fa8679565d4496d92c23d9ff85b19521fca74c6412bc11
@@ -49,7 +72,7 @@ entries:
     version: 2.4.0
   - apiVersion: v1
     appVersion: 2.3.1
-    created: "2019-11-01T11:51:15.333646851+01:00"
+    created: 2019-11-01T11:51:15.333646851+01:00
     description: A database featuring seamless multi-master sync, that scales 
from
       big data to mobile, with an intuitive HTTP/JSON API and designed for 
reliability.
     digest: 0eba7c20ec47bc8556b3cb3b5137b578d46b37397493087d61b8199066f84782
@@ -72,7 +95,7 @@ entries:
     version: 2.3.0
   - apiVersion: v1
     appVersion: 2.3.1
-    created: "2019-11-01T11:51:15.330535744+01:00"
+    created: 2019-11-01T11:51:15.330535744+01:00
     description: A database featuring seamless multi-master sync, that scales 
from
       big data to mobile, with an intuitive HTTP/JSON API and designed for 
reliability.
     digest: f68e6187c2b65a02fdde9d49ec38e76a68c3d82421e5ea9e599bac87f4193c6a
@@ -93,4 +116,4 @@ entries:
     urls:
     - https://apache.github.io/couchdb-helm/couchdb-2.2.0.tgz
     version: 2.2.0
-generated: "2019-11-01T11:51:15.321186109+01:00"
+generated: 2019-11-06T16:36:51.998874Z
diff --git a/test/e2e-kind.sh b/test/e2e-kind.sh
index 4cb57b4..a24d17b 100755
--- a/test/e2e-kind.sh
+++ b/test/e2e-kind.sh
@@ -4,7 +4,7 @@ set -o errexit
 set -o nounset
 set -o pipefail
 
-readonly CT_VERSION=v2.3.3
+readonly CT_VERSION=v2.4.0
 readonly KIND_VERSION=v0.5.1
 readonly CLUSTER_NAME=chart-testing
 readonly K8S_VERSION=v1.14.3
@@ -80,7 +80,9 @@ install_local-path-provisioner() {
 }
 
 install_charts() {
-    docker_exec ct lint-and-install --charts couchdb --upgrade --chart-dirs .
+    docker_exec ct lint-and-install --charts couchdb --upgrade --chart-dirs . 
--helm-extra-args "--set 'telemetry.enabled=true'"
+    # without telemetry
+    docker_exec ct lint --charts couchdb --chart-dirs . --helm-extra-args 
"--set ingress.enabled=true'"
     echo
 }
 

Reply via email to