Skip to content

Commit

Permalink
[mailhog] add support for ingress v1
Browse files Browse the repository at this point in the history
Signed-off-by: Moray Baruh <[email protected]>
  • Loading branch information
moray95 authored and Mirco Hacker committed Sep 24, 2021
1 parent a64ea8a commit 9399400
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
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: v2
description: An e-mail testing tool for developers
name: mailhog
appVersion: v1.0.1
version: 4.1.0
version: 5.0.0
type: application
keywords:
- mailhog
Expand Down
32 changes: 31 additions & 1 deletion charts/mailhog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@ Parameter | Description | Default
`ingress.enabled` | If `true`, an ingress is created | `false`
`ingress.annotations` | Annotations for the ingress | `{}`
`ingress.labels` | Labels for the ingress | `{}`
`ingress.hosts` | A list of ingress hosts | `{ host: mailhog.example.com, paths: ["/"] }`
`ingress.hosts` | A list of ingress hosts | `{ host: mailhog.example.com, paths: [{ path: "/", pathType: Prefix }] }`
`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) | `{}`

## Upgrading

### From chart < 5.0.0

Ingress path definitions are extended to describe path and pathType. Previously only the path was configured. Please adapt your configuration as shown below:

Old:
```yaml
ingress:
# ...
hosts:
- host: mailhog.example.com
# Paths for the host
paths:
- /
```
New:
```yaml
ingress:
# ...
hosts:
- host: mailhog.example.com
# Paths for the host
paths:
- path: /
pathType: Prefix
```
This allows to configure specific `pathType` configurations, e.g. `pathType: ImplementationSpecific` for [GKE Ingress on Google Cloud Platform](https://cloud.google.com/kubernetes-engine/docs/concepts/ingress#default_backend).
11 changes: 11 additions & 0 deletions charts/mailhog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,14 @@ Create the name for the outgoing-smtp secret.
{{- template "mailhog.fullname" . -}}-outgoing-smtp
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "mailhog.ingressAPIVersion" -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
{{- print "networking.k8s.io/v1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}
13 changes: 11 additions & 2 deletions charts/mailhog/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "mailhog.fullname" . -}}
apiVersion: networking.k8s.io/v1beta1
apiVersion: {{ include "mailhog.ingressAPIVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand Down Expand Up @@ -33,10 +33,19 @@ spec:
http:
paths:
{{- range .paths }}
- path: {{ . }}
- path: {{ .path }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}
port:
name: http
{{- else }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 4 additions & 1 deletion charts/mailhog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ ingress:
labels: {}
hosts:
- host: mailhog.example.com
paths: ["/"]
paths:
- path: "/"
pathType: Prefix


tls: []
# - secretName: chart-example-tls
Expand Down

0 comments on commit 9399400

Please sign in to comment.