Skip to content

Commit

Permalink
[mailhog] Update Mailhog chart to latest conventions (codecentric#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Reinhard Nägele <unguiculus@gmail.com>
  • Loading branch information
unguiculus authored Apr 18, 2019
1 parent 787f93f commit 5b5aba8
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 108 deletions.
1 change: 1 addition & 0 deletions charts/mailhog/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
.project
.idea/
*.tmproj
.vscode/
2 changes: 1 addition & 1 deletion charts/mailhog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
description: An e-mail testing tool for developers
name: mailhog
appVersion: 1.0.0
version: 2.3.1
version: 3.0.0
keywords:
- mailhog
- mail
Expand Down
61 changes: 28 additions & 33 deletions charts/mailhog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.5+ with Beta APIs enabled
- Kubernetes 1.9+ with Beta APIs enabled

## Installing the Chart

Expand Down Expand Up @@ -43,32 +43,34 @@ The following table lists the configurable parameters of the Mailhog chart and t

Parameter | Description | Default
--- | --- | ---
`image.repository` | container image repository | `mailhog/mailhog`
`image.tag` | container image tag | `v1.0.0`
`image.pullPolicy` | container 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` | annotations to be added to pods | `{}`
`resources` | pod resource requests & limits | `{}`
`service.annotations` | annotations for the service | `{}`
`service.clusterIP` | internal cluster service IP | `""`
`service.externalIPs` | service external IP addresses | `[]`
`image.repository` | Docker image repository | `mailhog/mailhog`
`image.tag` | Docker image tag | `v1.0.0`
`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 | `{}`
`resources` | Pod resource requests and limits | `{}`
`nodeSelector` | Node labels for pod assignment | `{}`
`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 | `""`
`ingress.enabled` | if `true`, an ingress is created | `false`
`ingress.annotations` | annotations for the ingress | `{}`
`ingress.path` | if `true`, an ingress is created | `/`
`ingress.hosts` | a list of ingress hosts | `[mailhog.example.com]`
`ingress.tls` | a list of [IngressTLS](https://v1-8.docs.kubernetes.io/docs/api-reference/v1.8/#ingresstls-v1beta1-extensions) items | `[]`
`env` | Mailhog environment variables, see [CONFIG.md](https://github.com/mailhog/MailHog/blob/master/docs/CONFIG.md) | `{}`
`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 | `""`
`ingress.enabled` | If `true`, an ingress is created | `false`
`ingress.annotations` | Annotations for the ingress | `{}`
`ingress.path` | If `true`, an ingress is created | `/`
`ingress.hosts` | A list of ingress hosts | `[mailhog.example.com]`
`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) | `{}`

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

Expand All @@ -83,10 +85,3 @@ Alternatively, a YAML file that specifies the values for the parameters can be p
```bash
$ helm install --name my-release -f values.yaml stable/mailhog
```

## Limitations

* Disk storage not yet supported (`env.MH_STORAGE: maildir`)
* The `env` property allows Mailhog to be freely configured via environment variables, but not all settings may work,
e. g. changing ports using `MH_SMTP_BIND_ADDR`, `MH_API_BIND_ADDR`, or `MH_UI_BIND_ADDR` does not make sense with the
standard Docker image because it would also require exposing different ports.
15 changes: 2 additions & 13 deletions charts/mailhog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,9 @@ Create chart name and version as used by the chart label.
Create the name for the auth secret.
*/}}
{{- define "mailhog.authFileSecret" -}}
{{- if .Values.auth.existingKeySecret -}}
{{- .Values.auth.existingKeySecret -}}
{{- if .Values.auth.existingSecret -}}
{{- .Values.auth.existingSecret -}}
{{- else -}}
{{- template "mailhog.fullname" . -}}-auth
{{- end -}}
{{- end -}}

{{/*
Create the name for the tls secret.
*/}}
{{- define "mailhog.tlsSecret" -}}
{{- if .Values.ingress.tls.existingSecret -}}
{{- .Values.ingress.tls.existingSecret -}}
{{- else -}}
{{- template "mailhog.fullname" . -}}-tls
{{- end -}}
{{- end -}}
8 changes: 4 additions & 4 deletions charts/mailhog/templates/auth-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ apiVersion: v1
kind: Secret
metadata:
labels:
app: {{ template "mailhog.name" . }}
chart: {{ template "mailhog.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
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:
Expand Down
47 changes: 30 additions & 17 deletions charts/mailhog/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mailhog.fullname" . }}
labels:
app: {{ template "mailhog.name" . }}
chart: {{ template "mailhog.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "mailhog.fullname" . }}
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:
{{- if .Values.podAnnotations }}
{{- with .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: {{ template "mailhog.name" . }}
release: {{ .Release.Name }}
app.kubernetes.io/name: {{ include "mailhog.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
securityContext:
runAsUser: 1000
fsGroup: 1000
runAsNonRoot: true
containers:
- name: {{ template "mailhog.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand All @@ -33,9 +39,8 @@ spec:
- name: MH_AUTH_FILE
value: /authdir/{{ .Values.auth.fileName }}
{{- end }}
{{- range $key, $value := .Values.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
Expand All @@ -59,10 +64,18 @@ spec:
readOnly: true
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.auth.enabled }}
volumes:
Expand Down
29 changes: 15 additions & 14 deletions charts/mailhog/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "mailhog.fullname" . -}}
{{- $path := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "mailhog.name" . }}
chart: {{ template "mailhog.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
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 }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
- host: {{ .host | quote }}
http:
paths:
- path: {{ $path }}
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
{{- end }}
42 changes: 22 additions & 20 deletions charts/mailhog/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
name: {{ include "mailhog.fullname" . }}
{{- with .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
{{- toYaml | nindent 4 }}
{{- end }}
labels:
app: {{ template "mailhog.name" . }}
chart: {{ template "mailhog.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "mailhog.fullname" . }}
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 }}"
clusterIP: "{{ .Values.service.clusterIP }}"
{{- if .Values.service.externalIPs }}
{{- with .Values.service.clusterIP }}
clusterIP: "{{ . }}"
{{- end }}
{{- with .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.loadBalancerIP }}
loadBalancerIP: "{{ . }}"
{{- end }}
{{- with .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
ports:
- name: http
port: {{ .Values.service.port.http }}
Expand All @@ -41,5 +43,5 @@ spec:
nodePort: {{ .Values.service.nodePort.smtp }}
{{- end }}
selector:
app: {{ template "mailhog.name" . }}
release: {{ .Release.Name }}
app.kubernetes.io/name: {{ include "mailhog.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
36 changes: 30 additions & 6 deletions charts/mailhog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ image:
tag: v1.0.0
pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

service:
annotations: {}
clusterIP: ""
Expand All @@ -20,13 +23,16 @@ service:
ingress:
enabled: false
annotations: {}
path: /
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- mailhog.example.com
- host: chart-example.local
paths: []

tls: []
# - hosts:
# - mailhog.example.com
# secretName: tls-mailhog
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

auth:
enabled: false
Expand All @@ -35,5 +41,23 @@ auth:
fileContents: ""

podAnnotations: {}

extraEnv: []

resources: {}
env: {}
# 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: []

0 comments on commit 5b5aba8

Please sign in to comment.