diff --git a/mailhog/.helmignore b/mailhog/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/mailhog/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/mailhog/Chart.yaml b/mailhog/Chart.yaml new file mode 100644 index 0000000..dc81b3f --- /dev/null +++ b/mailhog/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +appVersion: v1.0.1 +description: An e-mail testing tool for developers +home: http://iankent.uk/project/mailhog/ +icon: https://raw.githubusercontent.com/mailhog/MailHog-UI/master/assets/images/hog.png +keywords: +- mailhog +- mail +- smtp +- email +- e-mail +- testing +maintainers: +- email: pratik@improwised.com + name: pratik +name: mailhog +sources: + - https://github.com/mailhog/MailHog + - https://github.com/codecentric/ +version: 1.0.1 diff --git a/mailhog/README.md b/mailhog/README.md new file mode 100644 index 0000000..938f1d1 --- /dev/null +++ b/mailhog/README.md @@ -0,0 +1,70 @@ +# Mailhog + +[Mailhog](http://iankent.uk/project/mailhog/) is an e-mail testing tool for developers. + +## TL;DR; + +```bash +#clone this repo and follow below command +$ helm install mailhog . +``` + +## Introduction + +This chart creates a [Mailhog](http://iankent.uk/project/mailhog/) deployment on a [Kubernetes](http://kubernetes.io) +cluster using the [Helm](https://helm.sh) package manager. + +## Installing the Chart + +To install the chart with the release name `mailhog`: + +```bash +$ helm install mailhog . +``` + +The command deploys Mailhog on the Kubernetes cluster in the default configuration. The [configuration](#configuration) +section lists the parameters that can be configured during installation. + +## Uninstalling the Chart + +To uninstall/delete the `mailhog` deployment: + +```bash +$ helm uninstall mailhog +``` +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following table lists the configurable parameters of the Mailhog chart and their default values. + +Parameter | Description | Default +--- | --- | --- +`image.repository` | Docker image repository | `mailhog/mailhog` +`image.tag` | Docker image tag whose default is the chart version | `""` +`image.pullPolicy` | Docker image pull policy | `IfNotPresent` +`auth.enabled` | Specifies whether basic authentication is enabled, see [Auth.md](https://github.com/mailhog/MailHog/blob/master/docs/Auth.md) | `false` +`auth.existingSecret` | If auth is enabled, uses an existing secret with this name; otherwise a secret is created | `""` +`auth.fileName` | The name of the auth file | `auth.txt` +`auth.fileContents` | The contents of the auth file | `""` +`nodeSelector` | Node labels for pod assignment | `{}` +`podAnnotations` | Extra annotations to add to pod | `{}` +`podLabels` | Extra labels to add to pod | `{}` +`resources` | Pod resource requests and limits | `{}` +`tolerations` | Node taints to tolerate | `[]` +`service.annotations` | Annotations for the service | `{}` +`service.clusterIP` | Internal cluster service IP | `""` +`service.externalIPs` | Service external IP addresses | `[]` +`service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` +`service.loadBalancerSourceRanges` | List of IP CIDRs allowed access to load balancer (if supported) | `[]` +`service.type` | Type of service to create | `ClusterIP` +`service.node.http` | HTTP port of service | `""` +`service.node.smtp` | SMTP port of service | `""` +`service.nodePort.http` | If `service.type` is `NodePort` and this is non-empty, sets the http node port of the service | `""` +`service.nodePort.smtp` | If `service.type` is `NodePort` and this is non-empty, sets the smtp node port of the service | `""` +`securityContext` | Pod security context | `{ runAsUser: 1000, fsGroup: 1000, runAsNonRoot: true }` +`ingress.enabled` | If `true`, an ingress is created | `false` +`ingress.annotations` | Annotations for the ingress | `{}` +`ingress.hosts` | A list of ingress hosts | `{ host: mailhog.example.com, paths: ["/"] }` +`ingress.tls` | A list of [IngressTLS](https://v1-8.docs.kubernetes.io/docs/api-reference/v1.8/#ingresstls-v1beta1-extensions) items | `[]` +`extraEnv` | Additional environment variables, see [CONFIG.md](https://github.com/mailhog/MailHog/blob/master/docs/CONFIG.md) | `{}` diff --git a/mailhog/templates/NOTES.txt b/mailhog/templates/NOTES.txt new file mode 100644 index 0000000..678ad48 --- /dev/null +++ b/mailhog/templates/NOTES.txt @@ -0,0 +1,16 @@ +Mailhog can be accessed via ports {{ .Values.service.port.http }} (HTTP) and {{ .Values.service.port.smtp }} (SMTP) on the following DNS name from within your cluster: +{{ include "mailhog.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + +If you'd like to test your instance, forward the ports locally: + +Web UI: +======= + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mailhog.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") +kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME 8025 + +SMTP Server: +============ + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mailhog.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") +kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME 1025 diff --git a/mailhog/templates/_helpers.tpl b/mailhog/templates/_helpers.tpl new file mode 100644 index 0000000..f6d010a --- /dev/null +++ b/mailhog/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "mailhog.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 "mailhog.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 "mailhog.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name for the auth secret. +*/}} +{{- define "mailhog.authFileSecret" -}} + {{- if .Values.auth.existingSecret -}} + {{- .Values.auth.existingSecret -}} + {{- else -}} + {{- template "mailhog.fullname" . -}}-auth + {{- end -}} +{{- end -}} diff --git a/mailhog/templates/auth-secret.yaml b/mailhog/templates/auth-secret.yaml new file mode 100644 index 0000000..763aa73 --- /dev/null +++ b/mailhog/templates/auth-secret.yaml @@ -0,0 +1,14 @@ +{{- if and (.Values.auth.enabled) (not .Values.auth.existingSecret) -}} +apiVersion: v1 +kind: Secret +metadata: + labels: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + helm.sh/chart: {{ include "mailhog.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + name: {{ template "mailhog.authFileSecret" . }} +type: Opaque +data: + {{ .Values.auth.fileName }}: {{ .Values.auth.fileContents | b64enc }} +{{- end -}} diff --git a/mailhog/templates/deployment.yaml b/mailhog/templates/deployment.yaml new file mode 100644 index 0000000..6c305bf --- /dev/null +++ b/mailhog/templates/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mailhog.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + helm.sh/chart: {{ include "mailhog.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ template "mailhog.name" . }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + env: + - name: MH_HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + {{- if .Values.auth.enabled }} + - name: MH_AUTH_FILE + value: /authdir/{{ .Values.auth.fileName }} + {{- end }} + {{- with .Values.extraEnv }} + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: 8025 + protocol: TCP + - name: tcp-smtp + containerPort: 1025 + protocol: TCP + livenessProbe: + tcpSocket: + port: tcp-smtp + initialDelaySeconds: 10 + timeoutSeconds: 1 + readinessProbe: + tcpSocket: + port: tcp-smtp + {{- if .Values.auth.enabled }} + volumeMounts: + - name: authdir + mountPath: /authdir + readOnly: true + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + {{- if .Values.auth.enabled }} + - name: authdir + secret: + secretName: {{ template "mailhog.authFileSecret" . }} + {{- end }} \ No newline at end of file diff --git a/mailhog/templates/ingress.yaml b/mailhog/templates/ingress.yaml new file mode 100644 index 0000000..3b871ef --- /dev/null +++ b/mailhog/templates/ingress.yaml @@ -0,0 +1,42 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "mailhog.fullname" . -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + helm.sh/chart: {{ include "mailhog.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + {{- with .secretName }} + secretName: {{ . }} + {{- end }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + {{- $port := .port }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/mailhog/templates/service.yaml b/mailhog/templates/service.yaml new file mode 100644 index 0000000..07c570a --- /dev/null +++ b/mailhog/templates/service.yaml @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mailhog.fullname" . }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + helm.sh/chart: {{ include "mailhog.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: "{{ .Values.service.type }}" + {{- with .Values.service.clusterIP }} + clusterIP: "{{ . }}" + {{- end }} + {{- with .Values.service.externalIPs }} + externalIPs: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.service.loadBalancerIP }} + loadBalancerIP: "{{ . }}" + {{- end }} + {{- with .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- toYaml . | nindent 4 }} + {{- end }} + ports: + - name: http + port: {{ .Values.service.port.http }} + protocol: TCP + targetPort: http + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.http))) }} + nodePort: {{ .Values.service.nodePort.http }} + {{- end }} + - name: tcp-smtp + port: {{ .Values.service.port.smtp }} + protocol: TCP + targetPort: tcp-smtp + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.smtp))) }} + nodePort: {{ .Values.service.nodePort.smtp }} + {{- end }} + selector: + app.kubernetes.io/name: {{ include "mailhog.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/mailhog/values.yaml b/mailhog/values.yaml new file mode 100644 index 0000000..38d47a8 --- /dev/null +++ b/mailhog/values.yaml @@ -0,0 +1,70 @@ +image: + repository: mailhog/mailhog + tag: "" + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: "" + +service: + annotations: {} + clusterIP: "" + externalIPs: [] + loadBalancerIP: "" + loadBalancerSourceRanges: [] + type: NodePort + port: + http: 8025 + smtp: 1025 + nodePort: + http: "30030" + smtp: "30031" + +securityContext: + runAsUser: 1000 + fsGroup: 1000 + runAsNonRoot: true + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: mailhog.example.com + paths: ["/"] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +auth: + enabled: false + existingSecret: "" + fileName: auth.txt + fileContents: "" + +podAnnotations: {} + +podLabels: {} + +extraEnv: [] + +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + +affinity: {} + +nodeSelector: {} + +tolerations: []