adding redis-exporter chart (#2743)

* adding redis-exporter chart

* use {{ .Release.Name }} for resource naming

* adding annotations for prometheus scrapper

* Revert "use {{ .Release.Name }} for resource naming"

This reverts commit 4c0388f030.

* use .Release.Name for fullname

* updated prerequisites and api version

* matchLabels required for apps/v1beta2

* added suggested style fixes

* adding release label

* renamed to prometheus redis exporter

* moved to stable

* use a named port

* upgraded to v0.16.0
This commit is contained in:
acondrat
2018-04-08 01:40:07 -07:00
committed by k8s-ci-robot
parent f631044946
commit 4070903083
8 changed files with 226 additions and 0 deletions
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
@@ -0,0 +1,14 @@
apiVersion: v1
appVersion: 0.16.0
description: Prometheus exporter for Redis metrics
name: prometheus-redis-exporter
version: 0.1.0
home: https://github.com/oliver006/redis_exporter
sources:
- https://github.com/oliver006/redis_exporter
keywords:
- prometheus
- redis
maintainers:
- name: acondrat
email: arcadie.condrat@gmail.com
@@ -0,0 +1,68 @@
# prometheus-redis-exporter
[redis_exporter](https://github.com/oliver006/redis_exporter) is a Prometheus exporter for Redis metrics.
## TL;DR;
```bash
$ helm install stable/prometheus-redis-exporter
```
## Introduction
This chart bootstraps a [redis_exporter](https://github.com/oliver006/redis_exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
## Prerequisites
- Kubernetes 1.8+ with Beta APIs enabled
## Installing the Chart
To install the chart with the release name `my-release`:
```bash
$ helm install --name my-release stable/prometheus-redis-exporter
```
The command deploys prometheus-redis-exporter on the Kubernetes cluster in the default configuration.
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```bash
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The following tables lists the configurable parameters and their default values.
| Parameter | Description | Default |
| ---------------------- | --------------------------------------------------- | ------------------------- |
| `replicaCount` | desired number of prometheus-redis-exporter pods | `1` |
| `image.repository` | prometheus-redis-exporter image repository | `oliver006/redis_exporter`|
| `image.tag` | prometheus-redis-exporter image tag | `v0.16.0` |
| `image.pullPolicy` | image pull policy | `IfNotPresent` |
| `resources` | cpu/memory resource requests/limits | {} |
| `service.type` | desired service type | `ClusterIP` |
| `service.port` | service external port | `9121` |
| `redisAddress` | address of one or more redis nodes, comma separated | `redis://myredis:6379` |
For more information please refer to the [redis_exporter](https://github.com/oliver006/redis_exporter) documentation.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```bash
$ helm install --name my-release \
--set "redisAddress=redis://myredis:6379" \
stable/prometheus-redis-exporter
```
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
```bash
$ helm install --name my-release -f values.yaml stable/prometheus-redis-exporter
```
@@ -0,0 +1,15 @@
1. Get the Redis Exporter URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prometheus-redis-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "prometheus-redis-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "prometheus-redis-exporter.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "prometheus-redis-exporter.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort }}
{{- end }}
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-redis-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "prometheus-redis-exporter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "prometheus-redis-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -0,0 +1,45 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "prometheus-redis-exporter.fullname" . }}
labels:
app: {{ template "prometheus-redis-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "prometheus-redis-exporter.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "prometheus-redis-exporter.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: exporter-port
containerPort: 9121
env:
- name: REDIS_ADDR
value: {{ .Values.redisAddress }}
livenessProbe:
httpGet:
path: /
port: exporter-port
readinessProbe:
httpGet:
path: /
port: exporter-port
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "prometheus-redis-exporter.fullname" . }}
labels:
app: {{ template "prometheus-redis-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: exporter-port
protocol: TCP
selector:
app: {{ template "prometheus-redis-exporter.name" . }}
release: {{ .Release.Name }}
@@ -0,0 +1,11 @@
replicaCount: 1
image:
repository: oliver006/redis_exporter
tag: v0.16.0
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 9121
annotations: {}
resources: {}
redisAddress: redis://myredis:6379