Skip to content

Commit

Permalink
[prometheus-kafka-exporter] new chart donation (prometheus-community#216
Browse files Browse the repository at this point in the history
)

* add: kafka-exporter chart

Signed-off-by: gkarthiks <github.gkarthiks@gmail.com>

* fix: artifacthub annotations

Signed-off-by: gkarthiks <github.gkarthiks@gmail.com>

* feat: adding the tls option

Signed-off-by: gkarthiks <github.gkarthiks@gmail.com>

* fix: default service monitor to false

Signed-off-by: gkarthiks <github.gkarthiks@gmail.com>

* fix: default probes to false

Signed-off-by: gkarthiks <github.gkarthiks@gmail.com>
Signed-off-by: Torsten Walter <torsten.walter@syncier.com>
  • Loading branch information
gkarthiks authored and Torsten Walter committed Oct 26, 2020
1 parent b5e8a52 commit 5268dcf
Show file tree
Hide file tree
Showing 15 changed files with 557 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/charts/prometheus-couchdb-exporter/ @gkarthiks
/charts/prometheus-druid-exporter/ @iamabhishek-dubey
/charts/prometheus-elasticsearch-exporter/ @caarlos0 @desaintmartin @svenmueller
/charts/prometheus-kafka-exporter/ @gkarthiks @golgoth31
/charts/prometheus-mongodb-exporter/ @steven-sheehy
/charts/prometheus-mysql-exporter/ @juanchimienti @monotek
/charts/prometheus-nats-exporter/ @caarlos0 @okgolove
Expand Down
21 changes: 21 additions & 0 deletions charts/prometheus-kafka-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
appVersion: "v1.2.0"
description: A Helm chart to export the metrics from Kafka in Prometheus format using the kafka-exporter from https://github.com/danielqsj/kafka_exporter
name: prometheus-kafka-exporter
home: https://github.com/danielqsj/kafka_exporter
version: 0.1.4
sources:
- https://gkarthiks.github.io/helm-charts/charts/prometheus-kafka-exporter
keywords:
- prometheus
- kafka
maintainers:
- name: gkarthiks
email: github.gkarthiks@gmail.com
- name: golgoth31
email: golgoth31@notrenet.com
engine: gotpl
annotations:
"artifacthub.io/links": |
- name: Chart Source
url: https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-kafka-exporter
69 changes: 69 additions & 0 deletions charts/prometheus-kafka-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# prometheus-kafka-exporter

A Prometheus exporter for [Apacher Kafka](https://kafka.apache.org/) metrics.

This chart bootstraps a [Kafka Exporter](https://github.com/danielqsj/kafka_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

## Get Repo Info

```console
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
```

_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._


## Install Chart

```console
# Helm 3
$ helm install [RELEASE_NAME] prometheus-community/prometheus-kafka-exporter

# Helm 2
$ helm install --name [RELEASE_NAME] prometheus-community/prometheus-kafka-exporter
```

_See [configuration](#configuration) below._

_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Chart

```console
# Helm 3
$ helm uninstall [RELEASE_NAME]

# Helm 2
# helm delete --purge [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Upgrading Chart

```console
# Helm 3 or 2
$ helm upgrade [RELEASE_NAME] [CHART] --install
```

_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._

## Configuration

See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-kafka-exporter/values.yaml), or run these configuration commands:

```console
# Helm 2
$ helm inspect values prometheus-community/prometheus-kafka-exporter

# Helm 3
$ helm show values prometheus-community/prometheus-kafka-exporter
```
15 changes: 15 additions & 0 deletions charts/prometheus-kafka-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1. Get the application 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-kafka-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-kafka-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "prometheus-kafka-exporter.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "prometheus-kafka-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:80
{{- end }}
43 changes: 43 additions & 0 deletions charts/prometheus-kafka-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-kafka-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-kafka-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-kafka-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "prometheus-kafka-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "prometheus-kafka-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
76 changes: 76 additions & 0 deletions charts/prometheus-kafka-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "prometheus-kafka-exporter.fullname" . }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
chart: {{ template "prometheus-kafka-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "prometheus-kafka-exporter.name" . }}
release: {{ .Release.Name }}
template:
metadata:
annotations:
{{ toYaml .Values.annotations | indent 8 }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
release: {{ .Release.Name }}
spec:
serviceAccountName: {{ template "prometheus-kafka-exporter.serviceAccountName" . }}
containers:
- args:
{{- range $server := .Values.kafkaServer }}
- '--kafka.server={{ $server }}'
{{- end }}
{{- if .Values.tls.enabled }}
- '--tls.enabled'
- '--tls.ca-file={{ .Values.tls.mountPath }}/ca.crt'
- '--tls.cert-file={{ .Values.tls.mountPath }}/tls.crt'
- '--tls.key-file={{ .Values.tls.mountPath }}/tls.key'
{{- end }}
name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: exporter-port
containerPort: 9308
protocol: TCP
{{- if .Values.liveness.enabled }}
livenessProbe:
{{- toYaml .Values.liveness.probe | trim | nindent 12 }}
{{- end }}
{{- if .Values.readiness.enabled }}
readinessProbe:
{{- toYaml .Values.readiness.probe | trim | nindent 12 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.tls.enabled }}
volumeMounts:
- mountPath: {{ .Values.tls.mountPath }}
name: kafka-certs
readOnly: true
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- if .Values.tls.enabled }}
volumes:
- name: kafka-certs
secret:
secretName: {{ .Values.tls.secretName }}
{{- end }}
39 changes: 39 additions & 0 deletions charts/prometheus-kafka-exporter/templates/podsecuritypolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if .Values.rbac.pspEnabled }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: {{ template "prometheus-kafka-exporter.fullname" . }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
annotations:
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default'
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default'
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'docker/default'
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
spec:
privileged: false
allowPrivilegeEscalation: false
requiredDropCapabilities:
- ALL
volumes:
- 'configMap'
- 'emptyDir'
- 'projected'
- 'secret'
- 'downwardAPI'
hostNetwork: false
hostIPC: false
hostPID: false
runAsUser:
rule: 'RunAsAny'
seLinux:
rule: 'RunAsAny'
supplementalGroups:
rule: 'RunAsAny'
fsGroup:
rule: 'RunAsAny'
readOnlyRootFilesystem: false
{{- end }}
18 changes: 18 additions & 0 deletions charts/prometheus-kafka-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: {{ template "prometheus-kafka-exporter.fullname" . }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.rbac.pspEnabled }}
rules:
- apiGroups: ['extensions']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames: [{{ template "prometheus-kafka-exporter.fullname" . }}]
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/prometheus-kafka-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: {{ template "prometheus-kafka-exporter.fullname" . }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "prometheus-kafka-exporter.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "prometheus-kafka-exporter.serviceAccountName" . }}
{{- end -}}
21 changes: 21 additions & 0 deletions charts/prometheus-kafka-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "prometheus-kafka-exporter.fullname" . }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
chart: {{ template "prometheus-kafka-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: exporter-port
protocol: TCP
name: http
selector:
app: {{ template "prometheus-kafka-exporter.name" . }}
release: {{ .Release.Name }}
11 changes: 11 additions & 0 deletions charts/prometheus-kafka-exporter/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "prometheus-kafka-exporter.serviceAccountName" . }}
labels:
app: {{ template "prometheus-kafka-exporter.name" . }}
chart: {{ template "prometheus-kafka-exporter.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- end -}}
32 changes: 32 additions & 0 deletions charts/prometheus-kafka-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.prometheus.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "prometheus-kafka-exporter.fullname" . }}
{{- if .Values.prometheus.serviceMonitor.namespace }}
namespace: {{ .Values.prometheus.serviceMonitor.namespace }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "prometheus-kafka-exporter.name" . }}
helm.sh/chart: {{ include "prometheus-kafka-exporter.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.prometheus.serviceMonitor.additionalLabels }}
{{ toYaml .Values.prometheus.serviceMonitor.additionalLabels | indent 4 -}}
{{- end }}
spec:
jobLabel: jobLabel
selector:
matchLabels:
app.kubernetes.io/name: {{ include "prometheus-kafka-exporter.name" . }}
helm.sh/chart: {{ include "prometheus-kafka-exporter.chart" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- port: exporter-port
interval: {{ .Values.prometheus.serviceMonitor.interval }}
{{- if .Values.prometheus.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.prometheus.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
Loading

0 comments on commit 5268dcf

Please sign in to comment.