Skip to content

Serve the Rspamd web interface and metrics on a ClusterIP Service - #206

Merged
cfis merged 1 commit into
docker-mailserver:masterfrom
tillo:rspamd-internal-service
Nov 24, 2026
Merged

cfis merged 1 commit into
docker-mailserver:masterfrom
tillo:rspamd-internal-service

Conversation

@tillo

@tillo tillo commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

The main Service carries every port, including the Rspamd web interface (11334) and the metrics exporter. With service.type: LoadBalancer or NodePort, both are reachable from outside the cluster, and the Rspamd controller can be reached directly, bypassing any authentication on the rspamd ingress.

This moves both ports to a new ClusterIP Service, <fullname>-internal, and removes them from the main Service:

  • the rspamd ingress routes to the internal Service
  • the ServiceMonitor selects it (by app.kubernetes.io/component: internal), so metrics are never scraped twice
  • the prometheus.io/* annotations move to the internal Service, since it is the one with the metrics port
  • service.labels, service.ipFamilyPolicy and service.ipFamilies apply to the internal Service too
  • the README documents it under Ports, including what to change if you reached 11334 or the metrics port through the main Service

Tests: tests/service_test.yaml (8 cases); all unit tests pass and snapshots are unchanged; helm lint passes with both CI values files, and .ci/scripts/kube-score.sh passes.

@tillo
tillo requested a review from funkypenguin as a code owner November 23, 2026 08:13
@cfis

cfis commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

I like the idea, but a few changes:

  1. Remove exposeInternalPorts
  2. Remove rspamd and metrics from the main Service unconditionally
  3. Move the prometheus.io/* annotations to the internal Service, since the main Service no longer has the metrics port.
  4. Update the README with a note about this change
  5. Apply service.labels and ipFamilyPolicy/ipFamilies to the internal Service too.

The main Service carried every port, including the Rspamd web interface
(11334) and the metrics exporter. With service.type LoadBalancer or
NodePort, both were then reachable from outside the cluster, and the Rspamd
controller could be reached directly, bypassing any authentication the
rspamd ingress puts in front of it.

Both ports now live only on a new ClusterIP Service, <fullname>-internal,
and the main Service no longer has them. The internal Service also carries
the prometheus.io/* annotations (it is the one with the metrics port), and
takes service.labels, service.ipFamilyPolicy and service.ipFamilies like
the main Service. The rspamd ingress routes to it, and the ServiceMonitor
selects it by app.kubernetes.io/component=internal, so a scrape never hits
both Services. The README documents the change under Ports.

Tests: tests/service_test.yaml covers the main Service without the ports
and annotations, the internal Service's ports, annotations, labels and IP
families, the empty case, the ingress backend and the ServiceMonitor
selector. helm lint and kube-score pass.
@tillo
tillo force-pushed the rspamd-internal-service branch from 192d1df to 1c01e6f Compare November 24, 2026 07:56
@tillo

tillo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Updated and rebased onto master:

  1. exposeInternalPorts is gone.
  2. rspamd and metrics are removed from the main Service unconditionally.
  3. The prometheus.io/* annotations moved to the internal Service. The main Service now only renders service.annotations, if set.
  4. The README has a new "Rspamd web interface and metrics" section under Ports, with a note for anyone who reached those ports through the main Service.
  5. service.labels, ipFamilyPolicy and ipFamilies apply to the internal Service too.

Each point has a test in tests/service_test.yaml.

@cfis

cfis commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

@cfis
cfis merged commit 2465dba into docker-mailserver:master Nov 24, 2026
5 checks passed
@cfis cfis mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants