Parked: build a rootless Red-DiscordBot image (arm64) for Frostlink #52

Open
opened 2026-09-29 19:52:35 +00:00 by Exikle · 1 comment
Owner

Status: parked — needs review before any work starts.

Self-host a Red-DiscordBot instance on Frostlink (single-node ARM64 Talos, Oracle Cloud — always reachable). Instead of a community image that runs as root, build our own image in this repo following home-operations/containers conventions.

Researched 2026-09-29. Nothing built, applied, or committed.


Decisions already made

  • Cluster: Frostlink, namespace tools (currently only atuin). No new namespace.
  • Start from scratch. The old bot data (Red 3.4.7, 2021, OneDrive/Documents/duskbot-temp) is not migrated — too old, and its cog requirements were built for Python 3.8 on x86_64.
  • Disposable paths are logs + temp only. Everything else in the data dir stays on a backed-up PVC.
  • Own image, rootless, rather than phasecorex/red-discordbot or ghcr.io/rhomelab/red-discordbot (both start as root and drop privileges themselves; phasecorex exits if started non-root, so runAsNonRoot + read-only root breaks both).

Open decision — BLOCKER: arm64 builds

This repo's pipeline can only produce amd64 today:

  • Both existing apps set platforms = ["linux/amd64"] in docker-bake.hcl image-all.
  • Builds run against the remote buildkitd on Artemis (Artemis-Cluster/kubernetes/apps/forgejo/buildkit). Every Artemis node is amd64 (checked live) and no QEMU/binfmt is configured.
  • Red needs pip install in the Dockerfile, which executes on the target platform — flipping the platform list alone will not work.
Option Effort Trade-off
1. Second buildkitd on Frostlink (native arm64) — recommended ~1–2 h Two build servers; matches the "native arm runner, not QEMU" preference
2. QEMU binfmt on Artemis buildkitd ~30–60 min Simplest; slow Python builds; Talos needs a privileged binfmt pod
3. Skip own image, use phasecorex + root exception ~1 h total No pipeline work; breaks non-root rule for one app

Image design

Base: python:3.11-slim (Debian), not Alpine.

  • Red 3.5.24 (latest, 2026-03-06) supports Python 3.8.1–3.11 only — not 3.12+.
  • python:3.11-alpine exists with arm64, and Red's own 13 compiled deps all have musllinux aarch64 wheels, but cogs pip-install their requirements at runtime. Example: matplotlib has no musllinux aarch64 wheel for cp311 (verified on PyPI — only manylinux_2_28_aarch64), so it would compile inside a read-only container and fail. home-operations uses python:*-slim for the same reason (their esphome image).
  • Red does not list Alpine as a supported OS.

home-operations rules applied:

  • UID/GID 65534 (nobody:nogroup), config under /config.
  • catatonit → entrypoint.sh → exec redbot .... Single process, logs to stdout.
  • Read-only root filesystem; /tmp as emptyDir.
  • semver + rolling tags, digest-pinned, amd64 + arm64.
  • No in-container self-updates. Red version pinned via VERSION in docker-bake.hcl with a Renovate # renovate: datasource=pypi depName=Red-DiscordBot comment (like forgesync).

Config via env/flags (verified in Red 3.5.24 source):

  • Token: RED_TOKEN env var (redbot/__main__.py:348) — from 1Password ExternalSecret, never written to disk.
  • Prefix: --prefix flag only (no env var). Owner: --owner. Add --no-prompt.
  • PIP_NO_CACHE_DIR=1 so pip doesn't write to HOME.
  • Instance config is read from $XDG_CONFIG_HOME/Red-DiscordBot/config.json. A normal run only reads it (only redbot-setup, --edit, --no-instance write it), so it can be a read-only ConfigMap from Git.
Path Volume Why
$XDG_CONFIG_HOME/Red-DiscordBot/config.json ConfigMap (Git) Read-only during normal runs
data dir: all settings.json, Audio/Audio.db PVC (Kopiur → R2) Real state; Audio.db holds playlists
cogs/RepoManager/repos, cogs/CogManager/cogs, cogs/Downloader/lib PVC (Kopiur → R2) Must persist — see below
core/logs, Audio/logs, /tmp emptyDir Disposable

