diff --git a/charts/maildev/Chart.yaml b/charts/maildev/Chart.yaml new file mode 100644 index 0000000..726e37a --- /dev/null +++ b/charts/maildev/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +description: A Helm chart for maildev +name: maildev +version: 0.0.28 diff --git a/charts/maildev/templates/_helpers.tpl b/charts/maildev/templates/_helpers.tpl new file mode 100644 index 0000000..2ed072c --- /dev/null +++ b/charts/maildev/templates/_helpers.tpl @@ -0,0 +1,38 @@ +{{- define "common.names.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "common.names.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "common.names.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 -}} + +{{- define "common.names.suffixedName" -}} +{{- $base := trunc 54 (include "common.names.fullname" .root) -}} +{{- $suffix := .suffix -}} +{{- printf "%s-%s" $base $suffix | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "common.labels.standard" -}} +app.kubernetes.io/name: {{ include "common.names.name" . }} +helm.sh/chart: {{ include "common.names.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{- define "common.labels.matchLabels" -}} +app.kubernetes.io/name: {{ include "common.names.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/maildev/templates/cron.yaml b/charts/maildev/templates/cron.yaml new file mode 100644 index 0000000..30185c9 --- /dev/null +++ b/charts/maildev/templates/cron.yaml @@ -0,0 +1,48 @@ +{{- if and .Values.persistence.enabled .Values.cron.enabled }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "common.names.fullname" . }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + schedule: {{ .Values.cron.schedule | quote }} + startingDeadlineSeconds: 100 + jobTemplate: + spec: + template: + spec: + containers: + - name: delete-mail + image: "{{ .Values.cron.image.repository }}:{{ .Values.cron.image.tag }}" + imagePullPolicy: {{ .Values.cron.image.pullPolicy }} + args: + - "find" + - "{{ .Values.persistence.mountPath }}" + - "-type" + - "f" + - "-mtime" + - "+{{ .Values.cron.daysToKeep }}" + - "-exec" + - "rm" + - "-f" + - "{}" + - ";" + volumeMounts: + - name: data + mountPath: {{ .Values.persistence.mountPath }} + - name: reload-mail + image: "{{ .Values.cron.image.repository }}:{{ .Values.cron.image.tag }}" + imagePullPolicy: {{ .Values.cron.image.pullPolicy }} + args: ["wget","{{ include "common.names.fullname" . }}:1080/reloadMailsFromDirectory"] + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ include "common.names.fullname" . }} + restartPolicy: OnFailure + {{- end }} diff --git a/charts/maildev/templates/deployment.yaml b/charts/maildev/templates/deployment.yaml new file mode 100644 index 0000000..5d8f3f2 --- /dev/null +++ b/charts/maildev/templates/deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "common.names.fullname" . }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + matchLabels: {{ include "common.labels.matchLabels" . | nindent 6 }} + template: + metadata: + {{ if .Values.podAnnotations }} + annotations: + {{- toYaml .Values.podAnnotations | nindent 8 }} + {{ end }} + labels: {{- include "common.labels.standard" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "--mail-directory" + - "{{ .Values.persistence.mountPath }}" + {{- if .Values.extraArgs }} + {{- range .Values.extraArgs }} + - {{ . | quote }} + {{- end }} + {{- end }} + volumeMounts: + - name: data + mountPath: {{ .Values.persistence.mountPath }} + ports: + - name: http + containerPort: 1080 + protocol: TCP + - name: smtp + containerPort: 1025 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: http + readinessProbe: + httpGet: + path: /healthz + port: http + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumes: + - name: data + {{- if and (.Values.persistence.enabled) }} + persistentVolumeClaim: + claimName: {{ include "common.names.fullname" . }} + {{- else }} + emptyDir: {} + {{- end }} + nodeSelector: + {{- toYaml .Values.nodeSelector | nindent 8 }} + affinity: + {{- toYaml .Values.affinity | nindent 8 }} + tolerations: + {{- toYaml .Values.tolerations | nindent 8 }} diff --git a/charts/maildev/templates/ingress.yaml b/charts/maildev/templates/ingress.yaml new file mode 100644 index 0000000..4bd8fb6 --- /dev/null +++ b/charts/maildev/templates/ingress.yaml @@ -0,0 +1,29 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "common.names.fullname" . }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + annotations: + {{- if .Values.ingress.annotations }} + {{- include "common.tplvalues.render" (dict "value" .Values.ingress.annotations "context" $) | nindent 4 }} + {{- end }} +spec: + tls: + {{- if .Values.ingress.tls }} + - hosts: + - {{ .Values.ingress.hostname | quote }} + secretName: {{ .Values.ingress.tlsSecretname }} + {{- end }} + rules: + - host: {{ .Values.ingress.hostname | quote }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "common.names.fullname" . }} + port: + name: http +{{- end }} \ No newline at end of file diff --git a/charts/maildev/templates/pvc.yaml b/charts/maildev/templates/pvc.yaml new file mode 100644 index 0000000..43d9d07 --- /dev/null +++ b/charts/maildev/templates/pvc.yaml @@ -0,0 +1,25 @@ +{{- if and (.Values.persistence.enabled) (not .Values.persistence.existingClaim) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "common.names.fullname" . }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + annotations: + {{- if .Values.commonAnnotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- if .Values.persistence.storageClass }} + {{- if (not (eq "-" .Values.persistence.storageClass)) }} + storageClassName: "{{ .Values.persistence.storageClass }}" + {{- end }} + {{- end }} + {{- end }} diff --git a/charts/maildev/templates/service.yaml b/charts/maildev/templates/service.yaml new file mode 100644 index 0000000..f44abf4 --- /dev/null +++ b/charts/maildev/templates/service.yaml @@ -0,0 +1,30 @@ +{{- if .Values.service.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "common.names.fullname" . }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + annotations: + {{- if .Values.commonAnnotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.service.annotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.service.annotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + {{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }} + clusterIP: {{ .Values.service.clusterIP }} + {{- end }} + ports: + - name: http + port: {{ .Values.service.httpPort }} + targetPort: 1080 + - name: smtp + port: {{ .Values.service.smtpPort }} + targetPort: 1025 + selector: {{ include "common.labels.matchLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/maildev/values.yaml b/charts/maildev/values.yaml new file mode 100644 index 0000000..83d4562 --- /dev/null +++ b/charts/maildev/values.yaml @@ -0,0 +1,64 @@ +fullnameOverride: "" +nameOverride: "" + +commonAnnotations: {} +commonLabels: {} + +podAnnotations: + +image: + repository: maildev/maildev + pullPolicy: IfNotPresent + tag: "2.1.0" + +persistence: + enabled: + accessMode: ReadWriteMany + size: 256M + storageClass: "" + existingClaim: "" + mountPath: /home/node/maildev-data + +cron: + enabled: + image: + repository: busybox + pullPolicy: IfNotPresent + tag: latest + schedule: "0 1 * * *" + daysToKeep: 30 + +extraArgs: [] +# - "--outgoing-host" +# - "smtp.yourdomaine.com" +# - "--outgoing-port" +# - "25" + +service: + enabled: true + type: ClusterIP + smtpPort: 1025 + httpPort: 1080 + nodePort: + clusterIP: "" + annotations: {} + +ingress: + enabled: false + annotations: {} + hostname: api.local + tlsSecretname: alerte-secours-tls + +resources: {} +# requests: +# cpu: "200m" +# memory: 500Mi +# limits: +# cpu: "100m" +# memory: 256Mi + +replicaCount: 1 + +nodeSelector: {} +tolerations: [] +affinity: {}