Skip to content

Instantly share code, notes, and snippets.

@sameersbn
Last active June 22, 2017 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sameersbn/ede014d7a36912b4ac57050a64509ff2 to your computer and use it in GitHub Desktop.
Save sameersbn/ede014d7a36912b4ac57050a64509ff2 to your computer and use it in GitHub Desktop.
Patch to demonstrate addition of Prometheus metrics endpoint
# git clone https://github.com/kubernetes/charts
# cd charts
# curl -sSL https://git.io/vQIyP > mariadb-metrics-support.patch
# patch -Np1 -i mariadb-metrics-support.patch
# helm install stable/mariadb
diff --git a/stable/mariadb/templates/deployment.yaml b/stable/mariadb/templates/deployment.yaml
index ac3f7a1..3f8cd12 100644
--- a/stable/mariadb/templates/deployment.yaml
+++ b/stable/mariadb/templates/deployment.yaml
@@ -73,6 +73,15 @@ spec:
timeoutSeconds: 1
resources:
{{ toYaml .Values.resources | indent 10 }}
+ - name: metrics
+ image: "prom/mysqld-exporter:v0.10.0"
+ imagePullPolicy: "IfNotPresent"
+ env:
+ - name: DATA_SOURCE_NAME
+ value: "root:{{ .Values.mariadbRootPassword }}@(localhost:3306)/"
+ ports:
+ - name: metrics
+ containerPort: 9104
volumeMounts:
- name: data
mountPath: /bitnami/mariadb
diff --git a/stable/mariadb/templates/svc.yaml b/stable/mariadb/templates/svc.yaml
index 8a67c3c..ebaa407 100644
--- a/stable/mariadb/templates/svc.yaml
+++ b/stable/mariadb/templates/svc.yaml
@@ -7,6 +7,9 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
+ annotations:
+ prometheus.io/scrape: "true"
+ prometheus.io/port: "9104"
spec:
type: {{ .Values.serviceType }}
ports:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment