Skip to content

Commit

Permalink
add karma chart (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoQuote authored Jun 28, 2021
1 parent 57f52cc commit 50485f5
Show file tree
Hide file tree
Showing 13 changed files with 705 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/karma/.helmignore
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions charts/karma/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v2
description: A Helm chart for Karma - an UI for Prometheus Alertmanager
name: karma
home: https://github.com/prymitive/karma
sources:
- https://github.com/wiremind/wiremind-helm-charts/tree/main/charts/karma
- https://github.com/prymitive/karma
version: 1.8.1
appVersion: "0.85"
maintainers:
- name: desaintmartin
email: [email protected]
- name: machine424
email: [email protected]
- name: francoisminaud
email: [email protected]
102 changes: 102 additions & 0 deletions charts/karma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Karma

Karma is an ASL2 licensed alert dashboard for Prometheus Alertmanager.

## Introduction

This chart deploys karma to your cluster via a Deployment and Service.
Optionally you can also enable ingress.

# Prerequisites

- Kubernetes 1.9+

## Installing the Chart

To install the chart with the release name `my-release`, run:

```bash
$ helm repo add wiremind https://wiremind.github.io/wiremind-helm-charts
$ helm install --name my-release wiremind/karma
```

After a few seconds, you should see service statuses being written to the configured output.

> **Tip**: List all releases using `helm list`
## 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 values.yaml lists the configurable parameters of the karma chart and their default values.

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```bash
$ helm install --name my-release \
stable/karma
```

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/karma
```

> **Tip**: You will have to define the URL to alertmanager in env-settings in [values.yaml](values.yaml), under key ALERTMANAGER_URI .
### Secure configuration

If you have sensitive information in your Karma config you can wrap it in a Kubernetes Secret and then just point to the name of the Secret.

The structure of the Secret must follow the same pattern defined in `configMap.rawConfig`, here's an example on how to generate this Secret
with your Karma configuration:

```sh
# create a temporary file that contains your Karma configuration
cat > karma.conf <<EOL
alertmanager:
interval: 60s
servers:
- name: prod-alertmanager
uri: https://sensitive:[email protected]
timeout: 10s
proxy: true
- name: client-auth
uri: https://localhost:9093
timeout: 10s
tls:
ca: /etc/ssl/certs/ca-bundle.crt
cert: /etc/karma/client.pem
key: /etc/karma/client.key
annotations:
default:
hidden: false
hidden:
- help
visible: []
EOL

# create a Secret from this file with the key `karma.conf`
kubectl create secret generic sensitive-karma-config \
--from-file=karma.conf=./karma.conf
```

Next, point to the secret in your values file

```yml
# values.yaml
existingSecretConfig:
enabled: true
secretName: sensitive-karma-config
```
**NOTE:** you can either use `existingSecretConfig` or `configMap`, it cannot be both.
3 changes: 3 additions & 0 deletions charts/karma/ci/test-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
env:
- name: ALERTMANAGER_URI
value: http://monitoring-prometheus-alertmanager
19 changes: 19 additions & 0 deletions charts/karma/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "karma.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 {{ include "karma.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "karma.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.kubernetes.io/name={{ include "karma.name" . }},app.kubernetes.io/instance={{ .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/karma/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 "karma.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 "karma.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 "karma.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "karma.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "karma.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
18 changes: 18 additions & 0 deletions charts/karma/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ if .Values.configMap.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: "{{ template "karma.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
{{- with .Values.configMap.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
name: "{{ .Release.Name }}-config"
data:
karma.conf: |
{{ toYaml .Values.configMap.rawConfig | indent 4 }}
{{- end }}
114 changes: 114 additions & 0 deletions charts/karma/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "karma.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "karma.name" . }}
helm.sh/chart: {{ include "karma.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.deployment.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "karma.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "karma.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podLabels -}}
{{ toYaml .Values.podLabels | nindent 8 }}
{{- end }}
{{- if or .Values.configMap.enabled .Values.podAnnotations }}
annotations:
{{- if .Values.configMap.enabled }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.podAnnotations -}}
{{ toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
{{- end }}
spec:
serviceAccountName: {{ template "karma.serviceAccountName" . }}
{{- if .Values.securityContext }}
securityContext:
{{ toYaml .Values.securityContext | indent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
env:
{{- if or .Values.configMap.enabled .Values.existingSecretConfig.enabled }}
- name: CONFIG_FILE
value: /etc/karma/karma.conf
{{- end }}
{{- with .Values.env }}
{{ toYaml . | indent 10 }}
{{- end }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.path }}
port: http
initialDelaySeconds: {{ .Values.livenessProbe.delay }}
periodSeconds: {{ .Values.livenessProbe.period }}
readinessProbe:
httpGet:
path: {{ .Values.livenessProbe.path }}
port: http
initialDelaySeconds: {{ .Values.livenessProbe.delay }}
periodSeconds: {{ .Values.livenessProbe.period }}
resources:
{{ toYaml .Values.resources | indent 12 }}
volumeMounts:
{{- if or .Values.configMap.enabled .Values.existingSecretConfig.enabled }}
- name: karma-config
mountPath: /etc/karma
{{- end }}
{{- range .Values.certSecretNames }}
- name: {{ . }}
mountPath: /etc/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 }}
volumes:
{{- if and .Values.configMap.enabled .Values.existingSecretConfig.enabled }}
{{- fail "You can either use .Values.configMap or .Values.existingSecretConfig"}}
{{- end }}
{{- if .Values.configMap.enabled }}
- name: karma-config
configMap:
name: {{ .Release.Name }}-config
{{- end }}
{{- if .Values.existingSecretConfig.enabled }}
- name: karma-config
secret:
secretName: {{ .Values.existingSecretConfig.secretName }}
{{- end }}
{{- range .Values.certSecretNames }}
- name: {{ . }}
secret:
defaultMode: 420
secretName: {{ . }}
{{- end }}
38 changes: 38 additions & 0 deletions charts/karma/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "karma.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "karma.name" . }}
helm.sh/chart: {{ include "karma.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
Loading

0 comments on commit 50485f5

Please sign in to comment.