From cfd9fb2cf714724b89bace5ebaf7ca7679950656 Mon Sep 17 00:00:00 2001 From: Tyler Gregory Date: Wed, 23 Oct 2019 09:47:24 -0500 Subject: [PATCH 1/5] Create a prometheus metrics exporter as a sidecar --- .../templates/eventstore-statefulset.yaml | 25 ++++++++++++++++--- stable/eventstore/values.yaml | 5 ++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/stable/eventstore/templates/eventstore-statefulset.yaml b/stable/eventstore/templates/eventstore-statefulset.yaml index e1eb3b4..2b1eec4 100644 --- a/stable/eventstore/templates/eventstore-statefulset.yaml +++ b/stable/eventstore/templates/eventstore-statefulset.yaml @@ -22,14 +22,17 @@ spec: metadata: annotations: checksum/config: {{ include (print $.Template.BasePath "/eventstore-configmap.yaml") . | sha256sum }} + {{- if .Values.metrics.enabled }} + prometheus.io/scrape: "true" + prometheus.io/port: {{ .Values.metrics.port | quote }} + {{- end }} + {{- if .Values.podAnnotations }} +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} labels: app.kubernetes.io/name: {{ include "eventstore.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/component: database - {{- if .Values.podAnnotations }} - annotations: -{{ toYaml .Values.podAnnotations | indent 8 }} - {{- end }} spec: nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }} @@ -44,6 +47,20 @@ spec: {{- end}} {{- end }} containers: + {{- if .Values.metrics.enabled }} + - name: prometheus-exporter + image: marcinbudny/eventstore_exporter:0.7.0 + imagePullPolicy: {{ .Values.imagePullPolicy }} + env: + - name: EVENTSTORE_USER + value: admin + - name: EVENTSTORE_PASSWORD + value: {{- if .Values.admin.password }} {{- .Values.admin.password }} {{- else }} changeit {{- end }} + - name: PORT + value: {{ .Values.metrics.port | quote }} + - name: CLUSTER_MODE + value: {{- if and .Values.extIp (gt (.Values.clusterSize | float64) 1.0) }} cluster {{- else }} single {{- end }} + {{- end }} - name: {{ .Chart.Name }} image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: {{ .Values.imagePullPolicy }} diff --git a/stable/eventstore/values.yaml b/stable/eventstore/values.yaml index 9e57cef..090a7ae 100644 --- a/stable/eventstore/values.yaml +++ b/stable/eventstore/values.yaml @@ -124,6 +124,11 @@ persistence: mountPath: /var/lib/eventstore annotations: {} +## Export prometheus metrics +metrics: + enabled: false + port: 9448 + resources: {} ## If you want to specify resources, uncomment the following ## lines, adjust them as necessary, and remove the curly braces after 'resources:'. From 58128dae604d5c9020227c24e70ad3299e1ce6c9 Mon Sep 17 00:00:00 2001 From: Tyler Gregory Date: Wed, 23 Oct 2019 16:23:32 -0500 Subject: [PATCH 2/5] Update changelog and bump chart version --- CHANGELOG.md | 3 +++ stable/eventstore/Chart.yaml | 2 +- stable/eventstore/values.yaml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3023b7d..93c853e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog # +## 0.2.6 October 22, 2019 +- Add a prometheus exporter sidecar + ## 0.2.5: August 30, 2019 - __Potentially breaking__: Add release namespace to all resources to work with `helm template` See https://github.com/helm/helm/issues/5465 for more information. diff --git a/stable/eventstore/Chart.yaml b/stable/eventstore/Chart.yaml index 1f08d7a..b6e7ada 100644 --- a/stable/eventstore/Chart.yaml +++ b/stable/eventstore/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 description: A Helm chart for Kubernetes EventStore. name: eventstore home: https://eventstore.org/ -version: 0.2.5 +version: 0.2.6 appVersion: 4.1.1-hotfix1 keywords: - eventstore diff --git a/stable/eventstore/values.yaml b/stable/eventstore/values.yaml index 090a7ae..f9c672d 100644 --- a/stable/eventstore/values.yaml +++ b/stable/eventstore/values.yaml @@ -127,6 +127,7 @@ persistence: ## Export prometheus metrics metrics: enabled: false + ## The port the exporter sidecar will expose its metrics on port: 9448 resources: {} From 7f61e2be2e09170a9485a01d1361bf8855b39a26 Mon Sep 17 00:00:00 2001 From: Tyler Gregory Date: Sat, 16 Nov 2019 19:00:14 -0600 Subject: [PATCH 3/5] Enable configuration of metrics image and resources --- stable/eventstore/templates/_helpers.tpl | 7 +++++++ .../templates/eventstore-statefulset.yaml | 13 ++++++++++--- stable/eventstore/values.yaml | 7 ++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/stable/eventstore/templates/_helpers.tpl b/stable/eventstore/templates/_helpers.tpl index 977e720..efcec94 100644 --- a/stable/eventstore/templates/_helpers.tpl +++ b/stable/eventstore/templates/_helpers.tpl @@ -37,3 +37,10 @@ Create DNS used to access the service from within the cluster. {{- define "eventstore.dns" -}} {{ include "eventstore.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local {{- end -}} + +{{- define "eventstore.metrics.image" -}} +{{- $registryName := default "docker.io" .Values.metrics.image.registry -}} +{{- $repositoryName := .Values.metrics.image.repository -}} +{{- $tag := default "latest" .Values.metrics.image.tag | toString -}} +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} \ No newline at end of file diff --git a/stable/eventstore/templates/eventstore-statefulset.yaml b/stable/eventstore/templates/eventstore-statefulset.yaml index 2b1eec4..48e0a73 100644 --- a/stable/eventstore/templates/eventstore-statefulset.yaml +++ b/stable/eventstore/templates/eventstore-statefulset.yaml @@ -49,7 +49,7 @@ spec: containers: {{- if .Values.metrics.enabled }} - name: prometheus-exporter - image: marcinbudny/eventstore_exporter:0.7.0 + image: {{ template "eventstore.metrics.image" . }} imagePullPolicy: {{ .Values.imagePullPolicy }} env: - name: EVENTSTORE_USER @@ -60,6 +60,12 @@ spec: value: {{ .Values.metrics.port | quote }} - name: CLUSTER_MODE value: {{- if and .Values.extIp (gt (.Values.clusterSize | float64) 1.0) }} cluster {{- else }} single {{- end }} + ports: + - name: metrics + containerPort: {{ .Values.metrics.port }} + {{- if .Values.metrics.resources }} + resources: {{- toYaml .Values.metrics.resources | nindent 12 -}} + {{- end }} {{- end }} - name: {{ .Chart.Name }} image: "{{ .Values.image }}:{{ .Values.imageTag }}" @@ -105,8 +111,9 @@ spec: initialDelaySeconds: 15 timeoutSeconds: 5 periodSeconds: 15 - resources: -{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.resources }} + resources: {{- toYaml .Values.resources | nindent 12 -}} + {{- end }} volumeMounts: - name: data mountPath: {{ .Values.persistence.mountPath }} diff --git a/stable/eventstore/values.yaml b/stable/eventstore/values.yaml index f9c672d..4affb9c 100644 --- a/stable/eventstore/values.yaml +++ b/stable/eventstore/values.yaml @@ -127,8 +127,13 @@ persistence: ## Export prometheus metrics metrics: enabled: false - ## The port the exporter sidecar will expose its metrics on + image: + registry: docker.io + repository: marcinbudny/eventstore_exporter + tag: 0.7.0 + ## The port on which the exporter sidecar will expose its metrics port: 9448 + resources: {} resources: {} ## If you want to specify resources, uncomment the following From cbc125c0325a57c883eea62de49670ad4729b526 Mon Sep 17 00:00:00 2001 From: Tyler Gregory Date: Mon, 2 Dec 2019 13:54:18 -0600 Subject: [PATCH 4/5] Add metrics documentation to the readme --- stable/eventstore/README.md | 83 ++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/stable/eventstore/README.md b/stable/eventstore/README.md index 228c429..e98f100 100644 --- a/stable/eventstore/README.md +++ b/stable/eventstore/README.md @@ -68,44 +68,51 @@ associated with the chart and deletes the release. The following table lists the configurable parameters of the Event Store chart and their default values. -| Parameter | Description | Default | -| ------------------------------------ | ----------------------------------------------------------------------------- | ---------------------------- | -| `image` | Container image name | `eventstore/eventstore` | -| `imageTag` | Container image tag | `release-4.1.1-hotfix1` | -| `imagePullPolicy` | Container pull policy | `IfNotPresent` | -| `imagePullSecrets` | Specify image pull secrets | `nil` | -| `clusterSize` | The number of nodes in the cluster | `3` | -| `admin.jobImage` | Post install Job image with `curl` installed for setting admin password | `tutum/curl` | -| `admin.jobImageTag` | Post install Job image tag | `latest` | -| `admin.password` | Custom password for admin interface (should be set in separate file) | `nil` | -| `admin.serviceType` | Service type for the admin interface | `ClusterIP` | -| `admin.proxyImage` | NGINX image for admin interface proxy | `nginx` | -| `admin.proxyImageTag` | NGINX image tag | `latest` | -| `podDisruptionBudget.enabled` | Enable a pod disruption budget for nodes | `false` | -| `podDisruptionBudget.minAvailable` | Number of pods that must still be available after eviction | `2` | -| `podDisruptionBudget.maxUnavailable` | Number of pods that can be unavailable after eviction | `nil` | -| `extIp` | External IP address | `0.0.0.0` | -| `intHttpPort` | Internal HTTP port | `2112` | -| `extHttpPort` | External HTTP port | `2113` | -| `intTcpPort` | Internal TCP port | `1112` | -| `extTcpPort` | External TCP port | `1113` | -| `gossipAllowedDiffMs` | The amount of drift, in ms, between clocks on nodes before gossip is rejected | `600000` | -| `eventStoreConfig` | Additional Event Store parameters | `{}` | -| `scavenging.enabled` | Enable the scavenging CronJob for all nodes | `false` | -| `scavenging.image` | The image to use for the scavenging CronJob | `lachlanevenson/k8s-kubectl` | -| `scavenging.imageTag` | The image tag use for the scavenging CronJob | `latest` | -| `scavenging.schedule` | The schedule to use for the scavenging CronJob | `0 2 * * *` | -| `persistence.enabled` | Enable persistence using PVC | `false` | -| `persistence.existingClaim` | Provide an existing PVC | `nil` | -| `persistence.accessMode` | Access Mode for PVC | `ReadWriteOnce` | -| `persistence.size` | Size of data volume | `8Gi` | -| `persistence.mountPath` | Mount path of data volume | `/var/lib/eventstore` | -| `persistence.annotations` | Annotations for PVC | `{}` | -| `resources` | CPU/Memory resource request/limits | Memory: `256Mi`, CPU: `100m` | -| `nodeSelector` | Node labels for pod assignment | `{}` | -| `podAnnotations` | Pod annotations | `{}` | -| `tolerations` | Toleration labels for pod assignment | `[]` | -| `affinity` | Affinity settings for pod assignment | `{}` | +| Parameter | Description | Default | +| ------------------------------------ | ----------------------------------------------------------------------------- | --------------------------------- | +| `image` | Container image name | `eventstore/eventstore` | +| `imageTag` | Container image tag | `release-4.1.1-hotfix1` | +| `imagePullPolicy` | Container pull policy | `IfNotPresent` | +| `imagePullSecrets` | Specify image pull secrets | `nil` | +| `clusterSize` | The number of nodes in the cluster | `3` | +| `admin.jobImage` | Post install Job image with `curl` installed for setting admin password | `tutum/curl` | +| `admin.jobImageTag` | Post install Job image tag | `latest` | +| `admin.password` | Custom password for admin interface (should be set in separate file) | `nil` | +| `admin.serviceType` | Service type for the admin interface | `ClusterIP` | +| `admin.proxyImage` | NGINX image for admin interface proxy | `nginx` | +| `admin.proxyImageTag` | NGINX image tag | `latest` | +| `podDisruptionBudget.enabled` | Enable a pod disruption budget for nodes | `false` | +| `podDisruptionBudget.minAvailable` | Number of pods that must still be available after eviction | `2` | +| `podDisruptionBudget.maxUnavailable` | Number of pods that can be unavailable after eviction | `nil` | +| `extIp` | External IP address | `0.0.0.0` | +| `intHttpPort` | Internal HTTP port | `2112` | +| `extHttpPort` | External HTTP port | `2113` | +| `intTcpPort` | Internal TCP port | `1112` | +| `extTcpPort` | External TCP port | `1113` | +| `gossipAllowedDiffMs` | The amount of drift, in ms, between clocks on nodes before gossip is rejected | `600000` | +| `eventStoreConfig` | Additional Event Store parameters | `{}` | +| `scavenging.enabled` | Enable the scavenging CronJob for all nodes | `false` | +| `scavenging.image` | The image to use for the scavenging CronJob | `lachlanevenson/k8s-kubectl` | +| `scavenging.imageTag` | The image tag use for the scavenging CronJob | `latest` | +| `scavenging.schedule` | The schedule to use for the scavenging CronJob | `0 2 * * *` | +| `persistence.enabled` | Enable persistence using PVC | `false` | +| `persistence.existingClaim` | Provide an existing PVC | `nil` | +| `persistence.accessMode` | Access Mode for PVC | `ReadWriteOnce` | +| `persistence.size` | Size of data volume | `8Gi` | +| `persistence.mountPath` | Mount path of data volume | `/var/lib/eventstore` | +| `persistence.annotations` | Annotations for PVC | `{}` | +| `resources` | CPU/Memory resource request/limits | Memory: `256Mi`, CPU: `100m` | +| `nodeSelector` | Node labels for pod assignment | `{}` | +| `podAnnotations` | Pod annotations | `{}` | +| `tolerations` | Toleration labels for pod assignment | `[]` | +| `affinity` | Affinity settings for pod assignment | `{}` | +| `metrics.enabled` | Enable a sidecar to export prometheus metrics | `false` | +| `metrics.image.registry` | Docker registry from which to pull the metrics image | `docker.io` | +| `metrics.image.repository` | Docker repository from which to pull the metrics image | `marcinbudny/eventstore_exporter` | +| `metrics.image.tag` | Metric exporter image tag to pull | `0.7.0` | +| `metrics.port` | Metrics exporter port | `9448` | +| `metrics.resources` | CPU/Memory resource requests/limits for the metrics exporter | `{}` | + Specify each parameter using the `--set key=value[,key=value]` argument to `helm install` or create a `values.yaml` file and use `helm install --values values.yaml`. From ee16a726c1ed534105d39db5607cce0c16cabdbb Mon Sep 17 00:00:00 2001 From: Tyler Gregory Date: Thu, 5 Dec 2019 09:00:47 -0600 Subject: [PATCH 5/5] Un-nest the metrics exporter image values --- stable/eventstore/README.md | 5 ++--- stable/eventstore/templates/_helpers.tpl | 7 ------- stable/eventstore/templates/eventstore-statefulset.yaml | 2 +- stable/eventstore/values.yaml | 6 ++---- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/stable/eventstore/README.md b/stable/eventstore/README.md index e98f100..3593385 100644 --- a/stable/eventstore/README.md +++ b/stable/eventstore/README.md @@ -107,9 +107,8 @@ The following table lists the configurable parameters of the Event Store chart a | `tolerations` | Toleration labels for pod assignment | `[]` | | `affinity` | Affinity settings for pod assignment | `{}` | | `metrics.enabled` | Enable a sidecar to export prometheus metrics | `false` | -| `metrics.image.registry` | Docker registry from which to pull the metrics image | `docker.io` | -| `metrics.image.repository` | Docker repository from which to pull the metrics image | `marcinbudny/eventstore_exporter` | -| `metrics.image.tag` | Metric exporter image tag to pull | `0.7.0` | +| `metrics.image` | Docker repository from which to pull the metrics exporter image | `marcinbudny/eventstore_exporter` | +| `metrics.imageTag` | Metrics exporter image tag to pull | `0.7.0` | | `metrics.port` | Metrics exporter port | `9448` | | `metrics.resources` | CPU/Memory resource requests/limits for the metrics exporter | `{}` | diff --git a/stable/eventstore/templates/_helpers.tpl b/stable/eventstore/templates/_helpers.tpl index efcec94..977e720 100644 --- a/stable/eventstore/templates/_helpers.tpl +++ b/stable/eventstore/templates/_helpers.tpl @@ -37,10 +37,3 @@ Create DNS used to access the service from within the cluster. {{- define "eventstore.dns" -}} {{ include "eventstore.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local {{- end -}} - -{{- define "eventstore.metrics.image" -}} -{{- $registryName := default "docker.io" .Values.metrics.image.registry -}} -{{- $repositoryName := .Values.metrics.image.repository -}} -{{- $tag := default "latest" .Values.metrics.image.tag | toString -}} -{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} -{{- end -}} \ No newline at end of file diff --git a/stable/eventstore/templates/eventstore-statefulset.yaml b/stable/eventstore/templates/eventstore-statefulset.yaml index 48e0a73..373e747 100644 --- a/stable/eventstore/templates/eventstore-statefulset.yaml +++ b/stable/eventstore/templates/eventstore-statefulset.yaml @@ -49,7 +49,7 @@ spec: containers: {{- if .Values.metrics.enabled }} - name: prometheus-exporter - image: {{ template "eventstore.metrics.image" . }} + image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}" imagePullPolicy: {{ .Values.imagePullPolicy }} env: - name: EVENTSTORE_USER diff --git a/stable/eventstore/values.yaml b/stable/eventstore/values.yaml index 4affb9c..78f2ca2 100644 --- a/stable/eventstore/values.yaml +++ b/stable/eventstore/values.yaml @@ -127,10 +127,8 @@ persistence: ## Export prometheus metrics metrics: enabled: false - image: - registry: docker.io - repository: marcinbudny/eventstore_exporter - tag: 0.7.0 + image: marcinbudny/eventstore_exporter + imageTag: 0.7.0 ## The port on which the exporter sidecar will expose its metrics port: 9448 resources: {}