Skip to content

Commit

Permalink
Add helm chart for failedkite (#11)
Browse files Browse the repository at this point in the history
* Add  helm chart for failedkite

* add ingress

* use fullname instead of name

* remove type from configmap

---------

Co-authored-by: vini-intenseye <[email protected]>
Co-authored-by: Vini Vas <[email protected]>
  • Loading branch information
3 people authored Feb 22, 2024
1 parent 8eef467 commit 3df67db
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
appVersion: v1.0.0
description: A Helm chart for the Failedkite installation
name: failedkite
type: application
version: 1.0.0
58 changes: 58 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- define "verify-slackConfig" -}}
{{- if not (or (.Values.slack.apiToken) (.Values.slack)) }}
{{- fail "Slack configuration cannot be empty. Define the Slack API key and Default Email" }}
{{- end }}
{{- end -}}


{{/*
Expand the name of the chart.
*/}}
{{- define "failedkite.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 "failedkite.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if hasPrefix .Release.Name $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 "failedkite.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "failedkite.labels" -}}
helm.sh/chart: {{ include "failedkite.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "failedkite.selectorLabels" -}}
app.kubernetes.io/name: {{ include "failedkite.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: {{ include "failedkite.name" . }}
{{- end }}
13 changes: 13 additions & 0 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.authorMapping }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "failedkite.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "failedkite.labels" . | nindent 4 }}
data:
author_mapping.yml: |
{{ toYaml .Values.authorMapping | nindent 4 }}
{{- end }}
76 changes: 76 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "failedkite.fullname" . }}
labels:
{{- include "failedkite.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
{{- include "failedkite.selectorLabels" . | nindent 6 }}
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 100%
template:
metadata:
labels:
{{- include "failedkite.selectorLabels" . | nindent 8 }}
{{- include "failedkite.labels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{- toYaml .Values.commonPodLabels | nindent 8 }}
{{- end }}
{{- if .Values.commonPodLabels }}
{{- toYaml .Values.commonPodLabels | nindent 8 }}
{{- end }}
spec:
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.resources }}
resources:
{{- toYaml .Values.resources | nindent 10 }}
{{- end }}
env:
- name: SLACK_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "failedkite.fullname" . }}
key: SLACK_TOKEN
- name: DEFAULT_SLACK_EMAIL
value: {{ .Values.slack.defaultEmail | required "slack.defaultEmail is required" | quote }}
{{- if .Values.authorMapping }}
volumeMounts:
- name: {{ include "failedkite.fullname" . }}-volume
mountPath: /config/author_mapping.yml
subPath: author_mapping.yml
{{- end }}
{{- if .Values.authorMapping }}
volumes:
- name: {{ include "failedkite.fullname" . }}-volume
configMap:
name: {{ include "failedkite.fullname" . }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
48 changes: 48 additions & 0 deletions helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "failedkite.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "failedkite.labels" . | nindent 4 }}
annotations:
kubernetes.io/ingress.class: {{ .Values.ingress.class }}
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.Version }}
ingressClassName: {{ .Values.ingress.class }}
{{- end }}
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.host }}
secretName: {{ .Values.ingress.tls.secretName }}
{{- end }}
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /webhook
pathType: ImplementationSpecific
{{- if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.Version }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions helm/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "failedkite.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "failedkite.labels" . | nindent 4 }}
type: Opaque
data:
SLACK_TOKEN: {{ required "slack.apiToken is required!" .Values.slack.apiToken | b64enc | quote }}
22 changes: 22 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "failedkite.fullname" . }}
labels:
{{- include "failedkite.labels" . | nindent 4 }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "failedkite.selectorLabels" . | nindent 4 }}
type: {{ .Values.service.type }}
{{- if (and (.Values.service.loadBalancerIP) (eq .Values.service.type "LoadBalancer")) }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if (and (.Values.service.loadBalancerSourceRanges) (eq .Values.service.type "LoadBalancer")) }}
loadBalancerSourceRanges:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 2 }}
{{- end }}
50 changes: 50 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
image:
repository: hadican/failedkite
tag: latest
pullPolicy: IfNotPresent
imagePullSecrets: []
commonPodLabels: {}
nameOverride: ''
fullnameOverride: ''
replicas: 1
resources:
limits:
memory: 1Gi
requests:
cpu: 100m
memory: 128Mi

# Add Github username to Slack email address mapping
authorMapping:
#no_one: [email protected]
#hold_the_door: [email protected]
#DragonMama: [email protected]

# Provide Slack configuration
slack:
#apiToken:
#defaultEmail:

nodeSelector: {}
tolerations: []
affinity: {}

# Configure the service
# When using service type LoadBalancer, the loadBalancerIP and loadBalancerSourceRanges can be added
service:
type: ClusterIP
port: 8080
#loadBalancerIP: 10.3.1.3
#loadBalancerSourceRanges:
#- 10.4.5.6
#- 3.4.5.6

# Configure ingress
ingress:
enabled: false
#class: backend
tls:
enabled: false
secretName: tls-key
#host: failedkite.webhook.com
#annotations:

0 comments on commit 3df67db

Please sign in to comment.