diff --git a/stable/redis-ha/Chart.yaml b/stable/redis-ha/Chart.yaml index 7b5afe7023..38a10b1f70 100644 --- a/stable/redis-ha/Chart.yaml +++ b/stable/redis-ha/Chart.yaml @@ -6,7 +6,7 @@ keywords: - redis - keyvalue - database -version: 4.3.3 +version: 4.3.4 appVersion: 5.0.6 description: Highly available Kubernetes implementation of Redis icon: https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Redis_Logo.svg/1200px-Redis_Logo.svg.png diff --git a/stable/redis-ha/README.md b/stable/redis-ha/README.md index f997b112e0..04b06c9489 100644 --- a/stable/redis-ha/README.md +++ b/stable/redis-ha/README.md @@ -93,6 +93,7 @@ The following table lists the configurable parameters of the Redis chart and the | `exporter.port` | Exporter port | `9121` | | `exporter.annotations` | Prometheus scrape annotations | `{prometheus.io/path: /metrics, prometheus.io/port: "9121", prometheus.io/scrape: "true"}` | | `exporter.extraArgs` | Additional args for the exporter | `{}` | +| `exporter.script` | A custom custom Lua script that will be mounted to exporter for collection of custom metrics. Creates a ConfigMap and sets env var `REDIS_EXPORTER_SCRIPT`. | | | `exporter.serviceMonitor.enabled` | Use servicemonitor from prometheus operator | `false` | | `exporter.serviceMonitor.namespace` | Namespace the service monitor is created in | `default` | | `exporter.serviceMonitor.interval` | Scrape interval, If not set, the Prometheus default scrape interval is used | `nil` | diff --git a/stable/redis-ha/templates/redis-ha-exporter-script-configmap.yaml b/stable/redis-ha/templates/redis-ha-exporter-script-configmap.yaml new file mode 100644 index 0000000000..b9dc79c69b --- /dev/null +++ b/stable/redis-ha/templates/redis-ha-exporter-script-configmap.yaml @@ -0,0 +1,11 @@ +{{- if .Values.exporter.script }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "redis-ha.fullname" . }}-exporter-script-configmap + namespace: {{ .Release.Namespace }} + labels: +{{ include "labels.standard" . | indent 4 }} +data: + script: {{ toYaml .Values.exporter.script | indent 2 }} +{{- end }} \ No newline at end of file diff --git a/stable/redis-ha/templates/redis-ha-statefulset.yaml b/stable/redis-ha/templates/redis-ha-statefulset.yaml index 5017b91178..32638cfdd9 100644 --- a/stable/redis-ha/templates/redis-ha-statefulset.yaml +++ b/stable/redis-ha/templates/redis-ha-statefulset.yaml @@ -237,6 +237,10 @@ spec: {{- end }} key: {{ .Values.authKey }} {{- end }} + {{- if .Values.exporter.script }} + - name: REDIS_EXPORTER_SCRIPT + value: /script/script.lua + {{- end }} livenessProbe: httpGet: path: {{ .Values.exporter.scrapePath }} @@ -249,6 +253,11 @@ spec: ports: - name: exporter-port containerPort: {{ .Values.exporter.port }} + {{- if .Values.exporter.script }} + volumeMounts: + - mountPath: /script + name: script-mount + {{- end }} {{- end }} {{- if .Values.priorityClassName }} priorityClassName: {{ .Values.priorityClassName }} @@ -262,6 +271,14 @@ spec: hostPath: path: /sys {{- end }} + {{- if .Values.exporter.script }} + - name: script-mount + configMap: + name: {{ template "redis-ha.fullname" . }}-exporter-script-configmap + items: + - key: script + path: script.lua + {{- end }} {{- if .Values.persistentVolume.enabled }} volumeClaimTemplates: - metadata: diff --git a/stable/redis-ha/values.yaml b/stable/redis-ha/values.yaml index d105f0bfff..1672d52aa3 100644 --- a/stable/redis-ha/values.yaml +++ b/stable/redis-ha/values.yaml @@ -259,6 +259,31 @@ exporter: # Additional args for redis exporter extraArgs: {} + # Used to mount a LUA-Script via config map and use it for metrics-collection + # script: | + # -- Example script copied from: https://github.com/oliver006/redis_exporter/blob/master/contrib/sample_collect_script.lua + # -- Example collect script for -script option + # -- This returns a Lua table with alternating keys and values. + # -- Both keys and values must be strings, similar to a HGETALL result. + # -- More info about Redis Lua scripting: https://redis.io/commands/eval + # + # local result = {} + # + # -- Add all keys and values from some hash in db 5 + # redis.call("SELECT", 5) + # local r = redis.call("HGETALL", "some-hash-with-stats") + # if r ~= nil then + # for _,v in ipairs(r) do + # table.insert(result, v) -- alternating keys and values + # end + # end + # + # -- Set foo to 42 + # table.insert(result, "foo") + # table.insert(result, "42") -- note the string, use tostring() if needed + # + # return result + serviceMonitor: # When set true then use a ServiceMonitor to configure scraping enabled: false