Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 8s
9.7 KiB
9.7 KiB
type, status, project, date, tags
| type | status | project | date | tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| plan | completed | homelab | 2026-09-23 |
|
Plan: Clean Deprecation of Portainer from Core
Goal Description
Portainer was inherited during early Core consolidation, but its responsibility (GUI-based Docker container management) conflicts with the Homelab's architectural invariants:
- Infrastructure as Code & GitOps: All workloads and core services are declaratively defined in NixOS,
docker-compose.yml, andapp.yaml, with deployment managed viaappctland automated webhooks. Manual GUI container mutations bypass repository state. - Hardened Docker Socket: The security architecture enforces a strict read-only Docker socket proxy (
socket-proxywithPOST=0,DELETE=0,BUILD=0,EXEC=0). Portainer is unable to manage, deploy, or modify containers without weakening this boundary. - Overlapping Tools: Read-only log observation is handled by Dozzle, routing by Traefik, host lifecycle by NixOS, and service cataloging by Homepage. Portainer holds no unique responsibilities.
This plan details the complete, clean removal of Portainer across all layers of Homelab Core: Docker Compose, appctl, Homepage, NixOS SOPS secrets, structural/security tests, documentation, and production runtime cleanup.
Decisions Reached
- Volume Cleanup: Purge
core_portainer_data,homeserver_portainer_data, andportainer_portainer_dataon the server during the post-deployment cleanup phase. - SOPS Secret Removal: Remove
portainer.admin_passwordcompletely fromCore/nixos/secrets.yamlandCore/nixos/modules/homeserver.nix. - Gitea & Runner Decoupling: Retain Gitea and
act_runnerstandalone inSites/giteato maintain platform trust boundaries and unprivileged runner execution.
Architecture & Affected Components
flowchart TD
subgraph Core Repository
Compose["Core/docker-compose.yml<br/>(Remove portainer service & volume)"]
NixOS["Core/nixos/modules/homeserver.nix<br/>(Remove portainer SOPS secret & env var)"]
SOPS["Core/nixos/secrets.yaml<br/>(Prune portainer: admin_password)"]
Appctl["Core/scripts/appctl_engine.py<br/>(Remove portainer from get_core_services & metadata)"]
Homepage["Core/config/homepage/services.yaml<br/>(Regenerate / remove Portainer card)"]
Tests["Core/tests/security/test_security_invariants.py<br/>(Add absence assertion)"]
Docs["Documentation (6 files)<br/>(README, SECURITY, architecture, operations, appctl, secrets)"]
end
subgraph Production Runtime
NixRebuild["sudo nixos-rebuild switch --flake ~/Core#server<br/>(Updates env, triggers compose --remove-orphans)"]
VolPrune["docker volume rm ...<br/>(Purge stale Portainer volumes)"]
end
Compose --> NixRebuild
NixOS --> NixRebuild
SOPS --> NixRebuild
NixRebuild --> VolPrune
Component Changes
Component 1: Docker Compose & Host Orchestration
Core/docker-compose.yml:- Removed
portainerservice declaration. - Removed
portainer_data:from top-levelvolumes:.
- Removed
# Removed from Core/docker-compose.yml
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
command: >
-H tcp://socket-proxy:2375
--admin-password=${PORTAINER_ADMIN_PASSWORD}
--no-analytics
volumes:
- portainer_data:/data
networks:
- socket-net
- proxy-net
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`portainer.${DOMAIN}`)"
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.tls.certresolver=myresolver"
- "traefik.http.routers.portainer.middlewares=authelia-auth@docker"
- "traefik.http.routers.portainer.service=portainer-svc"
- "traefik.http.routers.portainer-red.rule=Host(`portainer.${DOMAIN}`)"
- "traefik.http.routers.portainer-red.entrypoints=web"
- "traefik.http.routers.portainer-red.middlewares=https-redirect@docker"
- "traefik.http.services.portainer-svc.loadbalancer.server.port=9000"
Component 2: NixOS Module & SOPS Secrets
Core/nixos/modules/homeserver.nix:- Removed
"portainer/admin_password"fromsops.secrets. - Removed
PORTAINER_ADMIN_PASSWORD = config.sops.placeholder."portainer/admin_password";fromsops.templates."homeserver.env".content.
- Removed
Core/nixos/secrets.yaml:- Decrypted via SOPS CLI and removed
portainer: admin_passwordkey block.
- Decrypted via SOPS CLI and removed
Component 3: CLI Orchestrator (appctl) & Homepage Dashboard
Core/scripts/appctl_engine.py:- Removed
"portainer"service map fromget_core_services(). - Removed
"portainer"from Homepage card weight metadata.
- Removed
Core/config/homepage/services.yaml:- Removed
Portainercard fromCore Infrastructuredashboard category.
- Removed
Component 4: Architecture & Security Invariant Tests
Core/tests/security/test_security_invariants.py:- Added regression assertion
test_portainer_is_deprecated_and_absent()verifying that neither the service nor volume exists indocker-compose.yml:
- Added regression assertion
def test_portainer_is_deprecated_and_absent():
"""Ensure portainer service and volume are completely absent from core docker-compose."""
compose_path = CORE_ROOT / "docker-compose.yml"
with open(compose_path, encoding="utf-8") as f:
compose = yaml.safe_load(f)
services = compose.get("services", {})
assert "portainer" not in services, "Deprecated service 'portainer' must not exist in docker-compose.yml"
volumes = compose.get("volumes", {})
assert "portainer_data" not in volumes, "Deprecated volume 'portainer_data' must not exist in docker-compose.yml"
Component 5: Documentation Synchronization
Core/SECURITY.md: Removed Portainer from protected proxy services.Core/README.md: Removed Portainer from platform overview, topology ASCII diagram, and routing table.Core/docs/secrets-and-state.md: Removedportainer_datafrom state table.Core/docs/appctl.md: Removedportainerfrom core service enumeration.Core/docs/operations.md: Removed Portainer from systemd and troubleshooting notes.Core/docs/architecture.md: Removed Portainer from topology and service mesh documentation.
Action Items & Milestones
- Branch Isolation: Create local git branch
fix/deprecate-portainerinCore. - Docker Compose: Remove
portainerservice block andportainer_datavolume fromCore/docker-compose.yml. - NixOS Configuration: Remove
portainer/admin_passwordfromCore/nixos/modules/homeserver.nix. - SOPS Secrets: Decrypt and prune
portainerkey fromCore/nixos/secrets.yaml. - Appctl Engine: Remove
portainerfromget_core_services()and Homepage metadata inCore/scripts/appctl_engine.py. - Homepage Config: Update
Core/config/homepage/services.yamlto remove Portainer. - Invariants & Tests: Add
test_portainer_is_deprecated_and_absenttoCore/tests/security/test_security_invariants.py. - Documentation: Clean up references in
Core/SECURITY.md,Core/README.md,Core/docs/secrets-and-state.md,Core/docs/appctl.md,Core/docs/operations.md, andCore/docs/architecture.md. - Local Validation: Run
ruff check .,pytest,nix flake check, and./scripts/test. - Commit Proposal: Propose atomic commit for user review and integration into
main. - Production Deployment: User rebuilds NixOS (
sudo nixos-rebuild switch --flake ~/Core#server), runsappctl sync, and prunes leftover volumes. - Post-Deployment Verification: Verify portainer is uninstalled, routing 404s, and Dozzle/Core remain healthy.
- Daily Journal: Log completed work in
records/journal/2026-09-23.md.
Deployment & Production Teardown Runbook
Phase 1: User-Controlled Commit & Integration
# On local workstation (/home/kiskaadee/Homelab/Core):
git checkout -b fix/deprecate-portainer
git add docker-compose.yml nixos/ scripts/ config/ tests/ docs/ README.md SECURITY.md
git commit -m "refactor(core): cleanly deprecate and remove portainer"
git checkout main
git merge fix/deprecate-portainer
git push origin main
Phase 2: Production Deployment on Server
# SSH into production server
ssh server-local
# Pull latest Core updates
cd ~/Core
git pull origin main
# Rebuild NixOS configuration (regenerates /run/secrets/homeserver.env and restarts homeserver-core with --remove-orphans)
sudo nixos-rebuild switch --flake ~/Core#server
# Sync homepage to remove Portainer card
appctl sync
Phase 3: Post-Deployment Verification
# Verify portainer container has been stopped and removed
docker ps -a --filter name=portainer
# Expected: empty table
# Verify Traefik has unregistered the portainer router
curl -kI https://portainer.roadtotech.me
# Expected: 404 Not Found (Traefik default)
# Verify Dozzle and other core services remain operational
appctl list --core
Phase 4: Stale Volume Cleanup
# Remove leftover Portainer data volumes
docker volume rm core_portainer_data homeserver_portainer_data portainer_portainer_data
Rollback Plan
If an unexpected regression occurs in the Core compose stack:
- On local workstation:
git revert HEADand push tomain. - On server:
cd ~/Core && git pull origin main && sudo nixos-rebuild switch --flake ~/Core#server.
Related Documentation & Cross-References
- Discussion: Core Service Qualification & Portainer Deprecation
- Daily Journal: Daily Journal: 2026-09-23