Why cogs can't be emptyDir: Red finds cog repos by scanning the repos folder (URLs live only inside each clone, not in settings). On boot, any cog that is missing or fails to import is permanently removed from the saved load list, and [p]cog install then refuses ("already installed") until uninstalled. Red has no reinstall-on-startup. cogs/Downloader/lib is only repopulated by [p]cog install/update, [p]pipinstall, or [p]cog reinstallreqs.

Metrics

  • Pod CPU/memory/restarts/OOM already come free from the cluster.
  • Red has no Prometheus endpoint. No existing Red metrics cog found (GitHub + web search; not proof one doesn't exist). Closest: discord-ext-prometheus (discord.py extension, last activity 2025-02).
  • Plan: small custom cog (~50–100 lines) serving /metrics — guilds, latency, command counts, errors. Bake it into the image (--cog-path + --load-cogs) so it's versioned in Git; user cogs stay on the PVC.
  • Scrape with a PodMonitor — Frostlink already uses VictoriaMetrics operator and PodMonitors (see kubernetes/apps/database/postgres/cluster/podmonitor.yaml).
  • Template to copy: kubernetes/apps/matrix/continuwuity/ (single container + Kopiur-backed PVC + 1Password ExternalSecret). Drop its route/service/config templating.
  • bjw-s app-template HelmRelease with per-app OCIRepository.
  • StorageClass openebs-zfs. Kopiur component at kubernetes/components/kopiur/ takes KOPIUR_APP (not APP).
  • Single replica, Recreate strategy.
  • Memory headroom is tight: node limits already total ~93% (actual use ~39%) as of 2026-09-29. Keep the bot's limit small.
  • Frostlink commits go straight to main after test-apply (PRs are Renovate-only).

Risks / gotchas

  • Audio cog: managed Lavalink sizes Java heap at 50% of node RAM, not the pod limit → OOMKill. Either leave Audio unloaded, [p]llset heapsize 512M, or run Lavalink as its own Deployment. Audio also needs Java 17/21 in the image, which a no-audio image avoids.
  • Discord developer portal: enable all 3 privileged intents — without Message Content no text commands work.
  • Reset the bot token. The old token is sitting in duskbot-temp/core/settings.json on OneDrive and possibly in core/logs. Generate a new one and store it in 1Password.
  • Upstream redbot-setup restore only exists in unreleased 3.5.25 — irrelevant since we're starting fresh.

Order of work

  • Decide arm64 build path (option 1/2/3 above)
  • If 1 or 2: make this repo's pipeline produce arm64
  • apps/red-discordbot/ — Dockerfile (python:3.11-slim, UID 65534, catatonit), entrypoint.sh, docker-bake.hcl with pinned VERSION + Renovate comment
  • Metrics cog baked into the image
  • New bot token in Discord portal → 1Password; enable privileged intents
  • Frostlink: tools/red-discordbot — ks.yaml, HelmRelease, OCIRepository, ExternalSecret, ConfigMap (config.json), Kopiur PVC, emptyDirs, PodMonitor
  • Test-apply on Frostlink, confirm bot online, then commit

Reference

**Status: parked — needs review before any work starts.** Self-host a Red-DiscordBot instance on Frostlink (single-node ARM64 Talos, Oracle Cloud — always reachable). Instead of a community image that runs as root, build our own image in this repo following [home-operations/containers](https://github.com/home-operations/containers) conventions. Researched 2026-09-29. Nothing built, applied, or committed. --- ## Decisions already made - **Cluster:** Frostlink, namespace `tools` (currently only atuin). No new namespace. - **Start from scratch.** The old bot data (Red 3.4.7, 2021, `OneDrive/Documents/duskbot-temp`) is **not** migrated — too old, and its cog requirements were built for Python 3.8 on x86_64. - **Disposable paths are logs + temp only.** Everything else in the data dir stays on a backed-up PVC. - **Own image, rootless**, rather than `phasecorex/red-discordbot` or `ghcr.io/rhomelab/red-discordbot` (both start as root and drop privileges themselves; phasecorex exits if started non-root, so `runAsNonRoot` + read-only root breaks both). ## Open decision — BLOCKER: arm64 builds This repo's pipeline can only produce amd64 today: - Both existing apps set `platforms = ["linux/amd64"]` in `docker-bake.hcl` `image-all`. - Builds run against the remote buildkitd on Artemis (`Artemis-Cluster/kubernetes/apps/forgejo/buildkit`). Every Artemis node is `amd64` (checked live) and no QEMU/binfmt is configured. - Red needs `pip install` in the Dockerfile, which executes on the target platform — flipping the platform list alone will not work. | Option | Effort | Trade-off | |---|---|---| | **1. Second buildkitd on Frostlink (native arm64)** — recommended | ~1–2 h | Two build servers; matches the "native arm runner, not QEMU" preference | | 2. QEMU binfmt on Artemis buildkitd | ~30–60 min | Simplest; slow Python builds; Talos needs a privileged binfmt pod | | 3. Skip own image, use phasecorex + root exception | ~1 h total | No pipeline work; breaks non-root rule for one app | ## Image design **Base: `python:3.11-slim` (Debian), not Alpine.** - Red 3.5.24 (latest, 2026-03-06) supports Python 3.8.1–3.11 only — not 3.12+. - `python:3.11-alpine` exists with arm64, and Red's own 13 compiled deps all have musllinux aarch64 wheels, but **cogs pip-install their requirements at runtime**. Example: matplotlib has no `musllinux` aarch64 wheel for cp311 (verified on PyPI — only `manylinux_2_28_aarch64`), so it would compile inside a read-only container and fail. home-operations uses `python:*-slim` for the same reason (their esphome image). - Red does not list Alpine as a supported OS. **home-operations rules applied:** - UID/GID `65534` (`nobody:nogroup`), config under `/config`. - `catatonit` → `entrypoint.sh` → `exec redbot ...`. Single process, logs to stdout. - Read-only root filesystem; `/tmp` as emptyDir. - semver + `rolling` tags, digest-pinned, amd64 + arm64. - No in-container self-updates. Red version pinned via `VERSION` in `docker-bake.hcl` with a Renovate `# renovate: datasource=pypi depName=Red-DiscordBot` comment (like forgesync). **Config via env/flags (verified in Red 3.5.24 source):** - Token: `RED_TOKEN` env var (`redbot/__main__.py:348`) — from 1Password ExternalSecret, never written to disk. - Prefix: `--prefix` flag only (no env var). Owner: `--owner`. Add `--no-prompt`. - `PIP_NO_CACHE_DIR=1` so pip doesn't write to HOME. - Instance config is read from `$XDG_CONFIG_HOME/Red-DiscordBot/config.json`. A normal run only reads it (only `redbot-setup`, `--edit`, `--no-instance` write it), so it can be a **read-only ConfigMap from Git**. ## Filesystem layout on Frostlink | Path | Volume | Why | |---|---|---| | `$XDG_CONFIG_HOME/Red-DiscordBot/config.json` | ConfigMap (Git) | Read-only during normal runs | | data dir: all `settings.json`, `Audio/Audio.db` | PVC (Kopiur → R2) | Real state; Audio.db holds playlists | | `cogs/RepoManager/repos`, `cogs/CogManager/cogs`, `cogs/Downloader/lib` | PVC (Kopiur → R2) | **Must persist** — see below | | `core/logs`, `Audio/logs`, `/tmp` | emptyDir | Disposable | **Why cogs can't be emptyDir:** Red finds cog repos by scanning the repos folder (URLs live only inside each clone, not in settings). On boot, any cog that is missing or fails to import is **permanently removed from the saved load list**, and `[p]cog install` then refuses ("already installed") until uninstalled. Red has no reinstall-on-startup. `cogs/Downloader/lib` is only repopulated by `[p]cog install/update`, `[p]pipinstall`, or `[p]cog reinstallreqs`. ## Metrics - Pod CPU/memory/restarts/OOM already come free from the cluster. - Red has **no** Prometheus endpoint. No existing Red metrics cog found (GitHub + web search; not proof one doesn't exist). Closest: `discord-ext-prometheus` (discord.py extension, last activity 2025-02). - Plan: small custom cog (~50–100 lines) serving `/metrics` — guilds, latency, command counts, errors. **Bake it into the image** (`--cog-path` + `--load-cogs`) so it's versioned in Git; user cogs stay on the PVC. - Scrape with a `PodMonitor` — Frostlink already uses VictoriaMetrics operator and PodMonitors (see `kubernetes/apps/database/postgres/cluster/podmonitor.yaml`). ## Frostlink deploy notes - Template to copy: `kubernetes/apps/matrix/continuwuity/` (single container + Kopiur-backed PVC + 1Password ExternalSecret). Drop its route/service/config templating. - bjw-s app-template HelmRelease with per-app OCIRepository. - StorageClass `openebs-zfs`. Kopiur component at `kubernetes/components/kopiur/` takes `KOPIUR_APP` (not `APP`). - Single replica, `Recreate` strategy. - **Memory headroom is tight:** node limits already total ~93% (actual use ~39%) as of 2026-09-29. Keep the bot's limit small. - Frostlink commits go straight to `main` after test-apply (PRs are Renovate-only). ## Risks / gotchas - **Audio cog:** managed Lavalink sizes Java heap at 50% of **node** RAM, not the pod limit → OOMKill. Either leave Audio unloaded, `[p]llset heapsize 512M`, or run Lavalink as its own Deployment. Audio also needs Java 17/21 in the image, which a no-audio image avoids. - **Discord developer portal:** enable all 3 privileged intents — without Message Content no text commands work. - **Reset the bot token.** The old token is sitting in `duskbot-temp/core/settings.json` on OneDrive and possibly in `core/logs`. Generate a new one and store it in 1Password. - Upstream `redbot-setup restore` only exists in unreleased 3.5.25 — irrelevant since we're starting fresh. ## Order of work - [ ] Decide arm64 build path (option 1/2/3 above) - [ ] If 1 or 2: make this repo's pipeline produce arm64 - [ ] `apps/red-discordbot/` — Dockerfile (python:3.11-slim, UID 65534, catatonit), `entrypoint.sh`, `docker-bake.hcl` with pinned `VERSION` + Renovate comment - [ ] Metrics cog baked into the image - [ ] New bot token in Discord portal → 1Password; enable privileged intents - [ ] Frostlink: `tools/red-discordbot` — ks.yaml, HelmRelease, OCIRepository, ExternalSecret, ConfigMap (config.json), Kopiur PVC, emptyDirs, PodMonitor - [ ] Test-apply on Frostlink, confirm bot online, then commit ## Reference - Red-DiscordBot: https://github.com/Cog-Creators/Red-DiscordBot (no official container image) - home-operations/containers: https://github.com/home-operations/containers - Community images checked (both have linux/arm64, verified from registry manifests): `ghcr.io/rhomelab/red-discordbot:3.5.24`, `phasecorex/red-discordbot`
Author
Owner

arm64 build research — parked 2026-10-11, nothing built or changed.

Recommended pipeline shape: build each arch on its own native builder, push by digest, merge with docker buildx imagetools create, cosign-sign the index. Keep a separate registry cache per app and arch, written on release builds only. This matches how home-operations/containers does it. Don't use a single multi-node buildx builder: registry cache export keeps only the last platform's cache (buildx#1044), and one failed arch fails the whole build.

Option A — buildkitd on Frostlink (native arm64), ~3–4h. ClusterMesh and Headscale have removed the network blocker:

  • Headscale grants 10.42.0.0/16 → 10.244.0.0/24 on all ports, so Artemis Tekton pods can reach a Frostlink pod.
  • Reach it through a ClusterMesh global service (same name and namespace in both clusters).
  • Frostlink's NetworkPolicy must name the Artemis cluster explicitly, because policyDefaultLocalCluster is on.
  • Use a shared buildkit CA in 1Password (same pattern as cilium-clustermesh-ca) to issue the Frostlink server cert and the Artemis client cert.
  • buildkitd needs its own namespace labelled privileged, because Frostlink defaults to baseline.
  • user.max_user_namespaces is already set on both clusters.
  • Frostlink memory limits are at 99% (requests 38%), so a ~4Gi buildkitd overcommits.
  • Simplest push path: the arm64 build sends its image back to the Tekton pod on Artemis, which pushes it.
  • Not tested: an actual Artemis-pod → Frostlink-pod connection for buildkit, and Frostlink pushing to registry.dcunha.io through the towonel edge.

Option B — all on Artemis, ~1–2h.

  • Cross-compile with FROM --platform=$BUILDPLATFORM plus xx. forgejo-runner already does this; forgesync would need the same change.
  • Register QEMU binfmt on the buildkitd node so the small arm64 RUN steps (apk add) can run.
  • pip install for Red would run under QEMU. That is still minutes, not hours, because its compiled deps have aarch64 wheels.

Either option also needs:

  • linux/arm64 added to image-all in each docker-bake.hcl.
  • The buildx-bake StepAction and the container-build / container-validate pipelines changed to per-arch builds plus a merge step.
  • Tekton matrix is available: v1.15 with enable-api-fields: beta.
  • Follow the two-clock order in Artemis-Cluster/.agents/references/tekton-ci.md.
**arm64 build research — parked 2026-10-11, nothing built or changed.** Recommended pipeline shape: build each arch on its own native builder, push by digest, merge with `docker buildx imagetools create`, cosign-sign the index. Keep a separate registry cache per app and arch, written on release builds only. This matches how home-operations/containers does it. Don't use a single multi-node buildx builder: registry cache export keeps only the last platform's cache (buildx#1044), and one failed arch fails the whole build. **Option A — buildkitd on Frostlink (native arm64), ~3–4h.** ClusterMesh and Headscale have removed the network blocker: - Headscale grants `10.42.0.0/16 → 10.244.0.0/24` on all ports, so Artemis Tekton pods can reach a Frostlink pod. - Reach it through a ClusterMesh global service (same name and namespace in both clusters). - Frostlink's NetworkPolicy must name the Artemis cluster explicitly, because `policyDefaultLocalCluster` is on. - Use a shared buildkit CA in 1Password (same pattern as `cilium-clustermesh-ca`) to issue the Frostlink server cert and the Artemis client cert. - buildkitd needs its own namespace labelled `privileged`, because Frostlink defaults to `baseline`. - `user.max_user_namespaces` is already set on both clusters. - Frostlink memory limits are at 99% (requests 38%), so a ~4Gi buildkitd overcommits. - Simplest push path: the arm64 build sends its image back to the Tekton pod on Artemis, which pushes it. - Not tested: an actual Artemis-pod → Frostlink-pod connection for buildkit, and Frostlink pushing to `registry.dcunha.io` through the towonel edge. **Option B — all on Artemis, ~1–2h.** - Cross-compile with `FROM --platform=$BUILDPLATFORM` plus xx. `forgejo-runner` already does this; `forgesync` would need the same change. - Register QEMU binfmt on the buildkitd node so the small arm64 `RUN` steps (`apk add`) can run. - `pip install` for Red would run under QEMU. That is still minutes, not hours, because its compiled deps have aarch64 wheels. Either option also needs: - `linux/arm64` added to `image-all` in each `docker-bake.hcl`. - The `buildx-bake` StepAction and the `container-build` / `container-validate` pipelines changed to per-arch builds plus a merge step. - Tekton matrix is available: v1.15 with `enable-api-fields: beta`. - Follow the two-clock order in `Artemis-Cluster/.agents/references/tekton-ci.md`.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Exikle/containers#52
No description provided.