Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion charts/docker-mailserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,23 @@ If you do not enable the PROXY protocol and your mail server is not exposed usin

### Rspamd web interface and metrics

The Rspamd web interface (port 11334) and the metrics exporter (`monitoring.service.port`, 9102 by default) are not on the main Service. They are on a separate ClusterIP Service named `<fullname>-internal`, so a main Service of type `LoadBalancer` or `NodePort` never publishes them outside the cluster. The Rspamd ingress (`rspamd.ingress`) and the ServiceMonitor (`metrics.serviceMonitor`) use the internal Service, and it carries the `prometheus.io/*` annotations. `service.labels`, `service.ipFamilyPolicy` and `service.ipFamilies` apply to both Services.
The Rspamd web interface (port 11334) and the metrics exporter (`monitoring.service.port`, 9102 by default) are not on the main Service. They are on a separate ClusterIP Service named `<fullname>-internal`, so a main Service of type `LoadBalancer` or `NodePort` never publishes them outside the cluster. The Rspamd ingress (`rspamd.ingress`), the Rspamd HTTPRoute (`rspamd.httpRoute`) and the ServiceMonitor (`metrics.serviceMonitor`) use the internal Service, and it carries the `prometheus.io/*` annotations. `service.labels`, `service.ipFamilyPolicy` and `service.ipFamilies` apply to both Services.

If you reached the Rspamd web interface or scraped the metrics through the main Service before (a port-forward, an annotation-based scrape, or an external address), use `<fullname>-internal` instead.

To expose the web interface through the [Gateway API](https://gateway-api.sigs.k8s.io/) instead of an ingress, enable `rspamd.httpRoute` and set `rspamd.httpRoute.parentRefs` to your Gateway:

```yaml
rspamd:
httpRoute:
enabled: true
parentRefs:
- name: gateway
namespace: gateway-system
hostnames:
- rspamd.example.com
```

## Persistence

Docker-mailserver assumes there are [four](https://docker-mailserver.github.io/docker-mailserver/latest/config/advanced/optional-config/#volumes) mounted volumes:
Expand Down
36 changes: 36 additions & 0 deletions charts/docker-mailserver/templates/httproute-rspamd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if and (.Values.deployment.env.ENABLE_RSPAMD) (.Values.rspamd.httpRoute.enabled) -}}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
labels:
app.kubernetes.io/name: {{ template "dockermailserver.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
{{- with .Values.rspamd.httpRoute.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
name: {{ template "dockermailserver.fullname" . }}-rspamd
{{- with .Values.rspamd.httpRoute.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
parentRefs:
{{- if not .Values.rspamd.httpRoute.parentRefs }}
{{- fail "rspamd.httpRoute.parentRefs is required" }}
{{- end }}
{{ toYaml .Values.rspamd.httpRoute.parentRefs | indent 4 }}
{{- with .Values.rspamd.httpRoute.hostnames }}
hostnames:
{{ toYaml . | indent 4 }}
{{- end }}
rules:
- matches:
- path:
type: PathPrefix
value: {{ .Values.rspamd.httpRoute.path }}
backendRefs:
- name: {{ template "dockermailserver.fullname" . }}-internal
port: 11334
{{- end }}
62 changes: 62 additions & 0 deletions charts/docker-mailserver/tests/httproute_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
suite: rspamd httproute tests
templates:
- httproute-rspamd.yaml
chart:
version: 0.1.0
appVersion: 0.1.0
values:
- ../values.yaml
tests:
- it: is not rendered by default
asserts:
- hasDocuments:
count: 0

- it: routes to the rspamd port on the internal service
set:
rspamd.httpRoute.enabled: true
rspamd.httpRoute.parentRefs:
- name: gateway
namespace: gateway-system
sectionName: https
rspamd.httpRoute.hostnames:
- rspamd.example.com
asserts:
- isKind:
of: HTTPRoute
- matchRegex:
path: metadata.name
pattern: -docker-mailserver-rspamd$
- equal:
path: spec.parentRefs[0].name
value: gateway
- equal:
path: spec.hostnames
value:
- rspamd.example.com
- equal:
path: spec.rules[0].matches[0].path.value
value: /
- matchRegex:
path: spec.rules[0].backendRefs[0].name
pattern: -docker-mailserver-internal$
- equal:
path: spec.rules[0].backendRefs[0].port
value: 11334

- it: is not rendered when rspamd is disabled
set:
deployment.env.ENABLE_RSPAMD: 0
rspamd.httpRoute.enabled: true
rspamd.httpRoute.parentRefs:
- name: gateway
asserts:
- hasDocuments:
count: 0

- it: requires parentRefs
set:
rspamd.httpRoute.enabled: true
asserts:
- failedTemplate:
errorMessage: rspamd.httpRoute.parentRefs is required
12 changes: 12 additions & 0 deletions charts/docker-mailserver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ rspamd:
tls:
enabled: false
secret:
httpRoute:
enabled: false
annotations: {}
labels: {}
# Gateways (or listeners) to attach to, for example:
# - name: gateway
# namespace: gateway-system
# sectionName: https
parentRefs: []
hostnames: []
# - rspamd.example.com
path: /

dovecot:
# Full text search using Dovecot's flatcurve plugin. See
Expand Down
Loading