first commit
This commit is contained in:
16
templates/NOTES.txt
Normal file
16
templates/NOTES.txt
Normal file
@@ -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
|
||||
83
templates/_helpers.tpl
Normal file
83
templates/_helpers.tpl
Normal file
@@ -0,0 +1,83 @@
|
||||
{{/* 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 -}}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "mailhog.labels" -}}
|
||||
helm.sh/chart: {{ include "mailhog.chart" . }}
|
||||
{{ include "mailhog.selectorLabels" . }}
|
||||
app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "mailhog.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "mailhog.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "mailhog.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "mailhog.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- 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 -}}
|
||||
|
||||
{{/*
|
||||
Create the name for the outgoing-smtp secret.
|
||||
*/}}
|
||||
{{- define "mailhog.outgoingSMTPSecret" -}}
|
||||
{{- if .Values.outgoingSMTP.existingSecret -}}
|
||||
{{- .Values.outgoingSMTP.existingSecret -}}
|
||||
{{- else -}}
|
||||
{{- template "mailhog.fullname" . -}}-outgoing-smtp
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
12
templates/auth-secret.yaml
Normal file
12
templates/auth-secret.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
{{- if and (.Values.auth.enabled) (not .Values.auth.existingSecret) -}}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "mailhog.labels" . | nindent 4 }}
|
||||
name: {{ template "mailhog.authFileSecret" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
type: Opaque
|
||||
data:
|
||||
{{ .Values.auth.fileName }}: {{ .Values.auth.fileContents | b64enc }}
|
||||
{{- end -}}
|
||||
129
templates/deployment.yaml
Normal file
129
templates/deployment.yaml
Normal file
@@ -0,0 +1,129 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "mailhog.fullname" . }}
|
||||
labels:
|
||||
{{- include "mailhog.labels" . | nindent 4 }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
spec:
|
||||
replicas: {{ .Values.podReplicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "mailhog.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "mailhog.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "mailhog.serviceAccountName" . }}
|
||||
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ template "mailhog.name" . }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
|
||||
env:
|
||||
{{- $vars := list }}
|
||||
{{- range .Values.extraEnv }}
|
||||
{{- $vars = append $vars .name }}
|
||||
{{- end }}
|
||||
{{- if not (has "MH_HOSTNAME" $vars) }}
|
||||
- name: MH_HOSTNAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
{{- end }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
- name: MH_AUTH_FILE
|
||||
value: /authdir/{{ .Values.auth.fileName }}
|
||||
{{- end }}
|
||||
{{- if .Values.outgoingSMTP.enabled }}
|
||||
- name: MH_OUTGOING_SMTP
|
||||
value: /config/{{ .Values.outgoingSMTP.fileName }}
|
||||
{{- end }}
|
||||
{{- with .Values.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: {{ .Values.containerPort.http.name }}
|
||||
containerPort: {{ .Values.containerPort.http.port }}
|
||||
protocol: TCP
|
||||
- name: {{ .Values.containerPort.smtp.name }}
|
||||
containerPort: {{ .Values.containerPort.smtp.port }}
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: {{ .Values.containerPort.smtp.port }}
|
||||
{{- if .Values.livenessProbe }}
|
||||
{{- toYaml .Values.livenessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: {{ .Values.containerPort.smtp.port }}
|
||||
{{- if .Values.readinessProbe }}
|
||||
{{- toYaml .Values.readinessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.auth.enabled .Values.outgoingSMTP.enabled }}
|
||||
volumeMounts:
|
||||
{{- if .Values.auth.enabled }}
|
||||
- name: authdir
|
||||
mountPath: /authdir
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.outgoingSMTP.enabled }}
|
||||
- name: outsmtpdir
|
||||
mountPath: /config
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.containerSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- with .Values.extraContainers }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.auth.enabled .Values.outgoingSMTP.enabled }}
|
||||
volumes:
|
||||
{{- if .Values.auth.enabled }}
|
||||
- name: authdir
|
||||
secret:
|
||||
secretName: {{ template "mailhog.authFileSecret" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.outgoingSMTP.enabled }}
|
||||
- name: outsmtpdir
|
||||
secret:
|
||||
secretName: {{ template "mailhog.outgoingSMTPSecret" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
64
templates/ingress.yaml
Normal file
64
templates/ingress.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "mailhog.fullname" . -}}
|
||||
{{- $apiV1 := false -}}
|
||||
{{- $apiVersion := "extensions/v1beta1" -}}
|
||||
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= v1.19.0-0" .Capabilities.KubeVersion.Version) -}}
|
||||
{{- $apiVersion = "networking.k8s.io/v1" -}}
|
||||
{{- $apiV1 = true -}}
|
||||
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
|
||||
{{- $apiVersion = "networking.k8s.io/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- $apiVersion = "extensions/v1beta1" -}}
|
||||
{{- end }}
|
||||
apiVersion: {{ $apiVersion }}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
{{- include "mailhog.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.ingress.ingressClassName }}
|
||||
ingressClassName: {{ .Values.ingress.ingressClassName }}
|
||||
{{- end }}
|
||||
{{- 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 }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if $apiV1 }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $fullName }}
|
||||
port:
|
||||
name: http
|
||||
{{- else }}
|
||||
backend:
|
||||
serviceName: {{ $fullName }}
|
||||
servicePort: http
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
49
templates/service.yaml
Normal file
49
templates/service.yaml
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "mailhog.fullname" . }}
|
||||
{{- with .Values.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "mailhog.labels" . | nindent 4 }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
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:
|
||||
{{- $httpPortName := .Values.containerPort.http.name }}
|
||||
{{- $smtpPortName := .Values.containerPort.smtp.name }}
|
||||
- name: {{ $httpPortName }}
|
||||
port: {{ .Values.service.port.http }}
|
||||
protocol: TCP
|
||||
targetPort: {{- if .Values.service.namedTargetPort }} {{ $httpPortName }} {{- else }} {{ .Values.containerPort.http.port }} {{- end }}
|
||||
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.http))) }}
|
||||
nodePort: {{ .Values.service.nodePort.http }}
|
||||
{{- end }}
|
||||
- name: {{ $smtpPortName }}
|
||||
port: {{ .Values.service.port.smtp }}
|
||||
protocol: TCP
|
||||
targetPort: {{- if .Values.service.namedTargetPort }} {{ $smtpPortName }} {{- else }} {{ .Values.containerPort.smtp.port }} {{- end }}
|
||||
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.smtp))) }}
|
||||
nodePort: {{ .Values.service.nodePort.smtp }}
|
||||
{{- end }}
|
||||
{{- if .Values.service.extraPorts }}
|
||||
{{- toYaml .Values.service.extraPorts | nindent 4 }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "mailhog.selectorLabels" . | nindent 4 }}
|
||||
11
templates/serviceaccount.yaml
Normal file
11
templates/serviceaccount.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "mailhog.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "mailhog.labels" . | nindent 4 }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.serviceAccount.imagePullSecrets | nindent 4 }}
|
||||
{{- end }}
|
||||
12
templates/smtp-secret.yaml
Normal file
12
templates/smtp-secret.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
{{- if and (.Values.outgoingSMTP.enabled) (not .Values.outgoingSMTP.existingSecret) -}}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "mailhog.labels" . | nindent 4 }}
|
||||
name: {{ template "mailhog.outgoingSMTPSecret" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
type: Opaque
|
||||
data:
|
||||
{{ .Values.outgoingSMTP.fileName }}: {{ .Values.outgoingSMTP.fileContents | toJson | b64enc }}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user