From 4046d570f944c9fe2fdf72e6f30c18f33e34e7b2 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 25 Sep 2022 19:23:21 +0200
Subject: [PATCH] feat(mok): Add ability to set define hostname for postfix

This patch allows to set the `HOSTNAME` variable, which should
explicitly set the hostname for the postfix pod and configure it to use
the proper external DNS name.
---
 charts/mok/Chart.yaml             | 2 +-
 charts/mok/README.md              | 3 ++-
 charts/mok/templates/postfix.yaml | 4 ++++
 charts/mok/values.yaml            | 2 ++
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/charts/mok/Chart.yaml b/charts/mok/Chart.yaml
index 94bf2a520..edf7bddc5 100644
--- a/charts/mok/Chart.yaml
+++ b/charts/mok/Chart.yaml
@@ -3,7 +3,7 @@ name: mok
 description: |
   Mail on Kubernetes (MoK) is a project to deploy a functional mailserver that runs without a database server on Kubernetes, taking advantage of configmaps and secret.
 type: application
-version: 0.5.2
+version: 0.6.0
 sources:
   - https://de.postfix.org/ftpmirror/index.html
   - https://github.com/dovecot/core
diff --git a/charts/mok/README.md b/charts/mok/README.md
index 69a685b3c..6ffc8aba3 100644
--- a/charts/mok/README.md
+++ b/charts/mok/README.md
@@ -1,6 +1,6 @@
 # mok
 
-![Version: 0.5.2](https://img.shields.io/badge/Version-0.5.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
+![Version: 0.6.0](https://img.shields.io/badge/Version-0.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
 
 Mail on Kubernetes (MoK) is a project to deploy a functional mailserver that runs without a database server on Kubernetes, taking advantage of configmaps and secret.
 
@@ -53,6 +53,7 @@ Mail on Kubernetes (MoK) is a project to deploy a functional mailserver that run
 | nameOverride | string | `""` |  |
 | networkPolicy.create | bool | `true` | Create NetworkPolicies to access the mailserver from outside |
 | postfix.affinity | object | `{}` |  |
+| postfix.hostname | string | `nil` | explicitly set postfix hostname |
 | postfix.image.pullPolicy | string | `"IfNotPresent"` |  |
 | postfix.image.repository | string | `"quay.io/shivering-isles/postfix"` | postfix container image |
 | postfix.image.tag | string | `"0.2.3"` | Overrides the image tag whose default is "latest" |
diff --git a/charts/mok/templates/postfix.yaml b/charts/mok/templates/postfix.yaml
index 6a3e32405..ab3b7ae5b 100644
--- a/charts/mok/templates/postfix.yaml
+++ b/charts/mok/templates/postfix.yaml
@@ -75,6 +75,10 @@ spec:
           env:
             - name: DOVECOT_SERVICE_NAME
               value: {{ include "mok.fullname" . }}-dovecot-internal.{{ .Release.Namespace }}.svc.cluster.local
+            {{- if .Values.postfix.hostname }}
+            - name: HOSTNAME
+              value: {{ .Values.postfix.hostname }}
+            {{- end }}
           image: {{ .Values.postfix.image.repository }}:{{.Values.postfix.image.tag | default "latest" }}
           imagePullPolicy: {{ .Values.postfix.image.pullPolicy }}
           lifecycle:
diff --git a/charts/mok/values.yaml b/charts/mok/values.yaml
index 816aa2e3b..58fd3b811 100644
--- a/charts/mok/values.yaml
+++ b/charts/mok/values.yaml
@@ -36,6 +36,8 @@ relay:
 
 
 postfix:
+  # -- explicitly set postfix hostname
+  hostname: null
   # -- Number of postfix pods.
   replicaCount: 1
 
-- 
GitLab