Skip to content

feat(k8s): mattermost team edition runs under argo cd from the mattermost operator, on a cloudnativepg database and a protected volume, at https://mattermost.<domain> through the tunnel #1391

Closed
1 of 1 issue completed

Description

@dan-petty

Tracking issue

This issue tracks the two pull requests of the section "Delivery".

The pull request of PR 2 closes this issue. It merges after #2008 closes, so this issue closes after its child issue.


Refreshed plan (2026-10-17, unblocking review)

This section supersedes any text below that conflicts with it.

Decisions

Scope

Delivery

  1. PR 1 (M) closes feat(k8s): deploy-stack declares its stack names once, and a cluster secret row can name its Secret type and hold derived entries #2008. It adds the post-Helm step (left out if fix(k8s): deploy-stack warns about GPU nodes no Ollama tier accepts, k8s/README.md documents GPU placement, and the gateway's ServiceMonitor moves to the llm stack #1367 has added it), declares stack names once, and adds the push table's derived entries and Secret types, each with tests. It changes no manifest under k8s/.
  2. PR 2 (M), "Closes feat(k8s): mattermost team edition runs under argo cd from the mattermost operator, on a cloudnativepg database and a protected volume, at https://mattermost.<domain> through the tunnel #1391". It delivers the rest of the body: the namespaces and LimitRange, the three Applications and their projects, the values files, k8s/mattermost/, the host override, the mattermost/mattermost-db row, the chat stack, the perimeters, the alerts and the guide.

