Certificates for the mail ports: TLS Secrets, cert-manager, ACME routes (K-C8) #26
No files matched your search
@@ -52,6 +52,12 @@ runs, pinned by digest.
|
||||
passwords between all users would ban the ingress for everyone.
|
||||
`server.trustedProxies` lists the proxies when the pod network isn't a
|
||||
private range. Needs server 27.1-rc.32; older servers ignore it.
|
||||
- Certificates for the mail ports (`server.certificates`): TLS Secrets
|
||||
(`secrets`, or `certManager` to have the chart ask cert-manager for one)
|
||||
mounted in every server pod and reread within about two minutes of a
|
||||
renewal, with no restart; and `acmeHosts`, which routes the server's own
|
||||
ACME HTTP-01 challenges for the mail names to it. Needs server
|
||||
27.1-rc.33.
|
||||
- Mail out from a known address (`server.egress`): with
|
||||
`expectedAddresses` and `checkUrl` set, a Job placed like the mta pods
|
||||
asks which address it leaves from after each install and upgrade, and
|
||||
|
||||
@@ -22,6 +22,13 @@ server:
|
||||
trustedProxies: [10.0.0.0/8, 100.64.0.0/10]
|
||||
listeners:
|
||||
pop3s: 995
|
||||
certificates:
|
||||
acmeHosts: [mx.example.org]
|
||||
secrets: [mail-tls]
|
||||
certManager:
|
||||
enabled: true
|
||||
issuerRef: {name: letsencrypt, kind: ClusterIssuer}
|
||||
dnsNames: [mail.example.org, mx.example.org]
|
||||
egress:
|
||||
expectedAddresses: [198.51.100.7, "2001:db8::7"]
|
||||
checkUrl: https://ip.example.org/
|
||||
|
||||
@@ -154,3 +154,26 @@ Call with (dict "url" .Values.webmail.publicUrl "name" "webmail").
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
The TLS Secrets mounted in the server pods, space-separated: the ones named
|
||||
in server.certificates.secrets, and the one cert-manager issues for the
|
||||
chart.
|
||||
*/}}
|
||||
{{- define "inbuxa.server.tlsSecrets" -}}
|
||||
{{- $c := .Values.server.certificates }}
|
||||
{{- $names := $c.secrets }}
|
||||
{{- if $c.certManager.enabled }}
|
||||
{{- $names = append $names (printf "%s-mail-tls" (include "inbuxa.fullname" .)) }}
|
||||
{{- end }}
|
||||
{{- join " " (uniq $names) }}
|
||||
{{- end }}
|
||||
|
||||
{{/* INBUXA_TLS_CERTIFICATE_DIRS for a list of TLS Secret names */}}
|
||||
{{- define "inbuxa.server.tlsDirs" -}}
|
||||
{{- $dirs := list }}
|
||||
{{- range . }}
|
||||
{{- $dirs = append $dirs (printf "/etc/inbuxa/tls/%s" .) }}
|
||||
{{- end }}
|
||||
{{- join "," $dirs }}
|
||||
{{- end }}
|
||||
@@ -5,6 +5,11 @@ SPDX-License-Identifier: Apache-2.0
|
||||
Routes from outside, one per public address, by host name: the server's
|
||||
publicUrl to its HTTP Service, and the webmail's and the console's to
|
||||
theirs. Gateway API HTTPRoutes, or an Ingress where there's no Gateway.
|
||||
|
||||
For the server's own ACME with HTTP-01, the names in
|
||||
server.certificates.acmeHosts get one more route: their
|
||||
/.well-known/acme-challenge/ to the server, which answers the challenge on
|
||||
any pod. A name the server's publicUrl already routes needs nothing more.
|
||||
*/}}
|
||||
{{- $root := . }}
|
||||
{{- $routes := .Values.routes }}
|
||||
@@ -26,6 +31,19 @@ theirs. Gateway API HTTPRoutes, or an Ingress where there's no Gateway.
|
||||
{{- end }}
|
||||
{{- $_ := set $hosts .host .name }}
|
||||
{{- end }}
|
||||
{{- $acmeHosts := list }}
|
||||
{{- range .Values.server.certificates.acmeHosts }}
|
||||
{{- if ne (get $hosts .) "server" }}
|
||||
{{- if hasKey $hosts . }}
|
||||
{{- fail (printf "server.certificates.acmeHosts: %s is the %s's host; the server's ACME challenges can't share it" . (get $hosts .)) }}
|
||||
{{- end }}
|
||||
{{- $acmeHosts = append $acmeHosts . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $acmeHosts = uniq $acmeHosts }}
|
||||
{{- if and $acmeHosts (not (or $routes.gateway.enabled $routes.ingress.enabled)) }}
|
||||
{{- fail "server.certificates.acmeHosts: turn on routes.gateway or routes.ingress to route the challenges, or use DNS-01" }}
|
||||
{{- end }}
|
||||
{{- if and $routes.gateway.enabled $routes.ingress.enabled }}
|
||||
{{- fail "routes: turn on gateway or ingress, not both" }}
|
||||
{{- end }}
|
||||
@@ -64,6 +82,35 @@ spec:
|
||||
- name: {{ .service }}
|
||||
port: 8080
|
||||
{{- end }}
|
||||
{{- if $acmeHosts }}
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: {{ printf "%s-acme" $full }}
|
||||
namespace: {{ $root.Release.Namespace }}
|
||||
labels:
|
||||
{{- include "inbuxa.labels" $root | nindent 4 }}
|
||||
app.kubernetes.io/component: server
|
||||
{{- with $routes.gateway.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
# The Gateway needs an HTTP listener on port 80 for these names
|
||||
parentRefs:
|
||||
{{- toYaml $routes.gateway.parentRefs | nindent 4 }}
|
||||
hostnames:
|
||||
{{- toYaml $acmeHosts | nindent 4 }}
|
||||
rules:
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /.well-known/acme-challenge/
|
||||
backendRefs:
|
||||
- name: {{ printf "%s-http" $full }}
|
||||
port: 8080
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $routes.ingress.enabled }}
|
||||
---
|
||||
@@ -99,4 +146,16 @@ spec:
|
||||
port:
|
||||
name: http
|
||||
{{- end }}
|
||||
{{- range $acmeHosts }}
|
||||
- host: {{ . | quote }}
|
||||
http:
|
||||
paths:
|
||||
- path: /.well-known/acme-challenge/
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ printf "%s-http" $full }}
|
||||
port:
|
||||
name: http
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,41 @@
|
||||
{{/*
|
||||
SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
A cert-manager Certificate for the mail host names, when
|
||||
server.certificates.certManager is on. cert-manager keeps it in the Secret
|
||||
<release>-mail-tls; the server pods mount it and reread it when it's
|
||||
renewed. Until it's first issued, the pods wait for the Secret.
|
||||
*/}}
|
||||
{{- $root := . }}
|
||||
{{- $cm := .Values.server.certificates.certManager }}
|
||||
{{- if $cm.enabled }}
|
||||
{{- if not $cm.issuerRef.name }}
|
||||
{{- fail "server.certificates.certManager.issuerRef: name the Issuer or ClusterIssuer" }}
|
||||
{{- end }}
|
||||
{{- if not $cm.dnsNames }}
|
||||
{{- fail "server.certificates.certManager.dnsNames: name the mail host names" }}
|
||||
{{- end }}
|
||||
{{- $name := printf "%s-mail-tls" (include "inbuxa.fullname" $root) }}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: {{ $name }}
|
||||
namespace: {{ $root.Release.Namespace }}
|
||||
labels:
|
||||
{{- include "inbuxa.labels" $root | nindent 4 }}
|
||||
app.kubernetes.io/component: server
|
||||
spec:
|
||||
secretName: {{ $name }}
|
||||
dnsNames:
|
||||
{{- toYaml $cm.dnsNames | nindent 4 }}
|
||||
issuerRef:
|
||||
name: {{ $cm.issuerRef.name }}
|
||||
kind: {{ $cm.issuerRef.kind | default "Issuer" }}
|
||||
group: {{ $cm.issuerRef.group | default "cert-manager.io" }}
|
||||
{{- with $cm.renewBefore }}
|
||||
renewBefore: {{ . }}
|
||||
{{- end }}
|
||||
privateKey:
|
||||
rotationPolicy: Always
|
||||
{{- end }}
|
||||
@@ -8,6 +8,7 @@ are interchangeable: Deployments, not StatefulSets.
|
||||
*/}}
|
||||
{{- $root := . }}
|
||||
{{- $server := .Values.server }}
|
||||
{{- $tlsSecrets := splitList " " (include "inbuxa.server.tlsSecrets" $root) | compact }}
|
||||
{{- range $group := list "front" "mta" "core" }}
|
||||
{{- $g := index $server.groups $group }}
|
||||
{{- if $g.enabled }}
|
||||
@@ -191,6 +192,11 @@ spec:
|
||||
# sign-ins and anonymous requests aren't charged to the proxy
|
||||
- name: INBUXA_HTTP_USE_FORWARDED
|
||||
value: "true"
|
||||
{{- if $tlsSecrets }}
|
||||
# Certificates from TLS Secrets, reread when they're renewed
|
||||
- name: INBUXA_TLS_CERTIFICATE_DIRS
|
||||
value: {{ include "inbuxa.server.tlsDirs" $tlsSecrets | quote }}
|
||||
{{- end }}
|
||||
{{- with $server.trustedProxies }}
|
||||
- name: INBUXA_HTTP_TRUSTED_PROXIES
|
||||
value: {{ join "," . | quote }}
|
||||
@@ -281,6 +287,12 @@ spec:
|
||||
mountPath: /etc/inbuxa/webmail
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- range $i, $name := $tlsSecrets }}
|
||||
# A whole directory, never a subPath: a renewal reaches the pod
|
||||
- name: tls-{{ $i }}
|
||||
mountPath: /etc/inbuxa/tls/{{ $name }}
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
- name: data
|
||||
mountPath: /var/lib/inbuxa
|
||||
- name: tmp
|
||||
@@ -313,6 +325,15 @@ spec:
|
||||
path: oauth-client-secret
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $i, $name := $tlsSecrets }}
|
||||
- name: tls-{{ $i }}
|
||||
secret:
|
||||
secretName: {{ $name }}
|
||||
defaultMode: 0440
|
||||
items:
|
||||
- {key: tls.crt, path: tls.crt}
|
||||
- {key: tls.key, path: tls.key}
|
||||
{{- end }}
|
||||
# Scratch only: everything lasting is in the data store
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
suite: certificates
|
||||
templates:
|
||||
- server/certificate.yaml
|
||||
- server/deployment.yaml
|
||||
release:
|
||||
name: mail
|
||||
namespace: inbuxa
|
||||
values:
|
||||
- ../ci/defaults-values.yaml
|
||||
tests:
|
||||
- it: mounts no certificates unless asked
|
||||
template: server/deployment.yaml
|
||||
documentIndex: 0
|
||||
asserts:
|
||||
- notContains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: INBUXA_TLS_CERTIFICATE_DIRS}
|
||||
any: true
|
||||
|
||||
- it: asks cert-manager for nothing unless asked
|
||||
template: server/certificate.yaml
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: mounts each TLS Secret whole, so renewals reach the pod
|
||||
template: server/deployment.yaml
|
||||
set:
|
||||
server.certificates.secrets: [mail-tls, mx-tls]
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: INBUXA_TLS_CERTIFICATE_DIRS, value: "/etc/inbuxa/tls/mail-tls,/etc/inbuxa/tls/mx-tls"}
|
||||
documentIndex: 1
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content: {name: tls-1, mountPath: /etc/inbuxa/tls/mx-tls, readOnly: true}
|
||||
documentIndex: 2
|
||||
- contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: tls-0
|
||||
secret:
|
||||
secretName: mail-tls
|
||||
defaultMode: 0440
|
||||
items: [{key: tls.crt, path: tls.crt}, {key: tls.key, path: tls.key}]
|
||||
documentIndex: 0
|
||||
|
||||
- it: asks cert-manager for the mail names, and mounts what it issues
|
||||
set:
|
||||
server.certificates.certManager:
|
||||
enabled: true
|
||||
issuerRef: {name: letsencrypt, kind: ClusterIssuer}
|
||||
dnsNames: [mail.example.org, mx.example.org]
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
secretName: mail-inbuxa-mail-tls
|
||||
dnsNames: [mail.example.org, mx.example.org]
|
||||
issuerRef: {name: letsencrypt, kind: ClusterIssuer, group: cert-manager.io}
|
||||
privateKey: {rotationPolicy: Always}
|
||||
template: server/certificate.yaml
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: INBUXA_TLS_CERTIFICATE_DIRS, value: /etc/inbuxa/tls/mail-inbuxa-mail-tls}
|
||||
template: server/deployment.yaml
|
||||
documentIndex: 0
|
||||
|
||||
- it: needs an issuer and names
|
||||
template: server/certificate.yaml
|
||||
set:
|
||||
server.certificates.certManager.enabled: true
|
||||
server.certificates.certManager.dnsNames: [mail.example.org]
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: issuerRef
|
||||
@@ -269,3 +269,60 @@ tests:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "routes.gateway.parentRefs"
|
||||
|
||||
- it: sends the ACME challenges for the mail host names to the server
|
||||
template: routes.yaml
|
||||
set:
|
||||
routes.gateway.enabled: true
|
||||
routes.gateway.parentRefs: [{name: public, namespace: gateway}]
|
||||
server.certificates.acmeHosts: [mx.example.org, mail.example.org, mx.example.org]
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: mail-inbuxa-acme
|
||||
documentIndex: 3
|
||||
- equal:
|
||||
path: spec.hostnames
|
||||
value: [mx.example.org]
|
||||
documentIndex: 3
|
||||
- equal:
|
||||
path: spec.rules[0]
|
||||
value:
|
||||
matches: [{path: {type: PathPrefix, value: /.well-known/acme-challenge/}}]
|
||||
backendRefs: [{name: mail-inbuxa-http, port: 8080}]
|
||||
documentIndex: 3
|
||||
|
||||
- it: and through the Ingress
|
||||
template: routes.yaml
|
||||
set:
|
||||
routes.ingress.enabled: true
|
||||
server.certificates.acmeHosts: [mx.example.org]
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[3]
|
||||
value:
|
||||
host: mx.example.org
|
||||
http:
|
||||
paths:
|
||||
- path: /.well-known/acme-challenge/
|
||||
pathType: Prefix
|
||||
backend: {service: {name: mail-inbuxa-http, port: {name: http}}}
|
||||
|
||||
- it: refuses an ACME host that's a front end's
|
||||
template: routes.yaml
|
||||
set:
|
||||
routes.ingress.enabled: true
|
||||
server.certificates.acmeHosts: [webmail.example.org]
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "webmail.example.org is the webmail's host"
|
||||
|
||||
- it: refuses ACME hosts with no routes to carry them
|
||||
template: routes.yaml
|
||||
set:
|
||||
server.certificates.acmeHosts: [mx.example.org]
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "turn on routes.gateway or routes.ingress"
|
||||
@@ -246,6 +246,38 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"certificates": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"acmeHosts": {
|
||||
"type": "array",
|
||||
"items": {"type": "string", "pattern": "^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$"}
|
||||
},
|
||||
"secrets": {
|
||||
"type": "array",
|
||||
"items": {"type": "string", "pattern": "^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$"}
|
||||
},
|
||||
"certManager": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {"type": "boolean"},
|
||||
"issuerRef": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"kind": {"type": "string", "enum": ["Issuer", "ClusterIssuer"]},
|
||||
"group": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"dnsNames": {"type": "array", "items": {"type": "string"}},
|
||||
"renewBefore": {"type": "string"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"egress": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
||||
@@ -181,6 +181,30 @@ server:
|
||||
expectedAddresses: []
|
||||
checkUrl: ""
|
||||
|
||||
# Certificates for the mail ports (SMTP STARTTLS, submissions, IMAPS,
|
||||
# POP3S, ManageSieve). HTTPS from outside is the Gateway's or the
|
||||
# Ingress's (routes below). Two ways:
|
||||
# - The server's own ACME (an ACME provider set up in the seed or the
|
||||
# console): certificates are kept in the store, and every pod uses them.
|
||||
# DNS-01 needs nothing here. For HTTP-01, name the hosts in acmeHosts:
|
||||
# the routes send their /.well-known/acme-challenge/ to the server.
|
||||
# - TLS Secrets (kubernetes.io/tls), mounted in every server pod and used
|
||||
# as they are: existing ones in secrets, or certManager to have the
|
||||
# chart ask cert-manager for one. The pods reread them within about two
|
||||
# minutes of a renewal, with no restart. Needs server 27.1-rc.33.
|
||||
certificates:
|
||||
acmeHosts: []
|
||||
# Names of Secrets in this namespace, each with tls.crt and tls.key
|
||||
secrets: []
|
||||
certManager:
|
||||
enabled: false
|
||||
# The Issuer or ClusterIssuer, e.g. {name: letsencrypt, kind: ClusterIssuer}
|
||||
issuerRef: {}
|
||||
# The mail host names, e.g. [mail.example.org, mx.example.org]
|
||||
dnsNames: []
|
||||
# Renew this long before expiry; empty is cert-manager's default
|
||||
renewBefore: ""
|
||||
|
||||
# Used for every group that sets no resources of its own
|
||||
resources:
|
||||
requests:
|
||||
|
||||
Reference in new issue
Block a user