Skip to content

Commit

Permalink
add smtp-fake-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Andru Cherny committed Jun 25, 2021
1 parent 9a0c460 commit 3b2b97e
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/smtp-fake-server/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.swp
*.bak
*.tmp
3 changes: 3 additions & 0 deletions charts/smtp-fake-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: v1
name: smtp-fake-server
version: 0.1.0
102 changes: 102 additions & 0 deletions charts/smtp-fake-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "smpt-fake-server.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 "smpt-fake-server.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 "smpt-fake-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the proper smpt-fake-server image name
*/}}
{{- define "smpt-fake-server.image" -}}
{{- $registryName := .Values.image.registry -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $tag := .Values.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}

{{/*
Return the proper image name (for the metrics image)
*/}}
{{- define "smpt-fake-server.metrics.image" -}}
{{- $registryName := .Values.metrics.image.registry -}}
{{- $repositoryName := .Values.metrics.image.repository -}}
{{- $tag := .Values.metrics.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}


{{/*
Renders a value that contains template.
Usage:
{{ include "smpt-fake-server.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "smpt-fake-server.tplValue" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}

{{/* Validate values of smpt-fake-server - must provide a valid database ssl configuration */}}
{{- define "smpt-fake-server.validateValues.db.ssl" -}}
{{- if and .Values.db.enableSsl (empty .Values.db.ssl.clientKey) (empty .Values.db.ssl.clientCertificate) (empty .Values.db.ssl.caCertificate) -}}
smpt-fake-server: db.ssl
Invalid database ssl configuration. You enabled SSL for the connection
between smpt-fake-server and the database but no key/certificates were provided
(--set db.ssl.clientKey="xxxx", --set db.ssl.clientCertificate="yyyy")
{{- end -}}
{{- end -}}
33 changes: 33 additions & 0 deletions charts/smtp-fake-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "smpt-fake-server.fullname" . }}
labels:
app: {{ template "smpt-fake-server.name" . }}
chart: {{ template "smpt-fake-server.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "smpt-fake-server.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "smpt-fake-server.name" . }}
chart: {{ template "smpt-fake-server.chart" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: {{ template "smpt-fake-server.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{/* - name: JAVA_OPTS*/}}
{{/* value: "-Ddebug=true"*/}}
- name: FAKESMTP_AUTHENTICATION_USERNAME
value: "root"
- name: FAKESMTP_AUTHENTICATION_PASSWORD
value: "root"
47 changes: 47 additions & 0 deletions charts/smtp-fake-server/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if .Values.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "smpt-fake-server.fullname" . }}
labels:
app: {{ template "smpt-fake-server.name" . }}
chart: {{ template "smpt-fake-server.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- if .Values.ingress.certManager }}
kubernetes.io/tls-acme: "true"
{{- end }}
{{- if .Values.ingress.rewriteTarget }}
ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/rewrite-target: /
{{- end }}
{{- if .Values.ingress.annotations }}
{{- include "smpt-fake-server.tplValue" (dict "value" .Values.ingress.annotations "context" $) | nindent 4 }}
{{- end }}
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .name }}
http:
paths:
- path: {{ default "/" .path }}
backend:
serviceName: {{ template "smpt-fake-server.fullname" $ }}
servicePort: http
{{- end }}
tls:
{{- range .Values.ingress.hosts }}
{{- if .tls }}
- hosts:
{{- if .tlsHosts }}
{{- range $host := .tlsHosts }}
- {{ $host }}
{{- end }}
{{- else }}
- {{ .name }}
{{- end }}
secretName: {{ .tlsSecret }}
{{- end }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/smtp-fake-server/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "smpt-fake-server.fullname" . }}
labels:
app: {{ template "smpt-fake-server.name" . }}
chart: {{ template "smpt-fake-server.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 5080
protocol: TCP
name: http

- port: 5081
targetPort: 5081
protocol: TCP
name: api

- port: 25
targetPort: 25
protocol: TCP
name: smtp

selector:
app: {{ template "smpt-fake-server.name" . }}
release: {{ .Release.Name }}
53 changes: 53 additions & 0 deletions charts/smtp-fake-server/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
replicaCount: 1

image:
registry: docker.io
repository: someblackmagic/smtp-fake-server
tag: latest
pullPolicy: Always
pullSecrets: ''

service:
type: ClusterIP
port: 80

ingress:
## Set this to true to enable ingress record generation
##
enabled: true

## Set this to true in order to add the corresponding annotations for cert-manager
##
certManager: false

## Set this to true in order to add the corresponding annotations to redirect traffic to /
##
rewriteTarget: true

## Additional Ingress annotations done as key:value pairs
## Example:
## annotations:
## kubernetes.io/ingress.class: nginx
## kubernetes.io/tls-acme: "true"
##
# annotations

## The list of hostnames to be covered with this ingress record.
## Most likely this will be just one host, but in the event more hosts are needed, this is an array
##
hosts:
- name: test.localhost
path: /

## Set this to true in order to enable TLS on the ingress record
tls: false

## Optionally specify the TLS hosts for the ingress record
## Useful when the Ingress controller supports www-redirection
## If not specified, the above host name will be used
# tlsHosts:
# - www.smpt-fake-server.local
# - smpt-fake-server.local

## If TLS is set to true, you must declare what secret will store the key/certificate for TLS
tlsSecret: smpt-fake-server.local-tls

0 comments on commit 3b2b97e

Please # to comment.