Acceptance criteria (these replace the body's _KUSTOMIZATIONS_BY_STACK["chat"] bullet and its "set as the owner decides" bullet; every other criterion, security criteria included, still applies)

  • mattermostEnv sets MM_EMAILSETTINGS_SENDPUSHNOTIFICATIONS=false and MM_PLUGINSETTINGS_ENABLEREMOTEMARKETPLACE=false (D6). Both are asserted in tests/test_third_party_telemetry.py, next to the diagnostics pair.
  • The post-Helm step (added by whichever of feat(k8s): mattermost team edition runs under argo cd from the mattermost operator, on a cloudnativepg database and a protected volume, at https://mattermost.<domain> through the tunnel #1391 and fix(k8s): deploy-stack warns about GPU nodes no Ollama tier accepts, k8s/README.md documents GPU placement, and the gateway's ServiceMonitor moves to the llm stack #1367 lands first):
    • stack_lifecycle.py gains one table, keyed by stack, of paths under --k8s-dir. A directory is applied with kubectl apply -k and a file with kubectl apply -f.
    • On a cluster without Argo CD, deploy-stack applies the table after the last Helm release (the loop at stack_lifecycle.py:1090-1094) and before post-deploy networking. An offline test of --stack chat records kubectl apply -k <k8s-dir>/mattermost after the Secret push and after the helm upgrade of mattermost-operator.
    • The Argo CD path (stack_lifecycle.py:1054-1063) does not change. Argo CD applies these objects, using SkipDryRunOnMissingResource=true.
    • The deploy-stack --dry-run output lists the entries under their own key and still makes no request.
    • teardown-stack deletes the entries in reverse order, before it uninstalls the releases (stack_lifecycle.py:1251-1257), and its dry run lists them.
    • _deploy_stack_network_policies (tests/test_k8s_network_policies.py:64-81) reads the table, so the Mattermost perimeters count as applied. An existence check in the style of test_manifests_by_stack_files_exist (tests/test_architectural_invariants.py:1410) covers the table's paths.
    • AGENTS.md:53 names the table alongside _MANIFESTS_BY_STACK and _HELM_RELEASES_BY_STACK.
  • The table's chat entry is (Path("mattermost"),). _KUSTOMIZATIONS_BY_STACK gains no chat entry, and the root k8s/kustomization.yaml does not list mattermost.
  • Stack names live in one tuple in networking.py. _resolve_stacks derives all and the valid names from that tuple, and stack_lifecycle.py keeps no copy. Every help text that lists stacks names chat: the --stack help of deploy-stack and teardown-stack (HELP.k8s.stack, src/devops_cli/lang/en/help.py:410, today "infra | llm | all"), the deploy-stack summary (:326) and the push_stack help (:332-334). The 2026-10-08 refinement's dry-run checkbox still applies.
  • The guide also says two things. First, deploy chat with the default --wait, because CloudNativePG's admission webhook refuses the Cluster until its operator is ready. Second, on a cluster without Argo CD, teardown-stack --stack chat deletes the database and the files claim.

Current references (checked at 3dd7fa6; covers the new code paths and the body references that moved)

  • src/devops_cli/commands/k8s/stack_lifecycle.py: :206-212 (_KUSTOMIZATIONS_BY_STACK, "before any Secret or chart"), :214 (VALID_STACKS), :1054-1063 (Argo CD early return), :1068-1070 (step 4), :1072-1075 (Secret push), :1090-1094 (Helm releases), :1096-1101 (post-deploy), :1233-1260 (teardown steps).
  • src/devops_cli/commands/k8s/networking.py:65 and :68-78. src/devops_cli/lang/en/help.py:326, :332-334 and :410.
  • src/devops_cli/config/constants.py:679-684 (was :688). src/devops_cli/k8s/cluster_secrets.py:34-80 (was :33-79). These are unchanged: secret_push.py:566, argocd_overrides.py:42-59 and :108-130, tests/test_k8s_push_secrets.py:330-334, k8s/devops/roadmap-service/networkpolicy.yaml:15-25, k8s/devops/networkpolicy.yaml:44-55 and k8s/argocd/apps/prometheus-operator-crds.yaml:34.
  • tests/test_k8s_argocd_apps.py:52, :217, :277-309 and :396. tests/test_k8s_network_policies.py:34 (TARGET_NAMESPACES). tests/test_k8s_monitoring_alerting.py:30-75 (SERVED_SERIES).
  • k8s/monitoring/networkpolicy.yaml:80-101 (API-server rule) and :103-146 (namespace egress). k8s/monitoring/grafana-values.yaml:116-121. k8s/monitoring/k8s-monitoring-values.yaml:146-148. k8s/README.md:145 (no ingress ipBlock, was :147) and :145-149 (kube-router and host-network traffic, was the Key question's :147-151).
  • SkipDryRunOnMissingResource=true is now set only in k8s/argocd/apps/k8s-monitoring.yaml:34 and ingress.yaml:28. dcgm-exporter.yaml no longer sets it.
  • AGENTS.md:50 is the rule to confirm before turning off a functional web integration (was :55). AGENTS.md:51-53 is the deploy-stack rule (was :56-58).

Dependencies and order


Problem

No chat server runs in the cluster. On 2026-10-08 the live namespaces were argocd, cloudflared, default, devops, kube-node-lease, kube-public, kube-system, llm, local-path-storage, logging, monitoring, otel and registry. Every integration in #1390 needs one.

What the Operator needs

Sources: the operator v1.25.x source and the mattermost-operator chart 1.0.5, read 2026-10-08.

  • A database Secret with DB_CONNECTION_STRING. An external database is a Secret that must hold that key (pkg/mattermost/database_external.go:35). Mattermost v11 needs PostgreSQL 14 or later.
  • No readiness init container, unless asked for.
  • A claim for files.
  • SiteURL from the Ingress host. The Operator sets MM_SERVICESETTINGS_SITEURL to https://<spec.ingress.host> (siteURLFromHost, pkg/mattermost/helpers.go). TLS ends at Cloudflare, so that is the right URL.
  • Defaults to override.
    • The Operator sets MM_PLUGINSETTINGS_ENABLEUPLOADS=true, MM_METRICSSETTINGS_ENABLE=true and MM_CLUSTERSETTINGS_ENABLE=true (pkg/mattermost/env_var.go).
    • It sets MM_FILESETTINGS_MAXFILESIZE to 1000 MB (constants.go).
    • An entry in spec.mattermostEnv replaces any of these by name (mergeEnvVars, helpers.go).
  • Rolling updates by default. Two pods on different nodes can't mount one ReadWriteOnce claim. deploymentTemplate.deploymentStrategyType: Recreate is supported (operator feat(github): in-flight work, pr stagnation & blocker radar (devops gh pm inflight) #418).
  • Team Edition by image. The default image is mattermost/mattermost-enterprise-edition (apis/mattermost/v1beta1/mattermost_utils.go:20); spec.image selects mattermost/mattermost-team-edition. The Operator labels Mattermost's pods app: mattermost and installation.mattermost.com/installation: <name> (mattermost_utils.go:288-312).
  • The chart can't set the operator's resources. Chart 1.0.5's templates/mattermost-operator/deployment.yaml templates only the top-level podSecurityContext and securityContext, the args, the env and the image. Its values.yaml has no resources key.
  • The CRDs are large.
    • The Mattermost CRD is 259,446 bytes as compact JSON, within about 2.7 KB of the 262,144-byte last-applied annotation once Argo CD adds its tracking annotation.
    • CloudNativePG 0.29.1's largest CRDs are poolers.postgresql.cnpg.io (about 679 KB of YAML) and clusters.postgresql.cnpg.io (about 470 KB), each beyond that limit on its own.
  • Which line. v11.7 is the current Extended Support Release, supported until 2027-05-15; its latest patch was v11.7.11 (2026-09-15) on 2026-10-08.

What this repository has, and what it lacks

  • Hosts. Homelab hosts reach Argo CD as Kustomize patches, which devops k8s deploy-stack writes on raw Applications (fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290).
    • _host_fields reads only Ingress rules, Ingress TLS hosts and IngressRoute matches (src/devops_cli/k8s/argocd_overrides.py:108-130).
    • application_source refuses an Application with spec.sources (:42-59, the refusal at :47-51). So a Helm Application can't carry a deploy-time host.
    • CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS is ("devops", "ingress") (src/devops_cli/config/constants.py:688). cluster ignores spec.source.kustomize on those two only (k8s/argocd/bootstrap/cluster.yaml).
  • Stacks. VALID_STACKS holds infra, llm, logging, devops and all (src/devops_cli/commands/k8s/stack_lifecycle.py:203). AGENTS.md:56-58 requires a deploy-stack path, included in all, for every in-cluster workload.
  • Secrets.
    • The push table has four kinds of source: a keyring entry, gh's machine token, a setting and a literal (src/devops_cli/k8s/cluster_secrets.py:33-79).
    • None can build one value from another. DB_CONNECTION_STRING must be built from the password the database is bootstrapped with.
    • Every pushed Secret is Opaque (src/devops_cli/k8s/secret_push.py:566), and CloudNativePG's bootstrap.initdb.secret expects kubernetes.io/basic-auth. Kubernetes requires only username or password in such a Secret, so the extra DB_CONNECTION_STRING key is allowed (pkg/apis/core/validation/validation.go).
    • A row's restart targets must be a workload rendered from a manifest under k8s/ or a Helm release's name (test_every_restart_target_is_a_manifest_workload_or_helm_release, tests/test_k8s_push_secrets.py:330-334). The Operator creates deployment/mattermost, which is neither.
  • Data safety. test_namespace_and_pvc_data_safety checks only Namespaces and PVCs (tests/test_k8s_argocd_apps.py:271-303). CloudNativePG gives its claims an owner reference to the Cluster object, so deleting that object deletes the database volume's claim.
  • Sync order. The mattermost Application renders Cluster, Mattermost and PodMonitor objects whose CRDs other Applications install. The repository handles that with SkipDryRunOnMissingResource=true (k8s/argocd/apps/k8s-monitoring.yaml:34, ingress.yaml:28, dcgm-exporter.yaml:34), and large CRDs with ServerSideApply=true (prometheus-operator-crds.yaml:34).
  • Monitoring.
    • Alloy reads PodMonitors (prometheusOperatorObjects, k8s/monitoring/k8s-monitoring-values.yaml:147-149), and the PodMonitor CRD is installed.
    • Grafana's sidecar loads dashboards from every namespace (k8s/monitoring/grafana-values.yaml:108-113).
    • The monitoring perimeter has no egress to the new namespaces (k8s/monitoring/networkpolicy.yaml:102-132).
  • Perimeter shape. The monitoring perimeter's API-server rule (k8s/monitoring/networkpolicy.yaml:79-101) needs an all-addresses ipBlock on 443, 6443 and other ports, because kube-router checks API traffic after DNAT against the node's address. In a namespace-wide policy, that peer would let every pod reach any public host on 443.
  • Tunnel. The wildcard route, DNS record and Access application already cover any <name>.<domain> host (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081 describes them), so a new host needs only an Ingress.

Acceptance criteria

In the gate.

  • New tests touch no cluster and no network, and they use structural tuple assertions.

  • Each new test's call phase stays under 1 s, as uv run pytest tests/test_k8s_mattermost.py tests/test_k8s_argocd_apps.py tests/test_k8s_argocd_overrides.py tests/test_k8s_network_policies.py tests/test_k8s_push_secrets.py tests/test_third_party_telemetry.py tests/test_k8s_monitoring_alerting.py --durations=0 shows.

  • Namespaces. k8s/namespaces.yaml gains mattermost, cnpg-system and mattermost-operator, each like otel:

    • Pod Security restricted for enforce, warn and audit;
    • argocd.argoproj.io/sync-options: Prune=false,Delete=false.
  • CloudNativePG. k8s/argocd/apps/cloudnative-pg.yaml, project homelab-system:

    • chart cloudnative-pg from https://cloudnative-pg.github.io/charts, at an exact version;
    • values from $values/k8s/mattermost/cloudnative-pg-values.yaml; destination cnpg-system;
    • syncOptions: [ServerSideApply=true], as prometheus-operator-crds has, because single CRDs exceed the last-applied annotation (Problem);
    • values: monitoring.podMonitorEnabled: true and monitoring.grafanaDashboard.create: true, for the operator's metrics and CloudNativePG's own dashboard;
    • values: restricted security contexts; requests of 50m and 128Mi; limits of 500m and 512Mi.
  • Mattermost Operator. k8s/argocd/apps/mattermost-operator.yaml, project homelab-system:

    • chart mattermost-operator from https://helm.mattermost.com, at an exact version, with the chart's own image tag;
    • values from $values/k8s/mattermost/mattermost-operator-values.yaml: restricted top-level podSecurityContext and securityContext;
    • syncOptions: [ServerSideApply=true], because the Mattermost CRD is within 2.7 KB of the annotation limit;
    • destination mattermost-operator.
  • The operator's resources. The chart can't set them, so a LimitRange in namespace mattermost-operator, in the root kustomization beside k8s/namespaces.yaml, gives containers default requests of 50m and 64Mi and default limits of 500m and 256Mi. A test asserts it.

  • Projects.

    • homelab-system gains both chart repositories, and the destinations cnpg-system and mattermost-operator.
    • homelab gains the destination mattermost.
    • test_application_projects_and_destinations (tests/test_k8s_argocd_apps.py:51) counts the two operator Applications among the system apps.
  • The Application. k8s/argocd/apps/mattermost.yaml, project homelab:

    • one spec.source, with path k8s/mattermost; destination mattermost;
    • the finalizer, automated prune and selfHeal, and the retry the other leaf Applications have;
    • syncOptions: [SkipDryRunOnMissingResource=true], so a first sync before the operators' CRDs exist doesn't exhaust its retries.
    • k8s/mattermost/kustomization.yaml lists exactly networkpolicy.yaml, database.yaml, files-pvc.yaml, mattermost.yaml and podmonitor.yaml.
  • Database (database.yaml): a CloudNativePG Cluster named mattermost-db, with:

    • one instance;
    • imageName pinned to ghcr.io/cloudnative-pg/postgresql:<major>.<minor>, major 17;
    • 10Gi on local-path;
    • bootstrap.initdb creating database mattermost, owned by mattermost, from Secret mattermost-db;
    • superuser access off (the default, asserted);
    • requests of 100m and 256Mi; limits of 1 CPU and 1Gi;
    • the annotation argocd.argoproj.io/sync-options: Prune=false,Delete=false;
    • no monitoring.enablePodMonitor, which CloudNativePG deprecated. Instead, podmonitor.yaml selects cnpg.io/cluster: mattermost-db on port metrics.
  • Files (files-pvc.yaml): claim mattermost-files, 10Gi, ReadWriteOnce, on local-path, annotated Prune=false,Delete=false.

  • Mattermost (mattermost.yaml): an installation.mattermost.com/v1beta1 Mattermost named mattermost, annotated Prune=false,Delete=false.

    • image: mattermost/mattermost-team-edition, with version pinned to an exact 11.7 patch.
    • One replica, and deploymentTemplate.deploymentStrategyType: Recreate.
    • database.external.secret: mattermost-db. That Secret has no DB_CONNECTION_CHECK_URL, so no init container is added.
    • fileStore.externalVolume.volumeClaimName: mattermost-files.
    • ingress:
      • enabled, with host mattermost.example.com and ingressClass: traefik;
      • the annotation traefik.ingress.kubernetes.io/router.entrypoints: web, as in k8s/ingress/ingress-routes.yaml;
      • no tlsSecret.
    • podTemplate security contexts:
      • non-root, as the image's own user and group 2000, with fsGroup 2000;
      • RuntimeDefault seccomp, no privilege escalation, all capabilities dropped;
      • a writable root filesystem, because Mattermost unpacks its bundled plugins at start.
    • scheduling.resources: requests of 100m and 512Mi; limits of 2 CPU and 2Gi.
    • mattermostEnv has exactly these entries, each asserted:
      • MM_LOGSETTINGS_ENABLEDIAGNOSTICS=false and MM_SERVICESETTINGS_ENABLESECURITYFIXALERT=false: telemetry and the update check. They are asserted in tests/test_third_party_telemetry.py.
      • MM_PLUGINSETTINGS_ENABLEUPLOADS=false, MM_METRICSSETTINGS_ENABLE=false and MM_CLUSTERSETTINGS_ENABLE=false, which replace the Operator's defaults.
      • MM_FILESETTINGS_MAXFILESIZE=99000000. Cloudflare's 100 MB limit applies to the whole multipart request, so a file at exactly 100 MB would get a 413 at the edge before Mattermost sees it. The test's comment says so.
      • MM_TEAMSETTINGS_ENABLEOPENSERVER=false.
      • MM_LOGSETTINGS_ENABLEFILE=false, so logs go only to stdout, which Alloy ships to Loki.
      • MM_SERVICESETTINGS_ENABLELOCALMODE=true, so mmctl --local works through kubectl exec and nowhere else.
      • MM_EMAILSETTINGS_SENDPUSHNOTIFICATIONS and MM_PLUGINSETTINGS_ENABLEREMOTEMARKETPLACE, set as the owner decides (Key questions).
  • The host at deploy time.

    • _host_fields also reads a Mattermost object's /spec/ingress/host, and each of its /spec/ingress/hosts/<i>/hostName.
    • CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS gains mattermost, and CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS_BY_STACK["chat"] is ("mattermost",).
    • The ignoreDifferences in cluster.yaml gains mattermost, as test_the_app_of_apps_keeps_the_hosts_deploy_stack_sets_on_the_homelab_applications requires.
    • Checked in tests/test_k8s_argocd_overrides.py: host_patches over kubectl kustomize k8s/mattermost gives one patch, for the Mattermost object. It tests /spec/ingress/host, then replaces it with mattermost.<configured domain>.
  • Derived entries and Secret types in the push table. These are new table features that feat(k8s): alertmanager posts critical and warning alerts to mattermost's alerts channel, and a roadmap service repository whose rounds all fail for an hour alerts #1392 and feat(k8s): argo cd's notifications controller posts the devops application's deploys and every failed sync to mattermost's deploys channel #1393 reuse.

    • A derived entry's value is built from other values of the same push, and never stored on its own. --plan shows it as derived, and --dry-run as <placeholder>.
    • A row may name its Secret type; it defaults to Opaque.
    • The in-cluster base URL http://mattermost.mattermost.svc.cluster.local:8065 is one constant in src/devops_cli/config/constants.py.
  • The database Secret. The push table gains mattermost/mattermost-db, stack chat, of type kubernetes.io/basic-auth, with no restart target:

    • username comes from the literal mattermost.
    • password comes from the keyring-only key mattermost_db_password. It is adopted from the live Secret, or else generated with token_urlsafe(32).
    • DB_CONNECTION_STRING is derived from those two: postgres://<masked-user>:<masked-password>@mattermost-db-rw.mattermost.svc.cluster.local:5432/mattermost?sslmode=require&connect_timeout=10. Both credentials are quoted with urllib.parse.quote(..., safe="").
    • It restarts nothing: the first push happens before either reader can start, and rotation is out of scope (Key questions). So the restart guard needs no change.
    • Tests check that:
      • the DSN parses back with urllib.parse.urlsplit to the same user, password, host and database;
      • the pushed manifest has type kubernetes.io/basic-auth;
      • keyring_only_keys() includes the new key;
      • the homelab project ignores the Secret as an orphan.
  • The chat stack. VALID_STACKS and all gain chat.

    • _HELM_REPOS_BY_STACK["chat"] holds both chart repositories.
    • _HELM_RELEASES_BY_STACK["chat"] holds cloudnative-pg, then mattermost-operator, at the Applications' versions.
    • _KUSTOMIZATIONS_BY_STACK["chat"] is (Path("mattermost"),). It is applied after both releases, because it needs their CRDs.
    • On an Argo CD-managed cluster, --stack chat pushes mattermost/mattermost-db and sets the mattermost Application's host, as --stack devops does for its own.
    • deploy-stack --stack chat --dry-run lists the releases, the kustomization, the Secret's key names and the host patch, and it makes no request.
  • Perimeter. k8s/mattermost/networkpolicy.yaml holds two policies, and mattermost joins TARGET_NAMESPACES (tests/test_k8s_network_policies.py:16).

    • mattermost-default-perimeter selects every pod in the namespace. It admits:

      • Traefik's pods, on 8065, with the namespace and pod selectors in one peer, as in k8s/devops/roadmap-service/networkpolicy.yaml:15-25;
      • pods in mattermost;
      • namespace cnpg-system, on 8000 and 5432, as CloudNativePG's "Networking" page asks;
      • namespace monitoring, on 9187.

      Its egress allows DNS and pods in mattermost, and nothing else.

    • mattermost-db-api selects only cnpg.io/cluster: mattermost-db, which covers the instance pods and CloudNativePG's bootstrap and join Jobs. It allows egress to the Kubernetes API on 443 and 6443, which the instance manager needs, in the shape of k8s/monitoring/networkpolicy.yaml:79-101.

    • A test asserts that no policy with an ipBlock egress peer selects a pod labelled app: mattermost.

    • No ingress peer is an ipBlock (k8s/README.md:147).

    • The monitoring perimeter gains egress to mattermost on 9187, and to cnpg-system on the operator's metrics port.

  • Alerts. Two rules in prometheus-values.yaml, each with for, a severity and annotations. Their series join SERVED_SERIES (tests/test_k8s_monitoring_alerting.py:31-75), each with what serves it.

    • MattermostUnavailable (warning): kube_deployment_status_replicas_available{namespace="mattermost", deployment="mattermost"} < 1 for 10m.
    • MattermostDatabaseDown (warning): max(cnpg_collector_up{namespace="mattermost"}) < 1 or absent(cnpg_collector_up{namespace="mattermost"}) for 5m, so a database pod that is gone or never scheduled fires too.
  • Ownership and data safety in the gate. test_rendered_raw_objects_single_ownership (tests/test_k8s_argocd_apps.py:211) and test_namespace_and_pvc_data_safety both build k8s/mattermost. The data-safety test also checks Cluster and Mattermost objects.

  • Guide. A "Mattermost" section in k8s/README.md covers:

    • what runs where, and the in-cluster and tunnel addresses. The tunnel diagram gains mattermost.<domain>.
    • The rollout order:
      1. Merge. Argo CD creates the namespaces and the objects, and the database waits for its Secret. MattermostDatabaseDown fires until step 2.
      2. uv run devops k8s deploy-stack --stack chat --context <context> pushes the Secret and sets the host.
      3. The owner signs up first, from the bypassed address.
      4. Set both PVs to Retain.
    • creating the team and the channels alerts and deploys, and that every incoming webhook is created with "Lock to this channel" (feat(k8s): the homelab hosts mattermost, and the cluster's alerts and argo cd deploys post to its channels #1390);
    • what is lost with a node, since nothing is backed up;
    • the upload limit, and the mobile app's limit;
    • upgrades, by changing version. With Recreate, an upgrade means a short outage;
    • resetting a password without email: kubectl -n mattermost exec deploy/mattermost -- mmctl --local user change-password <user> --password <new>.
  • uv run devops pr check-readiness passes.

  • uv run devops ci passes within its 5-minute budget.

Pending a person, after merge, with the cluster's context, from the devcontainer:

  • (a) kubectl -n argocd get application cloudnative-pg mattermost-operator mattermost shows all three as Synced and Healthy.
  • (b) kubectl label --dry-run=server --overwrite ns mattermost cnpg-system mattermost-operator pod-security.kubernetes.io/enforce=restricted prints no warning.
  • (c) The database and Mattermost are up:
    • kubectl -n mattermost get cluster mattermost-db -o jsonpath='{.status.phase}' prints Cluster in healthy state;
    • kubectl -n mattermost get mattermost mattermost -o jsonpath='{.status.state}' prints stable.
  • (d) The data is kept:
    • the Cluster, the Mattermost object, claim mattermost-files and namespace mattermost all carry Prune=false,Delete=false;
    • both bound PVs print Retain for .spec.persistentVolumeReclaimPolicy.
  • (e) curl -s https://mattermost.<domain>/api/v4/system/ping prints "status":"OK" from the bypassed address. From a network outside the bypass, the same URL redirects to the Access login.
  • (f) No placeholder is left:
    • kubectl -n mattermost get deploy mattermost -o jsonpath='{.spec.template.spec.containers[0].env}' holds MM_SERVICESETTINGS_SITEURL set to https://mattermost.<domain>;
    • kubectl get ingress -A -o yaml | grep example.com prints nothing.
  • (g) The web app stays connected for 10 minutes with no "connection lost" banner, which shows that WebSockets pass through cloudflared and Traefik.
  • (h) Once the owner's account exists, a sign-up attempt in a private window finds no way to create an account.
  • (i) kubectl -n mattermost exec deploy/mattermost -- curl -s -m 5 -o /dev/null -w '%{http_code}\n' https://github.com fails.
  • (j) Monitoring sees it:
    • cnpg_collector_up{namespace="mattermost"} is 1 in Prometheus;
    • CloudNativePG's dashboard shows the cluster;
    • Loki has lines for {namespace="mattermost"}.
  • (k) After kubectl -n mattermost rollout restart deploy/mattermost, kubectl -n mattermost get pods -w never shows two Running Mattermost pods.
  • (l) kubectl -n mattermost-operator get pod -o jsonpath='{.items[0].spec.containers[0].resources}' shows the LimitRange's defaults.
  • (m) From a phone outside the bypass, the mobile app either completes the Access login or doesn't; the result goes into the guide's mobile-app note.

Key questions

  • CloudNativePG, or a plain PostgreSQL StatefulSet? Proposed: CloudNativePG.
  • Team Edition on an Operator whose documented support covers only Entry and the Enterprise plans? Proposed: yes. spec.image is part of the Operator's API, and the Operator is open source. If an Operator release stops working with Team Edition, the fallback is to pin the last one that does, or to move to Entry within its message limit.
  • Where do the operators' values live? Proposed: in k8s/mattermost/, beside what uses them. CloudNativePG moves into its own directory and the infra stack when a second database appears.
  • A chat stack in all, or only on the homelab, as feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081 proposes for Gitea? Proposed: a chat stack in all, as AGENTS.md:56-58 requires. On minikube, --stack all then also runs Mattermost and PostgreSQL, about 1 GiB more in memory requests.
  • Perimeters for the operator namespaces? Proposed: none in this item.
    • The API server calls CloudNativePG's admission webhooks (port 9443, failurePolicy: Fail) from the control-plane node's host network.
    • kube-router admits host-network traffic only to pods on the same node, and an address range would admit every pod (k8s/README.md:147-151).
    • So a default-deny ingress would refuse the database's creation whenever the operator runs on another node.
  • A LimitRange, or an unbounded operator pod? Proposed: the LimitRange. It is the Kubernetes way to bound a pod whose chart exposes no resources, and it touches nothing else in a namespace that holds only the operator.
  • Which Mattermost line? Proposed: the newest patch of the current Extended Support Release (11.7.x), moving to the next ESR when it ships. ESRs get security fixes for longer and change less often. v12.0 is still a release candidate.
  • PostgreSQL 17 or 18? Proposed: 17. Mattermost's minimum is 14, and it names no maximum. 17 has had a year of releases.
  • Operator chart 1.0.5 with its own image, or a newer operator image? Proposed: the chart's own, v1.25.4.
    • Its CRD defines every field this item uses: image, externalVolume, deploymentStrategyType and ingressClass.
    • A newer image with an older CRD would lose any field the API server doesn't know.
  • Push notifications and the remote Marketplace? Owner decision. AGENTS.md:55 asks for a person's confirmation before an agent turns off a functional web integration, and it names remote marketplace catalogs as an example.
    • Proposed: push notifications off. Away from the bypassed address, the mobile app meets Access. Each notification would also go through Mattermost's hosted test proxy.
    • Proposed: the Marketplace off. Bundled plugins still install, and plugin uploads are off.
    • Turning either one on needs public HTTPS egress for the Mattermost pods only, in a policy of its own in the shape of k8s/devops/networkpolicy.yaml:44-55.
  • Who creates the admin? Proposed: the owner, by signing up first, right after the rollout.
    • Access admits only the owner, so no one else can sign up first.
    • No admin password goes through the keyring. The person keeps it.
  • Rotating the database password? Proposed: out of scope. The generated password stays: initdb sets it once, so a changed keyring value pushed with --rotate would break the connection. A later item proves a rotation path through CloudNativePG's spec.managed.roles, and adds the restart it needs then.

Strategic alignment

Update 2026-10-08: refinement

The chat kustomization cannot go in _KUSTOMIZATIONS_BY_STACK, applied before Secrets and charts (commands/k8s/stack_lifecycle.py:197-203); deploy-stack gains a post-Helm step, which #1367 also needs. Stack names live in three places.

  • deploy-stack --stack chat --dry-run and --stack all --dry-run select chat.

Proposed design

Problem statement

No chat server runs in the cluster. Every integration in #1390 needs one. This issue deploys Mattermost Team Edition v11.7.x under Argo CD using the mattermost-operator chart and a CloudNativePG PostgreSQL 17 database on a protected volume. The service is at https://mattermost. through the tunnel. It adds a chat stack, derived Secret entries, and supporting manifests.

Acceptance criteria

  • Criterion 1: mattermostEnv sets MM_EMAILSETTINGS_SENDPUSHNOTIFICATIONS=false and MM_PLUGINSETTINGS_ENABLEREMOTEMARKETPLACE=false.
    Verification: tests/test_third_party_telemetry.py asserts both values next to the diagnostics pair.
  • Criterion 2: deploy-stack applies the post-Helm table after the last Helm release and before post-deploy networking.
    Verification: An offline test of --stack chat records kubectl apply -k /mattermost after the Secret push and after helm upgrade of mattermost-operator.
  • Criterion 3: The post-Helm table's chat entry is (Path('mattermost'),) and _KUSTOMIZATIONS_BY_STACK has no chat entry.
    Verification: The root k8s/kustomization.yaml does not list mattermost.
  • Criterion 4: Stack names live in one tuple in networking.py and _resolve_stacks derives all from it.
    Verification: stack_lifecycle.py keeps no copy and every help text that lists stacks names chat.
  • Criterion 5: k8s/namespaces.yaml gains mattermost, cnpg-system, and mattermost-operator with restricted Pod Security and Prune=false,Delete=false.
    Verification: A test asserts the three namespaces exist with the required labels and annotations.
  • Criterion 6: The CloudNativePG Application uses ServerSideApply=true and an exact chart version.
    Verification: k8s/argocd/apps/cloudnative-pg.yaml has syncOptions with ServerSideApply=true and a pinned version.
  • Criterion 7: The Mattermost Operator Application uses ServerSideApply=true and an exact chart version.
    Verification: k8s/argocd/apps/mattermost-operator.yaml has syncOptions with ServerSideApply=true and a pinned version.
  • Criterion 8: A LimitRange in mattermost-operator gives default requests of 50m/64Mi and limits of 500m/256Mi.
    Verification: A test asserts the LimitRange values in the root kustomization.
  • Criterion 9: The mattermost Application uses SkipDryRunOnMissingResource=true and its kustomization lists exactly five files.
    Verification: k8s/mattermost/kustomization.yaml lists networkpolicy.yaml, database.yaml, files-pvc.yaml, mattermost.yaml, and podmonitor.yaml.
  • Criterion 10: The database Cluster is named mattermost-db with PostgreSQL 17, 10Gi on local-path, and Prune=false,Delete=false.
    Verification: k8s/mattermost/database.yaml has the required fields, annotation, and bootstrap.initdb from Secret .
  • Criterion 11: The files claim is mattermost-files, 10Gi, ReadWriteOnce, on local-path, with Prune=false,Delete=false.
    Verification: k8s/mattermost/files-pvc.yaml has the required fields and annotation.
  • Criterion 12: The Mattermost object uses team-edition image, Recreate strategy, and all required mattermostEnv entries.
    Verification: k8s/mattermost/mattermost.yaml has the required fields and tests assert each env entry by name.
  • Criterion 13: _host_fields reads a Mattermost object's /spec/ingress/host and CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS gains mattermost.
    Verification: tests/test_k8s_argocd_overrides.py checks host_patches over kubectl kustomize k8s/mattermost gives one patch for the Mattermost object.
  • Criterion 14: The push table supports derived entries and named Secret types defaulting to Opaque.
    Verification: A derived entry's value is built from other values, --plan shows it as derived, and --dry-run shows a placeholder.
  • Criterion 15: The push table gains mattermost/mattermost-db with type kubernetes.io/basic-auth and a derived DB_CONNECTION_STRING.
    Verification: Tests check the DSN parses back with urllib.parse.urlsplit and the pushed manifest has type kubernetes.io/basic-auth.
  • Criterion 16: VALID_STACKS and all gain chat with the correct Helm repos, releases, and post-Helm entry.
    Verification: deploy-stack --stack chat --dry-run lists the releases, kustomization, Secret key names, and host patch with no request.
  • Criterion 17: k8s/mattermost/networkpolicy.yaml holds two policies and mattermost joins TARGET_NAMESPACES.
    Verification: tests/test_k8s_network_policies.py asserts the policies and no ipBlock egress peer selects a pod labelled app: mattermost.
  • Criterion 18: Two alert rules join SERVED_SERIES with for, severity, and annotations.
    Verification: tests/test_k8s_monitoring_alerting.py asserts MattermostUnavailable and MattermostDatabaseDown.
  • Criterion 19: test_rendered_raw_objects_single_ownership and test_namespace_and_pvc_data_safety build k8s/mattermost.
    Verification: Both tests pass and the data-safety test checks Cluster and Mattermost objects.
  • Criterion 20: A Mattermost section in k8s/README.md covers rollout order, data safety, and operations.
    Verification: The section names the tunnel address, the four rollout steps, and the password reset command.
  • Criterion 21: uv run devops pr check-readiness passes.
    Verification: The command exits with status 0.
  • Criterion 22: uv run devops ci passes within its 5-minute budget.
    Verification: The CI workflow completes with all checks green.

Key questions

  • CloudNativePG, or a plain PostgreSQL StatefulSet?: CloudNativePG. It is the CNCF operator named in feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081, brings minor-version upgrades, a metrics exporter, and a dashboard. A StatefulSet would mean hand-written manifests with no exporter or upgrades. (proposed)
  • Team Edition on an Operator whose documented support covers only Entry and Enterprise?: Yes. spec.image is part of the Operator's API and the Operator is open source. The fallback is to pin the last compatible Operator release or move to Entry. (proposed)
  • Where do the operators' values live?: In k8s/mattermost/, beside what uses them. CloudNativePG moves into its own directory and the infra stack when a second database appears. (proposed)
  • A chat stack in all, or only on the homelab?: A chat stack in all, as AGENTS.md:56-58 requires a deploy-stack path included in all for every in-cluster workload. [sources: AGENTS.md]
  • Perimeters for the operator namespaces?: None in this item. kube-router admits host-network traffic only to pods on the same node, and an address range would admit every pod, so a default-deny ingress would refuse database creation whenever the operator runs on another node. [sources: k8s/README.md]
  • A LimitRange, or an unbounded operator pod?: The LimitRange. It is the Kubernetes way to bound a pod whose chart exposes no resources, and it touches nothing else in a namespace that holds only the operator. (proposed)
  • Which Mattermost line?: The newest patch of the current Extended Support Release, 11.7.x. ESRs get security fixes for longer and change less often. v12.0 is still a release candidate. (proposed)
  • PostgreSQL 17 or 18?: 17. Mattermost's minimum is 14 with no named maximum. 17 has had a year of releases. (proposed)
  • Operator chart 1.0.5 with its own image, or a newer operator image?: The chart's own, v1.25.4. Its CRD defines every field this item uses. A newer image with an older CRD would lose any field the API server does not know. (proposed)
  • Push notifications and the remote Marketplace?: Both off. Decision D6, owner, 2026-10-17: Mattermost push notifications and the remote Marketplace are off. Nothing in this item needs public egress. (proposed)
  • Who creates the admin?: The owner, by signing up first, right after the rollout. Access admits only the owner, so no one else can sign up first. No admin password goes through the keyring. (proposed)
  • Rotating the database password?: Out of scope. initdb sets the password once, so a changed keyring value pushed with --rotate would break the connection. A later item proves a rotation path through CloudNativePG's spec.managed.roles. (proposed)

Open questions

  • It is the CNCF operator that feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081 names as the maintained route to PostgreSQL.
  • It brings minor-version upgrades, a metrics exporter and a dashboard. Later, its Barman Cloud plugin can bring backups.
  • A StatefulSet of the postgres image would mean hand-written manifests with no exporter, no upgrades and no backups.
  • The cost: one more operator, and cluster-wide CRDs and admission webhooks.
  • Team Edition on an Operator whose documented support covers only Entry and the Enterprise plans? Proposed: yes. spec.image is part of the Operator's API, and the Operator is open source. If an Operator release stops working with Team Edition, the fallback is to pin the last one that does, or to move to Entry within its message limit.
  • The API server calls CloudNativePG's admission webhooks (port 9443, failurePolicy: Fail) from the control-plane node's host network.
  • kube-router admits host-network traffic only to pods on the same node, and an address range would admit every pod (k8s/README.md:147-151).
  • So a default-deny ingress would refuse the database's creation whenever the operator runs on another node.
  • Its CRD defines every field this item uses: image, externalVolume, deploymentStrategyType and ingressClass.
  • A newer image with an older CRD would lose any field the API server doesn't know.
  • Proposed: push notifications off. Away from the bypassed address, the mobile app meets Access. Each notification would also go through Mattermost's hosted test proxy.
  • Proposed: the Marketplace off. Bundled plugins still install, and plugin uploads are off.
  • Turning either one on needs public HTTPS egress for the Mattermost pods only, in a policy of its own in the shape of k8s/devops/networkpolicy.yaml:44-55.
  • Access admits only the owner, so no one else can sign up first.
  • No admin password goes through the keyring. The person keeps it.

Fit

Needs splitting into 2 items:

  1. PR 1: deploy-stack declares stack names once and the push table gains derived entries and Secret types (closes feat(k8s): deploy-stack declares its stack names once, and a cluster secret row can name its Secret type and hold derived entries #2008)
  2. PR 2: deploy the chat stack with all manifests, perimeters, alerts, and guide (closes feat(k8s): mattermost team edition runs under argo cd from the mattermost operator, on a cloudnativepg database and a protected volume, at https://mattermost.<domain> through the tunnel #1391)

Suspected block

None.

Dependencies

#2008

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    type/feature
    scope/k8s
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. It is a dependency for integrations in #1390 but is not a security fix or a blocking defect, so it is needed but not urgent.
    • Value: Medium. A team chat server supports collaboration and is a prerequisite for #1390's integrations, but it is not core to the project's primary function.
    • Effort: High. It requires deploying the Mattermost operator, a CloudNativePG database, a ReadWriteMany volume, ingress through the Cloudflare tunnel, and working around Argo CD's last-applied annotation size limit for large CRDs.
  3. added this to the v0.2.38 milestone on Oct 17, 2026
  4. removed this from the v0.2.38 milestone on Oct 20, 2026
  5. 1 remaining item

  6. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at 0b76871 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • It is the CNCF operator that feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081 names as the maintained route to PostgreSQL.
    • It brings minor-version upgrades, a metrics exporter and a dashboard. Later, its Barman Cloud plugin can bring backups.
    • A StatefulSet of the postgres image would mean hand-written manifests with no exporter, no upgrades and no backups.
    • The cost: one more operator, and cluster-wide CRDs and admission webhooks.
    • Team Edition on an Operator whose documented support covers only Entry and the Enterprise plans? Proposed: yes. spec.image is part of the Operator's API, and the Operator is open source. If an Operator release stops working with Team Edition, the fallback is to pin the last one that does, or to move to Entry within its message limit.
    • The API server calls CloudNativePG's admission webhooks (port 9443, failurePolicy: Fail) from the control-plane node's host network.
    • kube-router admits host-network traffic only to pods on the same node, and an address range would admit every pod (k8s/README.md:147-151).
    • So a default-deny ingress would refuse the database's creation whenever the operator runs on another node.
    • Its CRD defines every field this item uses: image, externalVolume, deploymentStrategyType and ingressClass.
    • A newer image with an older CRD would lose any field the API server doesn't know.
    • Proposed: push notifications off. Away from the bypassed address, the mobile app meets Access. Each notification would also go through Mattermost's hosted test proxy.
    • Proposed: the Marketplace off. Bundled plugins still install, and plugin uploads are off.
    • Turning either one on needs public HTTPS egress for the Mattermost pods only, in a policy of its own in the shape of k8s/devops/networkpolicy.yaml:44-55.
    • Access admits only the owner, so no one else can sign up first.
    • No admin password goes through the keyring. The person keeps it.
  7. added
    priority/p2-medium
    status/new
    effort/medium
    value/high
    on Oct 28, 2026
  8. added
    status/in-progress
    and removed
    status/new
    on Oct 31, 2026
  9. added
    status/in-review
    and removed
    status/in-progress
    on Oct 31, 2026
  10. removed
    status/in-review
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8stype/featurevalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions