From 6bae2c20babf3c50aa5c92b1f3e951444c47b4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20=C4=8Cekrli=C4=87?= Date: Sun, 25 Oct 2020 17:43:58 +0100 Subject: [PATCH] Rename chart and fix minor issues --- helm/{postfix => mail}/.helmignore | 0 helm/{postfix => mail}/Chart.yaml | 2 +- helm/{postfix => mail}/charts/.gitkeep | 0 helm/{postfix => mail}/templates/NOTES.txt | 10 +++---- helm/{postfix => mail}/templates/_helpers.tpl | 26 +++++++++---------- .../templates/configmap.yaml | 2 +- helm/{postfix => mail}/templates/hpa.yaml | 2 +- helm/{postfix => mail}/templates/service.yaml | 2 +- .../templates/serviceaccount.yaml | 2 +- .../templates/statefulset.yaml | 24 ++++++++--------- helm/{postfix => mail}/values.yaml | 1 + helm/test_2_no_persistence.yml | 9 +++++++ 12 files changed, 45 insertions(+), 35 deletions(-) rename helm/{postfix => mail}/.helmignore (100%) rename helm/{postfix => mail}/Chart.yaml (98%) rename helm/{postfix => mail}/charts/.gitkeep (100%) rename helm/{postfix => mail}/templates/NOTES.txt (70%) rename helm/{postfix => mail}/templates/_helpers.tpl (75%) rename helm/{postfix => mail}/templates/configmap.yaml (95%) rename helm/{postfix => mail}/templates/hpa.yaml (97%) rename helm/{postfix => mail}/templates/service.yaml (95%) rename helm/{postfix => mail}/templates/serviceaccount.yaml (94%) rename helm/{postfix => mail}/templates/statefulset.yaml (91%) rename helm/{postfix => mail}/values.yaml (97%) diff --git a/helm/postfix/.helmignore b/helm/mail/.helmignore similarity index 100% rename from helm/postfix/.helmignore rename to helm/mail/.helmignore diff --git a/helm/postfix/Chart.yaml b/helm/mail/Chart.yaml similarity index 98% rename from helm/postfix/Chart.yaml rename to helm/mail/Chart.yaml index e8aadcb..b9e151a 100644 --- a/helm/postfix/Chart.yaml +++ b/helm/mail/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: postfix +name: mail description: Helm chart for Postfix mail server # A chart can be either an 'application' or a 'library' chart. diff --git a/helm/postfix/charts/.gitkeep b/helm/mail/charts/.gitkeep similarity index 100% rename from helm/postfix/charts/.gitkeep rename to helm/mail/charts/.gitkeep diff --git a/helm/postfix/templates/NOTES.txt b/helm/mail/templates/NOTES.txt similarity index 70% rename from helm/postfix/templates/NOTES.txt rename to helm/mail/templates/NOTES.txt index 4863717..476c09e 100644 --- a/helm/postfix/templates/NOTES.txt +++ b/helm/mail/templates/NOTES.txt @@ -1,16 +1,16 @@ Postfix service installed. Send email by using the following address and port: {{- if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "postfix.fullname" . }}) + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mail.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "postfix.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "postfix.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mail.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mail.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "postfix.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mail.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 587:587 {{- end }} diff --git a/helm/postfix/templates/_helpers.tpl b/helm/mail/templates/_helpers.tpl similarity index 75% rename from helm/postfix/templates/_helpers.tpl rename to helm/mail/templates/_helpers.tpl index 7f61032..0938c8b 100644 --- a/helm/postfix/templates/_helpers.tpl +++ b/helm/mail/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{- define "postfix.name" -}} +{{- define "mail.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -11,7 +11,7 @@ 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 "postfix.fullname" -}} +{{- define "mail.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "postfix.chart" -}} +{{- define "mail.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "postfix.labels" -}} -helm.sh/chart: {{ include "postfix.chart" . }} -{{ include "postfix.selectorLabels" . }} +{{- define "mail.labels" -}} +helm.sh/chart: {{ include "mail.chart" . }} +{{ include "mail.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -46,17 +46,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "postfix.selectorLabels" -}} -app.kubernetes.io/name: {{ include "postfix.name" . }} +{{- define "mail.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mail.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "postfix.serviceAccountName" -}} +{{- define "mail.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "postfix.fullname" .) .Values.serviceAccount.name }} +{{- default (include "mail.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} @@ -65,13 +65,13 @@ Create the name of the service account to use {{/* Define checksum annotations */}} -{{- define "postfix.checksums" -}} +{{- define "mail.checksums" -}} # Reload for Statefulset when configmap changes on deployment checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} {{- end -}} -{{- define "postfix.reloader" -}} +{{- define "mail.reloader" -}} # Auto-reload postfix if somebody changes config map directly in Kuberentes. # Uses: https://github.com/stakater/Reloader -configmap.reloader.stakater.com/reload: "{{ include "postfix.fullname" . }}" +configmap.reloader.stakater.com/reload: "{{ include "mail.fullname" . }}" {{- end -}} diff --git a/helm/postfix/templates/configmap.yaml b/helm/mail/templates/configmap.yaml similarity index 95% rename from helm/postfix/templates/configmap.yaml rename to helm/mail/templates/configmap.yaml index 820dd20..5b94586 100644 --- a/helm/postfix/templates/configmap.yaml +++ b/helm/mail/templates/configmap.yaml @@ -1,4 +1,4 @@ -{{- $chart := "postfix" -}} +{{- $chart := "mail" -}} {{- $fullName := include (print $chart ".fullname") . -}} {{- $labels := include (print $chart ".labels") . -}} {{- $files := .Files -}} diff --git a/helm/postfix/templates/hpa.yaml b/helm/mail/templates/hpa.yaml similarity index 97% rename from helm/postfix/templates/hpa.yaml rename to helm/mail/templates/hpa.yaml index 11142af..7729f9d 100644 --- a/helm/postfix/templates/hpa.yaml +++ b/helm/mail/templates/hpa.yaml @@ -1,5 +1,5 @@ {{- if .Values.autoscaling.enabled }} -{{- $chart := "postfix" -}} +{{- $chart := "mail" -}} {{- $fullName := include (print $chart ".fullname") . -}} {{- $labels := include (print $chart ".labels") . -}} {{- $kind := "StatefulSet" -}} diff --git a/helm/postfix/templates/service.yaml b/helm/mail/templates/service.yaml similarity index 95% rename from helm/postfix/templates/service.yaml rename to helm/mail/templates/service.yaml index 58f6337..7bff750 100644 --- a/helm/postfix/templates/service.yaml +++ b/helm/mail/templates/service.yaml @@ -1,4 +1,4 @@ -{{- $chart := "postfix" -}} +{{- $chart := "mail" -}} {{- $fullName := include (print $chart ".fullname") . -}} {{- $labels := include (print $chart ".labels") . -}} {{- $selectorLabels := include (print $chart ".selectorLabels") . -}} diff --git a/helm/postfix/templates/serviceaccount.yaml b/helm/mail/templates/serviceaccount.yaml similarity index 94% rename from helm/postfix/templates/serviceaccount.yaml rename to helm/mail/templates/serviceaccount.yaml index 25f5084..2f59c5c 100644 --- a/helm/postfix/templates/serviceaccount.yaml +++ b/helm/mail/templates/serviceaccount.yaml @@ -1,5 +1,5 @@ {{- if .Values.serviceAccount.create -}} -{{- $chart := "postfix" -}} +{{- $chart := "mail" -}} {{- $labels := include (print $chart ".labels") . -}} {{- $serviceAccountName := include (print $chart ".serviceAccountName") . -}} apiVersion: v1 diff --git a/helm/postfix/templates/statefulset.yaml b/helm/mail/templates/statefulset.yaml similarity index 91% rename from helm/postfix/templates/statefulset.yaml rename to helm/mail/templates/statefulset.yaml index 60a2a2f..bb47175 100644 --- a/helm/postfix/templates/statefulset.yaml +++ b/helm/mail/templates/statefulset.yaml @@ -1,4 +1,4 @@ -{{- $chart := "postfix" -}} +{{- $chart := "mail" -}} {{- $fullName := include (print $chart ".fullname") . -}} {{- $labels := include (print $chart ".labels") . -}} {{- $reloaderAnnotations := include (print $chart ".reloader") . -}} @@ -55,22 +55,21 @@ spec: containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} securityContext: {{- toYaml .Values.container.postfix.securityContext | indent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" ports: - name: smtp containerPort: 587 protocol: TCP readinessProbe: initialDelaySeconds: 10 - periodSeconds: 60 + periodSeconds: 30 tcpSocket: port: 587 livenessProbe: initialDelaySeconds: 10 - periodSeconds: 120 + periodSeconds: 60 tcpSocket: port: 587 envFrom: @@ -82,7 +81,14 @@ spec: name: {{ $fullName }} {{- with .Values.extraVolumeMounts }}{{- toYaml . | nindent 12 }}{{ end }} resources: {{ toYaml .Values.resources | nindent 12 }} - + {{- if .Values.persistence.enabled }} + {{- with .Values.extraVolumes }}volumes: {{- toYaml . | nindent 8 }}{{ end }} + {{- else }} + volumes: + - name: {{ $fullName }} + emptyDir: {} + {{- with .Values.extraVolumes }}{{- toYaml . | nindent 8 }}{{ end }} + {{- end }} {{- if .Values.persistence.enabled }} volumeClaimTemplates: - metadata: @@ -98,10 +104,4 @@ spec: resources: requests: storage: {{ .Values.persistence.size | quote }} - {{ with .Values.extraVolumes }}volumes: {{- toYaml . | nindent 4 }}{{ end }} - {{- else }} - volumes: - - name: {{ $fullName }} - emptyDir: {} - {{- with .Values.extraVolumes }}{{- toYaml . | nindent 4 }}{{ end }} {{- end }} diff --git a/helm/postfix/values.yaml b/helm/mail/values.yaml similarity index 97% rename from helm/postfix/values.yaml rename to helm/mail/values.yaml index 6c6a110..d3e99d1 100644 --- a/helm/postfix/values.yaml +++ b/helm/mail/values.yaml @@ -2,6 +2,7 @@ replicaCount: 1 image: repository: boky/postfix + # tag: "" # If not specified uses chart's AppVersion as the tag pullPolicy: IfNotPresent imagePullSecrets: [] diff --git a/helm/test_2_no_persistence.yml b/helm/test_2_no_persistence.yml index 4d6af8b..36404f0 100644 --- a/helm/test_2_no_persistence.yml +++ b/helm/test_2_no_persistence.yml @@ -1,2 +1,11 @@ +image: + tag: v2.0.1 # Override version from Chart's AppVersion + persistence: enabled: false + +config: + general: + TZ: Europe/London + ALLOWED_SENDER_DOMAINS: example.org + FORCE_COLOR: "1"