diff --git a/deploy/hive-oke/mail/README.md b/deploy/hive-oke/mail/README.md index 1ec7f92..d11c816 100644 --- a/deploy/hive-oke/mail/README.md +++ b/deploy/hive-oke/mail/README.md @@ -23,11 +23,16 @@ certificate (see "STARTTLS" below). - Accepts `RCPT TO` only for `hive@` where the host is a hive the hub knows (subdomain, vanity or dashboard host). The list comes from `GET /api/mail/hosts` on the hub every 60 seconds; until the first list loads, RCPT gets a temporary 451. -- At most 5 recipients and 2 MB per message, per-IP and per-sender-domain rate limits, at most 100 - connections, no AUTH, no relay. It never sends mail. +- At most 5 recipients and 35 MiB per message (`SIZE 36700160`: a 25 MB attachment after base64), + per-IP and per-sender-domain rate limits, a daily byte budget per hive (512 MiB), at most 100 + connections and 8 messages in processing, no AUTH, no relay. It never sends mail. +- Each message is spooled to the size-limited `emptyDir` at `/var/spool/hive-mx` (1 GiB) while it is + processed, never held in memory whole; limits are 512 MiB of memory and 1.5 GiB of ephemeral + storage per pod (hivecommons/hive#18564). - After DATA it records SPF, DKIM and DMARC alignment, keeps only calendar invites (scheduling - fields and join details), Markdown/audio/image attachments, or a proof code, and posts the result - to `POST /api/mail/inbound` on the hub. The hub signs it with the target hive's relay key and + fields and join details), the text body as a Markdown note, Markdown/audio/video/image + attachments, or a proof code, and posts the result to `POST /api/mail/inbound` on the hub + (multipart for large deliveries, which the hub relays to the spoke in signed pieces). The hub signs it with the target hive's relay key and forwards it; it stores nothing. A hub or spoke that cannot take the mail makes hive-mx answer a temporary 451, so the sender's server retries. diff --git a/deploy/hive-oke/mail/hive-mx.yaml b/deploy/hive-oke/mail/hive-mx.yaml index 6d50540..c215c0b 100644 --- a/deploy/hive-oke/mail/hive-mx.yaml +++ b/deploy/hive-oke/mail/hive-mx.yaml @@ -72,6 +72,14 @@ spec: value: /var/run/secrets/hive-mx-tls/tls.crt - name: HIVE_MX_TLS_KEY value: /var/run/secrets/hive-mx-tls/tls.key + # Mail is spooled to disk while it is processed, never held in memory whole + # (hivecommons/hive#18564). SIZE is 35 MiB (36700160) by default. At most 8 messages are + # processed at once, each needing about the message plus its decoded attachments + # (about 65 MB), so the spool stays under 600 MB; the emptyDir below caps it at 1 GiB. + - name: HIVE_MX_SPOOL_DIR + value: /var/spool/hive-mx + - name: HIVE_MX_MAX_CONCURRENT_DATA + value: "8" ports: - name: smtp containerPort: 2525 @@ -92,10 +100,12 @@ spec: resources: requests: cpu: 50m - memory: 64Mi + memory: 128Mi + ephemeral-storage: 256Mi limits: - cpu: 500m - memory: 256Mi + cpu: "1" + memory: 512Mi + ephemeral-storage: 1536Mi securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true @@ -108,6 +118,9 @@ spec: - name: tls mountPath: /var/run/secrets/hive-mx-tls readOnly: true + # The root filesystem is read-only; the spool is the only writable path. + - name: spool + mountPath: /var/spool/hive-mx volumes: - name: hub-token secret: @@ -118,6 +131,10 @@ spec: secret: secretName: hive-mx-tls defaultMode: 0440 + # Size-limited spool for messages in flight; the kubelet evicts the pod past it. + - name: spool + emptyDir: + sizeLimit: 1Gi --- apiVersion: policy/v1 kind: PodDisruptionBudget