diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..4f19f0d --- /dev/null +++ b/helm/Chart.yaml @@ -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 \ No newline at end of file diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 0000000..4687ce4 --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -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 }} \ No newline at end of file diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml new file mode 100644 index 0000000..dc46338 --- /dev/null +++ b/helm/templates/configmap.yaml @@ -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 }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml new file mode 100644 index 0000000..1338a04 --- /dev/null +++ b/helm/templates/deployment.yaml @@ -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 }} \ No newline at end of file diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml new file mode 100644 index 0000000..ded92d9 --- /dev/null +++ b/helm/templates/ingress.yaml @@ -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 }} diff --git a/helm/templates/secret.yaml b/helm/templates/secret.yaml new file mode 100644 index 0000000..6144780 --- /dev/null +++ b/helm/templates/secret.yaml @@ -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 }} \ No newline at end of file diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml new file mode 100644 index 0000000..cd7ad2e --- /dev/null +++ b/helm/templates/service.yaml @@ -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 }} \ No newline at end of file diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..bcf6074 --- /dev/null +++ b/helm/values.yaml @@ -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: arya@stark.com + #hold_the_door: hodor@ikea.com + #DragonMama: daenerys@targaryen.com + +# 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: \ No newline at end of file