diff --git a/.kube-linter.yaml b/.kube-linter.yaml index cffc3f7..bd13772 100644 --- a/.kube-linter.yaml +++ b/.kube-linter.yaml @@ -5,4 +5,28 @@ # left out here with a line saying why. checks: addAllBuiltIn: true - exclude: [] + exclude: + # Style: Kubernetes' own docs order keys by meaning, not alphabetically + - sorted-keys + # An organisation's own conventions, for the operator to add + - required-annotation-email + - required-label-owner + # Cluster DNS defaults are right for the server + - dnsconfig-options + # Placement is the operator's choice (nodeSelector/affinity per group) + - no-node-affinity + # The groups spread with topologySpreadConstraints instead + - no-anti-affinity + # core runs exactly one replica by design, and front and mta default to 2 + - minimum-three-replicas + # The mail Service is a LoadBalancer on purpose: it is how mail gets in + - exposed-services + # TODO(K-C4): NetworkPolicies come with the security defaults; take this + # line out then + - non-isolated-pod + # The standard mail ports, on purpose. The pod listens on them with no + # capability, through the sysctl below. + - privileged-ports + # Flags net.ipv4.ip_unprivileged_port_start, which Kubernetes counts as a + # safe, namespaced sysctl since 1.22 and Pod Security "restricted" allows + - unsafe-sysctls diff --git a/CHANGELOG.md b/CHANGELOG.md index 5725d94..e966664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,3 +12,18 @@ runs, pinned by digest. - The repository: the chart's layout, a values schema that refuses unknown keys, and CI (`helm lint` under Helm 4 and 3, kubeconform against Kubernetes 1.35 to 1.37, kube-linter, helm-unittest). +- The server, as three Deployments: `front` (client protocols and web), + `mta` (as front, plus outbound delivery) and `core` (everything, exactly + one replica). The data store is a value, written as `config.json`; its + secrets are Secrets mounted under `/etc/inbuxa/secrets`. +- Pods that run as a non-root user with every capability dropped, a + read-only root filesystem and the RuntimeDefault seccomp profile. They + listen on the standard mail ports through the namespaced sysctl + `net.ipv4.ip_unprivileged_port_start`, which Pod Security "restricted" + allows. +- A `mail` LoadBalancer Service (front and mta, client addresses kept) and an + `http` ClusterIP Service (front and core), PodDisruptionBudgets, and + spreading across nodes and zones. +- `server.seed`: the new store's setup (domain, administrator, blob store, + coordinator, roles), applied once on install by a pre-install Job running + the server's `--seed`, before any server pod starts. diff --git a/charts/inbuxa/ci/defaults-values.yaml b/charts/inbuxa/ci/defaults-values.yaml index 560a3d2..acc8377 100644 --- a/charts/inbuxa/ci/defaults-values.yaml +++ b/charts/inbuxa/ci/defaults-values.yaml @@ -2,5 +2,16 @@ # SPDX-License-Identifier: Apache-2.0 # # Each file in ci/ is one set of values tools/check.sh renders and checks. -# This one is the defaults, as they are. -{} +# This one is the defaults plus the one value that has none: the data store. +server: + dataStore: + "@type": PostgreSql + host: pg-rw.data.svc + port: 5432 + database: inbuxa + authUsername: inbuxa + authSecret: {"@type": File, filePath: /etc/inbuxa/secrets/pg-password} + useTls: true + secretMounts: + - secretName: inbuxa-data + items: [{key: pg-password, path: pg-password}] diff --git a/charts/inbuxa/ci/everything-values.yaml b/charts/inbuxa/ci/everything-values.yaml new file mode 100644 index 0000000..a96734e --- /dev/null +++ b/charts/inbuxa/ci/everything-values.yaml @@ -0,0 +1,63 @@ +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: Apache-2.0 +# +# Every optional setting turned on, so all of the templates' branches render. +imagePullSecrets: [{name: registry}] +server: + image: + digest: sha256:0000000000000000000000000000000000000000000000000000000000000000 + dataStore: + "@type": PostgreSql + host: pg-rw.data.svc + port: 5432 + database: inbuxa + authUsername: inbuxa + authSecret: {"@type": File, filePath: /etc/inbuxa/secrets/pg-password} + secretMounts: + - secretName: inbuxa-data + items: [{key: pg-password, path: pg-password}, {key: nats-password, path: nats-password}] + - secretName: inbuxa-s3 + items: [{key: secret-key, path: s3-secret-key}] + publicUrl: https://mail.example.org + listeners: + pop3s: 995 + groups: + front: + replicas: 3 + podAnnotations: {example.org/team: mail} + extraEnv: [{name: INBUXA_HTTP_FORWARDED_HEADER, value: X-Forwarded-For}] + mta: + nodeSelector: {example.org/egress: mail} + tolerations: [{key: example.org/egress, operator: Exists, effect: NoSchedule}] + resources: + requests: {cpu: 500m, memory: 1Gi} + limits: {cpu: "4", memory: 4Gi} + core: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + preference: + matchExpressions: [{key: example.org/tier, operator: In, values: [core]}] + topologySpread: + zones: "off" + services: + http: + annotations: {example.org/scrape: "true"} + mail: + loadBalancerClass: example.org/lb + annotations: {example.org/lb-pool: mail} + seed: + enabled: true + request: + using: ["urn:ietf:params:jmap:core", "urn:inbuxa:jmap:registry"] + methodCalls: + - ["x:Domain/set", {create: {d: {name: example.org, dkimManagement: {"@type": Automatic}}}}, "domain"] + - ["x:Account/set", {create: {admin: {"@type": User, name: admin, domainId: "#d", roles: {"@type": Admin}, + credentials: {"0": {"@type": Password, secret: {"$file": /etc/inbuxa/seed-secrets/admin-password}}}}}}, "admin"] + secretMounts: + - secretName: inbuxa-seed + items: [{key: admin-password, path: admin-password}] + resources: + requests: {cpu: 100m, memory: 256Mi} + limits: {cpu: "1", memory: 1Gi} diff --git a/charts/inbuxa/templates/NOTES.txt b/charts/inbuxa/templates/NOTES.txt index cbbfd54..8f07ce4 100644 --- a/charts/inbuxa/templates/NOTES.txt +++ b/charts/inbuxa/templates/NOTES.txt @@ -1,4 +1,19 @@ inbuxa {{ .Chart.AppVersion }} is installed as "{{ .Release.Name }}" in namespace "{{ .Release.Namespace }}". -This chart is in development and creates nothing yet. The guide is at -https://docs.inbuxa.org/ +The server runs as {{ range $name, $g := .Values.server.groups }}{{ if $g.enabled }}{{ $name }} ({{ $g.replicas }}) {{ end }}{{ end }}on the data store in config.json. +{{- if .Values.server.services.mail.enabled }} + +Mail from outside reaches the {{ .Values.server.services.mail.type }} Service {{ include "inbuxa.fullname" . }}-mail. Its address: + kubectl -n {{ .Release.Namespace }} get service {{ include "inbuxa.fullname" . }}-mail +{{- end }} + +{{ if .Values.server.seed.enabled -}} +The store was set up from server.seed before the server started (once: a +store that was set up already is left as it is). +{{- else -}} +No seed was given (server.seed), so a new store has no domain, administrator +or cluster roles yet, and the front and mta groups name roles that don't +exist. Set the seed and install again on an empty store. +{{- end }} + +This chart is in development. The guide is at https://docs.inbuxa.org/ diff --git a/charts/inbuxa/templates/_helpers.tpl b/charts/inbuxa/templates/_helpers.tpl index cad66ca..924ca09 100644 --- a/charts/inbuxa/templates/_helpers.tpl +++ b/charts/inbuxa/templates/_helpers.tpl @@ -44,3 +44,30 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/part-of: inbuxa {{- end -}} + +{{/* The server image, by digest when one is set. */}} +{{- define "inbuxa.server.image" -}} +{{- $img := .Values.server.image -}} +{{- if $img.digest -}} +{{- printf "%s@%s" $img.repository $img.digest -}} +{{- else -}} +{{- printf "%s:%s" $img.repository (default .Chart.AppVersion $img.tag) -}} +{{- end -}} +{{- end -}} + +{{/* A server group's selector labels. Call with (dict "root" $ "group" "front"). */}} +{{- define "inbuxa.server.selectorLabels" -}} +{{ include "inbuxa.selectorLabels" .root }} +app.kubernetes.io/component: server +inbuxa.org/group: {{ .group }} +{{- end -}} + +{{/* INBUXA_LISTENER_PORTS: name=port for each listener, off for a 0. */}} +{{- define "inbuxa.server.listenerPorts" -}} +{{- $items := list -}} +{{- range $name := list "smtp" "submissions" "imaps" "pop3s" "sieve" "https" "http" -}} +{{- $port := int (index $.Values.server.listeners $name) -}} +{{- $items = append $items (printf "%s=%s" $name (ternary "off" (toString $port) (eq $port 0))) -}} +{{- end -}} +{{- join "," $items -}} +{{- end -}} diff --git a/charts/inbuxa/templates/server/configmap.yaml b/charts/inbuxa/templates/server/configmap.yaml new file mode 100644 index 0000000..d1a5185 --- /dev/null +++ b/charts/inbuxa/templates/server/configmap.yaml @@ -0,0 +1,23 @@ +{{/* +SPDX-FileCopyrightText: 2026 Coffey Labs LLC +SPDX-License-Identifier: Apache-2.0 + +The server's config.json: the data store and nothing else. Everything else +the server keeps in that store. Secrets in it are File references. +*/}} +{{- if not .Values.server.dataStore }} +{{- fail "server.dataStore is required: the server's data store, with its secrets as File references under /etc/inbuxa/secrets" }} +{{- end }} +{{- if not (index .Values.server.dataStore "@type") }} +{{- fail "server.dataStore needs an \"@type\" (PostgreSql, MySql, FoundationDb, ...)" }} +{{- end }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "inbuxa.fullname" . }}-server + namespace: {{ .Release.Namespace }} + labels: + {{- include "inbuxa.labels" . | nindent 4 }} + app.kubernetes.io/component: server +data: + config.json: {{ toJson .Values.server.dataStore | quote }} diff --git a/charts/inbuxa/templates/server/deployment.yaml b/charts/inbuxa/templates/server/deployment.yaml new file mode 100644 index 0000000..6ac60cc --- /dev/null +++ b/charts/inbuxa/templates/server/deployment.yaml @@ -0,0 +1,215 @@ +{{/* +SPDX-FileCopyrightText: 2026 Coffey Labs LLC +SPDX-License-Identifier: Apache-2.0 + +One Deployment per server role group. Node identity comes from the pod +(INBUXA_HOSTNAME is the pod name) and node ids from the store, so the pods +are interchangeable: Deployments, not StatefulSets. +*/}} +{{- $root := . }} +{{- $server := .Values.server }} +{{- range $group := list "front" "mta" "core" }} +{{- $g := index $server.groups $group }} +{{- if $g.enabled }} +{{- $labels := include "inbuxa.server.selectorLabels" (dict "root" $root "group" $group) }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "inbuxa.fullname" $root }}-{{ $group }} + namespace: {{ $root.Release.Namespace }} + labels: + {{- include "inbuxa.labels" $root | nindent 4 }} + app.kubernetes.io/component: server + inbuxa.org/group: {{ $group }} +spec: + replicas: {{ $g.replicas }} + revisionHistoryLimit: 5 + selector: + matchLabels: + {{- $labels | nindent 6 }} + strategy: + type: RollingUpdate + rollingUpdate: + {{- if eq $group "core" }} + # Never two cores at once, not even for a moment during a rollout + maxSurge: 0 + maxUnavailable: 1 + {{- else }} + maxSurge: 1 + maxUnavailable: 0 + {{- end }} + template: + metadata: + labels: + {{- include "inbuxa.labels" $root | nindent 8 }} + app.kubernetes.io/component: server + inbuxa.org/group: {{ $group }} + {{- if has $group $server.services.http.groups }} + inbuxa.org/serves-http: "true" + {{- end }} + {{- if and $server.services.mail.enabled (has $group $server.services.mail.groups) }} + inbuxa.org/serves-mail: "true" + {{- end }} + annotations: + checksum/config: {{ toJson $server.dataStore | sha256sum }} + {{- with $g.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + automountServiceAccountToken: false + enableServiceLinks: false + restartPolicy: Always + terminationGracePeriodSeconds: {{ $server.terminationGracePeriodSeconds }} + {{- with $root.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- $lowest := 65536 }} + {{- range $name, $port := $server.listeners }} + {{- if and (gt (int $port) 0) (lt (int $port) (int $lowest)) }}{{ $lowest = int $port }}{{ end }} + {{- end }} + {{- if lt (int $lowest) 1024 }} + # Lets the unprivileged server listen from the lowest listener port + # up, with no capability. Namespaced to the pod, and one of the + # sysctls Pod Security "restricted" allows. + sysctls: + - name: net.ipv4.ip_unprivileged_port_start + value: {{ $lowest | quote }} + {{- end }} + runAsNonRoot: true + runAsUser: 2000 + runAsGroup: 2000 + fsGroup: 2000 + seccompProfile: + type: RuntimeDefault + {{- if or (ne $server.topologySpread.nodes "off") (ne $server.topologySpread.zones "off") }} + topologySpreadConstraints: + {{- if ne $server.topologySpread.nodes "off" }} + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: {{ $server.topologySpread.nodes }} + labelSelector: + matchLabels: + {{- $labels | nindent 14 }} + {{- end }} + {{- if ne $server.topologySpread.zones "off" }} + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: {{ $server.topologySpread.zones }} + labelSelector: + matchLabels: + {{- $labels | nindent 14 }} + {{- end }} + {{- end }} + {{- with $g.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $g.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $g.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: server + image: {{ include "inbuxa.server.image" $root }} + imagePullPolicy: {{ $server.image.pullPolicy }} + args: ["--config", "/etc/inbuxa/config.json"] + env: + - name: INBUXA_HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + {{- if $g.role }} + - name: INBUXA_ROLE + value: {{ $g.role | quote }} + {{- end }} + {{- if $server.publicUrl }} + - name: INBUXA_PUBLIC_URL + value: {{ $server.publicUrl | quote }} + {{- end }} + - name: INBUXA_LISTENER_PORTS + value: {{ include "inbuxa.server.listenerPorts" $root | quote }} + {{- with $g.extraEnv }} + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + {{- range $name := list "smtp" "submissions" "imaps" "pop3s" "sieve" "https" "http" }} + {{- $port := int (index $server.listeners $name) }} + {{- if $port }} + - name: {{ $name }} + containerPort: {{ $port }} + protocol: TCP + {{- end }} + {{- end }} + startupProbe: + httpGet: + path: /healthz/live + port: http + periodSeconds: 5 + # A first start on a new or upgraded store can take a while + failureThreshold: 120 + livenessProbe: + httpGet: + path: /healthz/live + port: http + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 6 + readinessProbe: + # Ready while the data store answers + httpGet: + path: /healthz/ready + port: http + periodSeconds: 5 + timeoutSeconds: 5 + failureThreshold: 3 + resources: + {{- toYaml (default $server.resources $g.resources) | nindent 12 }} + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: [ALL] + volumeMounts: + - name: config + mountPath: /etc/inbuxa/config.json + subPath: config.json + readOnly: true + {{- if $server.secretMounts }} + - name: secrets + mountPath: /etc/inbuxa/secrets + readOnly: true + {{- end }} + - name: data + mountPath: /var/lib/inbuxa + - name: tmp + mountPath: /tmp + volumes: + - name: config + configMap: + name: {{ include "inbuxa.fullname" $root }}-server + {{- if $server.secretMounts }} + - name: secrets + projected: + defaultMode: 0440 + sources: + {{- range $server.secretMounts }} + - secret: + name: {{ .secretName }} + items: + {{- toYaml .items | nindent 20 }} + {{- end }} + {{- end }} + # Scratch only: everything lasting is in the data store + - name: data + emptyDir: {} + - name: tmp + emptyDir: {} +{{- end }} +{{- end }} diff --git a/charts/inbuxa/templates/server/pdb.yaml b/charts/inbuxa/templates/server/pdb.yaml new file mode 100644 index 0000000..ec87fba --- /dev/null +++ b/charts/inbuxa/templates/server/pdb.yaml @@ -0,0 +1,32 @@ +{{/* +SPDX-FileCopyrightText: 2026 Coffey Labs LLC +SPDX-License-Identifier: Apache-2.0 + +A drain or upgrade takes down at most maxUnavailable pods of a group. For +the single core that means it can be moved, with a short gap in the +scheduled tasks, rather than blocking every drain. +*/}} +{{- if .Values.server.podDisruptionBudget.enabled }} +{{- $root := . }} +{{- range $group := list "front" "mta" "core" }} +{{- $g := index $root.Values.server.groups $group }} +{{- if and $g.enabled (gt (int $g.replicas) 0) }} +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "inbuxa.fullname" $root }}-{{ $group }} + namespace: {{ $root.Release.Namespace }} + labels: + {{- include "inbuxa.labels" $root | nindent 4 }} + app.kubernetes.io/component: server + inbuxa.org/group: {{ $group }} +spec: + maxUnavailable: {{ $root.Values.server.podDisruptionBudget.maxUnavailable }} + unhealthyPodEvictionPolicy: AlwaysAllow + selector: + matchLabels: + {{- include "inbuxa.server.selectorLabels" (dict "root" $root "group" $group) | nindent 6 }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/inbuxa/templates/server/seed.yaml b/charts/inbuxa/templates/server/seed.yaml new file mode 100644 index 0000000..09da4bc --- /dev/null +++ b/charts/inbuxa/templates/server/seed.yaml @@ -0,0 +1,158 @@ +{{/* +SPDX-FileCopyrightText: 2026 Coffey Labs LLC +SPDX-License-Identifier: Apache-2.0 + +The new store's setup, once, on install: the server's --seed runs the seed +(a JMAP request body) as the system administrator and exits, before any +server pod starts. Pre-install hooks run before the chart's other objects +exist, so the Job brings its own copy of config.json. A seed applies only +to a new store; on a store that has one, the run does nothing and exits 0. +*/}} +{{- $root := . }} +{{- $server := .Values.server }} +{{- $seed := $server.seed }} +{{- if $seed.enabled }} +{{- if and $seed.request $seed.existingConfigMap }} +{{- fail "server.seed: set request or existingConfigMap, not both" }} +{{- end }} +{{- if not (or $seed.request $seed.existingConfigMap) }} +{{- fail "server.seed.enabled needs the seed: server.seed.request, or server.seed.existingConfigMap" }} +{{- end }} +{{- $name := printf "%s-seed" (include "inbuxa.fullname" $root) }} +{{- if eq $seed.existingConfigMap $name }} +{{- fail (printf "server.seed.existingConfigMap can't be %q: the chart makes a ConfigMap of that name for the seed run, which replaces yours" $name) }} +{{- end }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ $name }} + namespace: {{ $root.Release.Namespace }} + labels: + {{- include "inbuxa.labels" $root | nindent 4 }} + app.kubernetes.io/component: seed + annotations: + helm.sh/hook: pre-install + helm.sh/hook-weight: "-5" + helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded +data: + config.json: {{ toJson $server.dataStore | quote }} + {{- if $seed.request }} + seed.json: {{ toJson $seed.request | quote }} + {{- end }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ $name }} + namespace: {{ $root.Release.Namespace }} + labels: + {{- include "inbuxa.labels" $root | nindent 4 }} + app.kubernetes.io/component: seed + annotations: + helm.sh/hook: pre-install + helm.sh/hook-weight: "0" + # A failed run stays, for its log, until the next install or a day + helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded + ignore-check.kube-linter.io/no-liveness-probe: "A one-shot that serves nothing; activeDeadlineSeconds bounds it" + ignore-check.kube-linter.io/no-readiness-probe: "A one-shot that serves nothing" + ignore-check.kube-linter.io/restart-policy: "Never on purpose: a second run would apply part of the seed twice" +spec: + ttlSecondsAfterFinished: 86400 + # Never again on its own: a run that stopped partway left part of the + # seed in the store, and a second would make it twice + backoffLimit: 0 + activeDeadlineSeconds: {{ $seed.timeoutSeconds }} + template: + metadata: + labels: + {{- include "inbuxa.labels" $root | nindent 8 }} + app.kubernetes.io/component: seed + spec: + automountServiceAccountToken: false + enableServiceLinks: false + restartPolicy: Never + {{- with $root.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + runAsNonRoot: true + runAsUser: 2000 + runAsGroup: 2000 + fsGroup: 2000 + seccompProfile: + type: RuntimeDefault + containers: + - name: seed + image: {{ include "inbuxa.server.image" $root }} + imagePullPolicy: {{ $server.image.pullPolicy }} + args: ["--seed", "/etc/inbuxa/seed/seed.json", "--config", "/etc/inbuxa/config.json"] + env: + - name: INBUXA_HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + # The defaults the seed run writes include the listeners + - name: INBUXA_LISTENER_PORTS + value: {{ include "inbuxa.server.listenerPorts" $root | quote }} + resources: + {{- toYaml (default $server.resources $seed.resources) | nindent 12 }} + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: [ALL] + volumeMounts: + - name: config + mountPath: /etc/inbuxa/config.json + subPath: config.json + readOnly: true + - name: seed + mountPath: /etc/inbuxa/seed + readOnly: true + {{- if $server.secretMounts }} + - name: secrets + mountPath: /etc/inbuxa/secrets + readOnly: true + {{- end }} + {{- if $seed.secretMounts }} + - name: seed-secrets + mountPath: /etc/inbuxa/seed-secrets + readOnly: true + {{- end }} + - name: data + mountPath: /var/lib/inbuxa + - name: tmp + mountPath: /tmp + volumes: + - name: config + configMap: + name: {{ $name }} + items: [{key: config.json, path: config.json}] + - name: seed + configMap: + {{- if $seed.request }} + name: {{ $name }} + {{- else }} + name: {{ $seed.existingConfigMap }} + {{- end }} + items: [{key: seed.json, path: seed.json}] + {{- range $volume, $mounts := dict "secrets" $server.secretMounts "seed-secrets" $seed.secretMounts }} + {{- if $mounts }} + - name: {{ $volume }} + projected: + defaultMode: 0440 + sources: + {{- range $mounts }} + - secret: + name: {{ .secretName }} + items: + {{- toYaml .items | nindent 20 }} + {{- end }} + {{- end }} + {{- end }} + - name: data + emptyDir: {} + - name: tmp + emptyDir: {} +{{- end }} diff --git a/charts/inbuxa/templates/server/service-http.yaml b/charts/inbuxa/templates/server/service-http.yaml new file mode 100644 index 0000000..4d9327a --- /dev/null +++ b/charts/inbuxa/templates/server/service-http.yaml @@ -0,0 +1,44 @@ +{{/* +SPDX-FileCopyrightText: 2026 Coffey Labs LLC +SPDX-License-Identifier: Apache-2.0 + +Web, JMAP and the management API, inside the cluster. A selector can't say +"any of these groups", so the pods of each group listed carry +inbuxa.org/serves-http, and this selects that. +*/}} +{{- $root := . }} +{{- $svc := .Values.server.services.http }} +{{- range $group := $svc.groups }} +{{- if not (index $root.Values.server.groups $group).enabled }} +{{- fail (printf "server.services.http.groups names %q, which is not enabled" $group) }} +{{- end }} +{{- end }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "inbuxa.fullname" . }}-http + namespace: {{ .Release.Namespace }} + labels: + {{- include "inbuxa.labels" . | nindent 4 }} + app.kubernetes.io/component: server + {{- with $svc.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ $svc.type }} + selector: + {{- include "inbuxa.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: server + inbuxa.org/serves-http: "true" + ports: + {{- if .Values.server.listeners.https }} + - name: https + port: 443 + targetPort: https + protocol: TCP + {{- end }} + - name: http + port: 8080 + targetPort: http + protocol: TCP diff --git a/charts/inbuxa/templates/server/service-mail.yaml b/charts/inbuxa/templates/server/service-mail.yaml new file mode 100644 index 0000000..1b1ed43 --- /dev/null +++ b/charts/inbuxa/templates/server/service-mail.yaml @@ -0,0 +1,56 @@ +{{/* +SPDX-FileCopyrightText: 2026 Coffey Labs LLC +SPDX-License-Identifier: Apache-2.0 + +Mail from outside, on the standard ports, sent to the listeners in the +pods. With externalTrafficPolicy Local the load balancer sends only to +nodes running one of these pods, and the server sees each client's own +address. +*/}} +{{- $root := . }} +{{- $svc := .Values.server.services.mail }} +{{- if $svc.enabled }} +{{- range $group := $svc.groups }} +{{- if not (index $root.Values.server.groups $group).enabled }} +{{- fail (printf "server.services.mail.groups names %q, which is not enabled" $group) }} +{{- end }} +{{- end }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "inbuxa.fullname" . }}-mail + namespace: {{ .Release.Namespace }} + labels: + {{- include "inbuxa.labels" . | nindent 4 }} + app.kubernetes.io/component: server + {{- with $svc.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ $svc.type }} + {{- if ne $svc.type "ClusterIP" }} + externalTrafficPolicy: {{ $svc.externalTrafficPolicy }} + {{- end }} + {{- if and (eq $svc.type "LoadBalancer") $svc.loadBalancerClass }} + loadBalancerClass: {{ $svc.loadBalancerClass }} + {{- end }} + {{- if and (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + loadBalancerIP: {{ $svc.loadBalancerIP }} + {{- end }} + selector: + {{- include "inbuxa.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: server + inbuxa.org/serves-mail: "true" + ports: + {{- range $name := list "smtp" "submissions" "imaps" "pop3s" "sieve" }} + {{- $target := int (index $root.Values.server.listeners $name) }} + {{- $port := int (index $svc.ports $name) }} + {{- if and $target $port }} + - name: {{ $name }} + port: {{ $port }} + targetPort: {{ $name }} + protocol: TCP + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/inbuxa/tests/seed_test.yaml b/charts/inbuxa/tests/seed_test.yaml new file mode 100644 index 0000000..b39c636 --- /dev/null +++ b/charts/inbuxa/tests/seed_test.yaml @@ -0,0 +1,106 @@ +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: Apache-2.0 +suite: seed +templates: + - server/seed.yaml +release: + name: mail + namespace: inbuxa +values: + - ../ci/defaults-values.yaml +set: + server.seed.enabled: true + server.seed.request: + using: ["urn:ietf:params:jmap:core", "urn:inbuxa:jmap:registry"] + methodCalls: [["x:Domain/set", {create: {d: {name: example.org}}}, "d"]] + server.seed.secretMounts: + - secretName: inbuxa-seed + items: [{key: admin-password, path: admin-password}] +tests: + - it: makes nothing without a seed + set: + server.seed.enabled: false + asserts: + - hasDocuments: + count: 0 + + - it: runs before the chart's other objects, and only on install + asserts: + - equal: + path: metadata.annotations["helm.sh/hook"] + value: pre-install + - equal: + path: metadata.annotations["helm.sh/hook-weight"] + value: "-5" + documentIndex: 0 + - equal: + path: metadata.annotations["helm.sh/hook-weight"] + value: "0" + documentIndex: 1 + + - it: brings its own config.json and the seed + documentIndex: 0 + asserts: + - equal: + path: data["seed.json"] + value: '{"methodCalls":[["x:Domain/set",{"create":{"d":{"name":"example.org"}}},"d"]],"using":["urn:ietf:params:jmap:core","urn:inbuxa:jmap:registry"]}' + - exists: + path: data["config.json"] + + - it: runs --seed once, never retried + documentIndex: 1 + asserts: + - equal: + path: spec.backoffLimit + value: 0 + - equal: + path: spec.template.spec.containers[0].args + value: ["--seed", "/etc/inbuxa/seed/seed.json", "--config", "/etc/inbuxa/config.json"] + - equal: + path: spec.template.spec.restartPolicy + value: Never + + - it: mounts the seed's secrets apart from the server's + documentIndex: 1 + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: {name: seed-secrets, mountPath: /etc/inbuxa/seed-secrets, readOnly: true} + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: {name: secrets, mountPath: /etc/inbuxa/secrets, readOnly: true} + + - it: reads an existing ConfigMap instead + set: + server.seed.request: null + server.seed.existingConfigMap: my-seed + asserts: + - notExists: + path: data["seed.json"] + documentIndex: 0 + - contains: + path: spec.template.spec.volumes + content: {name: seed, configMap: {name: my-seed, items: [{key: seed.json, path: seed.json}]}} + documentIndex: 1 + + - it: refuses to run without a seed + set: + server.seed.request: null + asserts: + - failedTemplate: + errorPattern: needs the seed + + - it: refuses two seeds + set: + server.seed.existingConfigMap: my-seed + asserts: + - failedTemplate: + errorPattern: not both + + - it: refuses a ConfigMap with the name of its own + set: + server.seed.request: null + server.seed.existingConfigMap: mail-inbuxa-seed + asserts: + - failedTemplate: + errorPattern: the chart makes a ConfigMap of that name diff --git a/charts/inbuxa/tests/server_test.yaml b/charts/inbuxa/tests/server_test.yaml new file mode 100644 index 0000000..73d26c7 --- /dev/null +++ b/charts/inbuxa/tests/server_test.yaml @@ -0,0 +1,238 @@ +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: Apache-2.0 +suite: server +templates: + - server/configmap.yaml + - server/deployment.yaml + - server/pdb.yaml + - server/service-http.yaml + - server/service-mail.yaml +release: + name: mail + namespace: inbuxa +values: + - ../ci/defaults-values.yaml +tests: + - it: refuses to render without a data store + set: + server.dataStore: null + template: server/configmap.yaml + asserts: + - failedTemplate: + errorPattern: server.dataStore is required + + - it: writes the data store as config.json + template: server/configmap.yaml + asserts: + - equal: + path: data["config.json"] + value: '{"@type":"PostgreSql","authSecret":{"@type":"File","filePath":"/etc/inbuxa/secrets/pg-password"},"authUsername":"inbuxa","database":"inbuxa","host":"pg-rw.data.svc","port":5432,"useTls":true}' + + - it: makes one Deployment per group, core with a single replica + template: server/deployment.yaml + asserts: + - hasDocuments: + count: 3 + - equal: + path: metadata.name + value: mail-inbuxa-front + documentIndex: 0 + - equal: + path: spec.replicas + value: 2 + documentIndex: 1 + - equal: + path: spec.replicas + value: 1 + documentIndex: 2 + + - it: never runs two cores at once, even mid-rollout + template: server/deployment.yaml + documentIndex: 2 + asserts: + - equal: + path: spec.strategy.rollingUpdate + value: {maxSurge: 0, maxUnavailable: 1} + + - it: keeps front at full strength during a rollout + template: server/deployment.yaml + documentIndex: 0 + asserts: + - equal: + path: spec.strategy.rollingUpdate + value: {maxSurge: 1, maxUnavailable: 0} + + - it: names each group's role, and none for core + template: server/deployment.yaml + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_ROLE, value: peer} + documentIndex: 0 + - contains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_ROLE, value: peer-mta} + documentIndex: 1 + - notContains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_ROLE, value: ""} + documentIndex: 2 + + - it: takes the node's name from the pod + template: server/deployment.yaml + documentIndex: 0 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: INBUXA_HOSTNAME + valueFrom: {fieldRef: {fieldPath: metadata.name}} + + - it: keeps the standard ports, POP3 off by default + template: server/deployment.yaml + documentIndex: 0 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: INBUXA_LISTENER_PORTS + value: smtp=25,submissions=465,imaps=993,pop3s=off,sieve=4190,https=443,http=8080 + - lengthEqual: + path: spec.template.spec.containers[0].ports + count: 6 + + - it: lets the pod listen from its lowest port with the namespaced sysctl + template: server/deployment.yaml + documentIndex: 0 + asserts: + - equal: + path: spec.template.spec.securityContext.sysctls + value: [{name: net.ipv4.ip_unprivileged_port_start, value: "25"}] + + - it: needs no sysctl when every listener is above 1024 + set: + server.listeners: {smtp: 0, submissions: 4465, imaps: 9993, sieve: 4190, https: 8443, http: 8080} + template: server/deployment.yaml + documentIndex: 0 + asserts: + - notExists: + path: spec.template.spec.securityContext.sysctls + + - it: refuses to move SMTP off 25 + set: + server.listeners.smtp: 2525 + template: server/deployment.yaml + asserts: + - failedTemplate: {} + + - it: runs with nothing added back + template: server/deployment.yaml + documentIndex: 0 + asserts: + - equal: + path: spec.template.spec.containers[0].securityContext + value: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: {drop: [ALL]} + - equal: + path: spec.template.spec.automountServiceAccountToken + value: false + - equal: + path: spec.template.spec.securityContext.seccompProfile.type + value: RuntimeDefault + + - it: probes plain HTTP, ready only while the data store answers + template: server/deployment.yaml + documentIndex: 0 + asserts: + - equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet + value: {path: /healthz/ready, port: http} + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet + value: {path: /healthz/live, port: http} + + - it: mounts the secrets read-only, under /etc/inbuxa/secrets + template: server/deployment.yaml + documentIndex: 0 + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: {name: secrets, mountPath: /etc/inbuxa/secrets, readOnly: true} + - equal: + path: spec.template.spec.volumes[1].projected.sources[0].secret + value: {name: inbuxa-data, items: [{key: pg-password, path: pg-password}]} + + - it: pins the image by digest when one is given + set: + server.image.digest: sha256:1111111111111111111111111111111111111111111111111111111111111111 + template: server/deployment.yaml + documentIndex: 0 + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: ghcr.io/inbuxa/inbuxa-server@sha256:1111111111111111111111111111111111111111111111111111111111111111 + + - it: leaves out a disabled group, its budget and its Service labels + set: + server.groups.mta.enabled: false + server.services.mail.groups: [front] + asserts: + - hasDocuments: + count: 2 + template: server/deployment.yaml + - hasDocuments: + count: 2 + template: server/pdb.yaml + + - it: refuses a Service that names a disabled group + set: + server.groups.mta.enabled: false + template: server/service-mail.yaml + asserts: + - failedTemplate: + errorPattern: names "mta", which is not enabled + + - it: sends mail to front and mta, web to front and core + template: server/deployment.yaml + asserts: + - equal: + path: spec.template.metadata.labels["inbuxa.org/serves-mail"] + value: "true" + documentIndex: 0 + - equal: + path: spec.template.metadata.labels["inbuxa.org/serves-mail"] + value: "true" + documentIndex: 1 + - notExists: + path: spec.template.metadata.labels["inbuxa.org/serves-mail"] + documentIndex: 2 + - notExists: + path: spec.template.metadata.labels["inbuxa.org/serves-http"] + documentIndex: 1 + - equal: + path: spec.template.metadata.labels["inbuxa.org/serves-http"] + value: "true" + documentIndex: 2 + + - it: maps the standard mail ports onto the listeners, keeping client addresses + template: server/service-mail.yaml + asserts: + - equal: + path: spec.externalTrafficPolicy + value: Local + - equal: + path: spec.ports + value: + - {name: smtp, port: 25, targetPort: smtp, protocol: TCP} + - {name: submissions, port: 465, targetPort: submissions, protocol: TCP} + - {name: imaps, port: 993, targetPort: imaps, protocol: TCP} + - {name: sieve, port: 4190, targetPort: sieve, protocol: TCP} + + - it: refuses a core with a second replica + set: + server.groups.core.replicas: 2 + template: server/deployment.yaml + asserts: + - failedTemplate: {} diff --git a/charts/inbuxa/values.schema.json b/charts/inbuxa/values.schema.json index 09c0d35..3bf674f 100644 --- a/charts/inbuxa/values.schema.json +++ b/charts/inbuxa/values.schema.json @@ -3,6 +3,136 @@ "title": "Values for the inbuxa chart", "type": "object", "additionalProperties": false, + "definitions": { + "name": { + "type": "string", + "pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?)?$" + }, + "port": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "listenerPort": { + "description": "A port in the pod, or 0 to leave the listener out.", + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "group": { + "type": "object", + "additionalProperties": false, + "required": [ + "enabled", + "replicas", + "role" + ], + "properties": { + "enabled": { + "type": "boolean" + }, + "replicas": { + "type": "integer", + "minimum": 0 + }, + "role": { + "description": "The registry ClusterRole the group's pods run as; empty runs every task.", + "type": "string" + }, + "resources": { + "type": "object" + }, + "nodeSelector": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "tolerations": { + "type": "array", + "items": { + "type": "object" + } + }, + "affinity": { + "type": "object" + }, + "podAnnotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraEnv": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ] + } + } + } + }, + "groupNames": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "enum": [ + "front", + "mta", + "core" + ] + } + }, + "spreadMode": { + "enum": [ + "DoNotSchedule", + "ScheduleAnyway", + "off" + ] + }, + "secretMounts": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "secretName", + "items" + ], + "properties": { + "secretName": { + "type": "string", + "minLength": 1 + }, + "items": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "key", + "path" + ], + "properties": { + "key": { + "type": "string", + "minLength": 1 + }, + "path": { + "type": "string", + "pattern": "^[^/][^\\0]*$" + } + } + } + } + } + } + } + }, "properties": { "global": { "description": "Set by Helm for charts that have subcharts. Unused here.", @@ -10,15 +140,285 @@ }, "nameOverride": { "description": "Replaces \"inbuxa\" in the names of everything the chart creates.", - "type": "string", - "maxLength": 40, - "pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?)?$" + "allOf": [ + { + "$ref": "#/definitions/name" + }, + { + "maxLength": 40 + } + ] }, "fullnameOverride": { "description": "Replaces the whole name: the release name and the chart name.", - "type": "string", - "maxLength": 52, - "pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?)?$" + "allOf": [ + { + "$ref": "#/definitions/name" + }, + { + "maxLength": 52 + } + ] + }, + "imagePullSecrets": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + } + } + } + }, + "server": { + "type": "object", + "additionalProperties": false, + "properties": { + "image": { + "type": "object", + "additionalProperties": false, + "properties": { + "repository": { + "type": "string", + "minLength": 1 + }, + "tag": { + "type": "string" + }, + "digest": { + "type": "string", + "pattern": "^(sha256:[a-f0-9]{64})?$" + }, + "pullPolicy": { + "enum": [ + "Always", + "IfNotPresent", + "Never" + ] + } + } + }, + "dataStore": { + "description": "The data store, written as config.json. Its secrets are File references.", + "type": "object" + }, + "secretMounts": { + "$ref": "#/definitions/secretMounts" + }, + "seed": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "request": { + "description": "A JMAP request body: using and methodCalls.", + "type": "object" + }, + "existingConfigMap": { + "type": "string" + }, + "secretMounts": { + "$ref": "#/definitions/secretMounts" + }, + "timeoutSeconds": { + "type": "integer", + "minimum": 30 + }, + "resources": { + "type": "object" + } + } + }, + "publicUrl": { + "type": "string", + "pattern": "^(https?://[^/\\s]+)?$" + }, + "listeners": { + "type": "object", + "additionalProperties": false, + "properties": { + "smtp": { + "description": "25, or 0 for no SMTP. The server's default rules treat only port 25 as mail from the internet, so SMTP can't move.", + "enum": [ + 0, + 25 + ] + }, + "submissions": { + "$ref": "#/definitions/listenerPort" + }, + "imaps": { + "$ref": "#/definitions/listenerPort" + }, + "pop3s": { + "$ref": "#/definitions/listenerPort" + }, + "sieve": { + "$ref": "#/definitions/listenerPort" + }, + "https": { + "$ref": "#/definitions/listenerPort" + }, + "http": { + "description": "Plain HTTP, which the probes use, so it can't be left out.", + "type": "integer", + "minimum": 1, + "maximum": 65535 + } + } + }, + "groups": { + "type": "object", + "additionalProperties": false, + "properties": { + "front": { + "$ref": "#/definitions/group" + }, + "mta": { + "$ref": "#/definitions/group" + }, + "core": { + "allOf": [ + { + "$ref": "#/definitions/group" + }, + { + "properties": { + "replicas": { + "description": "0 or 1: a second core would queue every maintenance task twice.", + "maximum": 1 + } + } + } + ] + } + } + }, + "resources": { + "type": "object" + }, + "terminationGracePeriodSeconds": { + "type": "integer", + "minimum": 0 + }, + "topologySpread": { + "type": "object", + "additionalProperties": false, + "properties": { + "nodes": { + "$ref": "#/definitions/spreadMode" + }, + "zones": { + "$ref": "#/definitions/spreadMode" + } + } + }, + "podDisruptionBudget": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "maxUnavailable": { + "type": "integer", + "minimum": 1 + } + } + }, + "services": { + "type": "object", + "additionalProperties": false, + "properties": { + "http": { + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "enum": [ + "ClusterIP", + "NodePort", + "LoadBalancer" + ] + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "groups": { + "$ref": "#/definitions/groupNames" + } + } + }, + "mail": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "type": { + "enum": [ + "LoadBalancer", + "NodePort", + "ClusterIP" + ] + }, + "externalTrafficPolicy": { + "enum": [ + "Local", + "Cluster" + ] + }, + "loadBalancerClass": { + "type": "string" + }, + "loadBalancerIP": { + "type": "string" + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "groups": { + "$ref": "#/definitions/groupNames" + }, + "ports": { + "type": "object", + "additionalProperties": false, + "properties": { + "smtp": { + "$ref": "#/definitions/port" + }, + "submissions": { + "$ref": "#/definitions/port" + }, + "imaps": { + "$ref": "#/definitions/port" + }, + "pop3s": { + "$ref": "#/definitions/port" + }, + "sieve": { + "$ref": "#/definitions/port" + } + } + } + } + } + } + } + } } } } diff --git a/charts/inbuxa/values.yaml b/charts/inbuxa/values.yaml index 29ba627..9f6cdb9 100644 --- a/charts/inbuxa/values.yaml +++ b/charts/inbuxa/values.yaml @@ -9,3 +9,161 @@ nameOverride: "" # Overrides the whole name (release name plus chart name). fullnameOverride: "" + +imagePullSecrets: [] + +server: + image: + repository: ghcr.io/inbuxa/inbuxa-server + # Defaults to the chart's appVersion + tag: "" + # sha256:..., which wins over the tag when set + digest: "" + pullPolicy: IfNotPresent + + # The data store, written as the server's config.json. Required. A secret + # in it is a File reference to a path under /etc/inbuxa/secrets, never the + # secret itself. For example: + # "@type": PostgreSql + # host: pg-rw.data.svc + # port: 5432 + # database: inbuxa + # authUsername: inbuxa + # authSecret: {"@type": File, filePath: /etc/inbuxa/secrets/pg-password} + # useTls: true + dataStore: {} + + # Secrets mounted under /etc/inbuxa/secrets, where the data store, blob + # store and coordinator settings point with File references. Each entry is + # an existing Secret and the keys to mount from it: + # - secretName: inbuxa-data + # items: [{key: pg-password, path: pg-password}] + secretMounts: [] + + # The new store's setup, applied once on install, before any server pod + # starts: the domain, administrator, blob store, coordinator and cluster + # roles the groups below name. A JMAP request body ("using" and + # "methodCalls"), the calls an administrator would send to /jmap, run as + # the system administrator. A value {"$file": /path} is replaced by that + # file's contents: put secrets in seed.secretMounts, never in the seed. + # Ignored by a store that's set up already. See the server's --seed. + seed: + enabled: false + # The seed, as values + request: {} + # Or an existing ConfigMap with it under the key seed.json + existingConfigMap: "" + # Secrets only the seed run sees, at /etc/inbuxa/seed-secrets, in the + # same form as secretMounts + secretMounts: [] + timeoutSeconds: 600 + resources: {} + + # Where browsers and clients reach the server, as https://host. Sign-in + # pages and OAuth metadata name it. + publicUrl: "" + + # The port in the pod of each listener a new store gets, which is what + # the Services send traffic to. 0 leaves that listener out. The pods may + # listen below 1024 without any privilege: they set the namespaced sysctl + # net.ipv4.ip_unprivileged_port_start, which Pod Security "restricted" + # allows. SMTP stays on 25: the server's default rules tell mail from the + # internet from submissions by local port 25. Used once, when the store is + # new; after that the listeners are settings in the console, and these + # have to match them. + listeners: + smtp: 25 + submissions: 465 + imaps: 993 + pop3s: 0 + sieve: 4190 + https: 443 + http: 8080 + + # The server's role groups, each a Deployment. INBUXA_ROLE names a role + # (a ClusterRole in the server's registry) that says which background + # tasks the group runs; an empty role runs them all. + groups: + # Client protocols, web and JMAP; no outbound delivery, no scheduler + front: + enabled: true + replicas: 2 + role: peer + resources: {} + nodeSelector: {} + tolerations: [] + affinity: {} + podAnnotations: {} + extraEnv: [] + # As front, plus outbound delivery. Place it where its egress address + # is the one your SPF and PTR records name. + mta: + enabled: true + replicas: 2 + role: peer-mta + resources: {} + nodeSelector: {} + tolerations: [] + affinity: {} + podAnnotations: {} + extraEnv: [] + # Everything, including the task scheduler. Exactly one replica: a + # second would queue every maintenance task twice. + core: + enabled: true + replicas: 1 + role: "" + resources: {} + nodeSelector: {} + tolerations: [] + affinity: {} + podAnnotations: {} + extraEnv: [] + + # Used for every group that sets no resources of its own + resources: + requests: + cpu: 250m + memory: 512Mi + limits: + cpu: "2" + memory: 2Gi + + # Time for SMTP sessions in progress to finish when a pod stops + terminationGracePeriodSeconds: 120 + + # Pods of a group are spread across nodes (never two on one node while + # another node has room) and, where the cluster has zones, across zones. + topologySpread: + nodes: DoNotSchedule + zones: ScheduleAnyway + + # At most this many pods of a group down at once for a drain or upgrade + podDisruptionBudget: + enabled: true + maxUnavailable: 1 + + services: + # Web, JMAP and the API, inside the cluster. Front ends and an Ingress + # or Gateway route point here. + http: + type: ClusterIP + annotations: {} + groups: [front, core] + # Mail from outside, on the standard ports. Local keeps each client's + # own address (no SNAT): the load balancer sends only to nodes running a + # mail pod. + mail: + enabled: true + type: LoadBalancer + externalTrafficPolicy: Local + loadBalancerClass: "" + loadBalancerIP: "" + annotations: {} + groups: [front, mta] + ports: + smtp: 25 + submissions: 465 + imaps: 993 + pop3s: 995 + sieve: 4190 diff --git a/tools/check.sh b/tools/check.sh index ca6dc72..05608b2 100755 --- a/tools/check.sh +++ b/tools/check.sh @@ -23,14 +23,13 @@ step() { printf '\n== %s\n' "$*"; } for helm in helm helm3; do step "$helm lint ($($helm version --short))" - $helm lint --strict "$CHART" for values in "$CHART"/ci/*-values.yaml; do $helm lint --strict "$CHART" -f "$values" done done step "the values schema rejects a key it doesn't know" -if helm lint --strict "$CHART" --set notAValue=1 >"$OUT/reject.log" 2>&1; then +if helm lint --strict "$CHART" -f "$CHART/ci/defaults-values.yaml" --set notAValue=1 >"$OUT/reject.log" 2>&1; then echo "!! an unknown value was accepted" >&2 exit 1 fi @@ -45,7 +44,7 @@ for values in "$CHART"/ci/*-values.yaml; do name="$(basename "$values" -values.yaml)" for kube in "${KUBE_VERSIONS[@]}"; do step "kubeconform: $name values on Kubernetes $kube" - helm template ci "$CHART" -f "$values" --kube-version "$kube" >"$OUT/$name-$kube.yaml" + helm template ci "$CHART" -n inbuxa -f "$values" --kube-version "$kube" >"$OUT/$name-$kube.yaml" kubeconform -strict -summary -kubernetes-version "$kube" \ -schema-location default "$OUT/$name-$kube.yaml" done