Skip to content

Deploying New Applications

This guide captures the decision-making process and patterns for deploying new applications to the homelab. Use this as a checklist when planning a new app deployment.

Phase 1: Analyze the Application

1.1 Identify the Stack

Start by understanding what the app needs. For Docker Compose deployments, map each service:

# Example: analyze Readest's compose.yaml
curl -s https://raw.githubusercontent.com/readest/readest/main/docker/compose.yaml

Create a table:

Service Image Port Purpose State
client ghcr.io/readest/readest 3000 Next.js web app Stateless
db supabase/postgres 5432 PostgreSQL Stateful
auth supabase/gotrue 9999 Auth service Stateless
rest postgrest/postgrest 3000 REST API Stateless
minio minio/minio 9000 S3 storage Stateful

1.2 Identify Dependencies

  • Database: Does it need PostgreSQL, MySQL, Redis, etc.?
  • Object Storage: Does it need S3/MinIO?
  • Auth: Does it support OIDC/OAuth? What provider?
  • API Gateway: Does it need Kong, Traefik, or can a Gateway API HTTPRoute (Envoy Gateway) handle it?
  • Secrets: What credentials does it need? (API keys, JWT secrets, etc.)

1.3 Check for Existing Infrastructure

Before deploying new instances, check what already exists:

# Find existing MinIO deployments
grep -r "minio" apps/ platform/ --include="*.yaml"

# Find existing Postgres deployments
grep -r "postgresql" apps/ --include="*.yaml"

# Find existing OIDC integrations
grep -r "KanidmOAuth2Client" apps/ --include="*.yaml"

Phase 2: Make Architectural Decisions

2.1 Database: Zalando vs Container

Use Zalando Postgres operator when: - The app uses standard PostgreSQL features - You want automated backups, snapshots, and operator-managed lifecycle - The app doesn't require custom Postgres extensions not in the Spilo image - The app doesn't need Supabase-specific schemas (auth, storage, realtime)

Use container Postgres when: - The app requires Supabase extensions (auth schema, GoTrue, PostgREST) - The app needs custom init scripts that conflict with Zalando's role management - The app uses a specific Postgres distribution (e.g., TimescaleDB, Citus)

Decision tree:

Does the app need Supabase auth/storage/realtime schemas?
├── YES → Use container Postgres with init scripts
└── NO → Does it need custom extensions not in Spilo?
    ├── YES → Use custom Spilo image (see immich) or container Postgres
    └── NO → Use Zalando operator

Example: Readest - Needs auth.users FK, auth.uid() in RLS, Supabase roles - Decision: Zalando for the database + init container for Supabase bootstrap SQL

Version-pinned upstream SQL on Zalando: - If upstream relies on docker-entrypoint-initdb.d, its scripts do not run on Spilo. Vendor SQL at the application image tag, review the changes, and render it into an init-container ConfigMap rather than downloading SQL at pod startup. - For incremental migrations, keep upstream filenames and order, record each applied filename in a database ledger, and do not replay the base schema. Readest is the reference: apps/readest/hack/vendor-sql-migrations.py and docs/deployment/readest.md. - For a single re-runnable schema snapshot, verify its DDL is safe on an existing database and adapt incompatible statements before committing. Firecrawl is the reference: apps/firecrawl/hack/update-nuq-sql.sh and docs/troubleshooting/firecrawl-selfhost-deployment.md. - Couple generated SQL to image updates with a Renovate post-upgrade task, disable automerge for review, check provenance in CI, and fail fast on version mismatch before touching the database. A matching version is not proof that a migration is safe or complete. - The post-upgrade task runs inside the Renovate container without GITHUB_TOKEN. Fetch upstream SQL over the git protocol (a shallow sparse git clone) or raw.githubusercontent.com; avoid api.github.com, whose unauthenticated 60 req/h limit on shared Actions runner IPs makes regeneration flaky. See apps/readest/hack/vendor-sql-migrations.py.

2.2 Object Storage: Which MinIO?

See docs/deployment/minio-architecture.md for the complete architecture, decision tree, and integration patterns.

There are three MinIO instances, pick by who fetches the objects:

Instance Path Host Reachable from internet? Use for
Internal shared platform/minio/ s3.internal.grigri.cloud No In-cluster/backup storage (Velero, Kaniop). Server-side I/O only.
Public apps/s3-public/ s3.grigri.cloud Yes Apps that hand the browser presigned URLs (e.g. Readest book downloads).
Cross-backups apps/cross-backups/ cross-backups.grigri.cloud Yes Receiving backups pushed from other machines (restic, borg, mc mirror).

Quick decision: - Browser/external client fetches objects? → Public MinIO (apps/s3-public/) - Server-side I/O only? → Internal MinIO (platform/minio/) - Receiving backups from external machines? → Cross-backups (apps/cross-backups/)

Gotcha: The internal MinIO host s3.internal.grigri.cloud is on the internal Gateway only. If an app generates presigned URLs against it, external clients fail to download. Use apps/s3-public/ and set the app's public endpoint to https://s3.grigri.cloud. See docs/deployment/s3-public.md.

Pattern for adding a bucket/user to the public MinIO (apps/s3-public/values.yaml):

buckets:
  - name: <app>-files
    policy: none
    versioning: false
    objectlocking: false

policies:
  - name: <app>Policy
    statements:
      - resources:
          - 'arn:aws:s3:::<app>-files/*'
        actions:
          - "s3:GetObject"
          - "s3:PutObject"
          - "s3:DeleteObject"
          - "s3:AbortMultipartUpload"
          - "s3:ListMultipartUploadParts"
      - resources:
          - 'arn:aws:s3:::<app>-files'
        actions:
          - "s3:GetBucketLocation"
          - "s3:ListBucket"
          - "s3:ListBucketMultipartUploads"

users:
  - accessKey: <app>
    existingSecret: s3-public-users
    existingSecretKey: <app>Password
    policy: <app>Policy

Then add <app>Password to Vault /s3-public/users and to apps/s3-public/templates/external-secrets-users.yaml. The same pattern applies to platform/minio/ (secret minio-users, Vault /minio/users) for internal buckets.

2.3 API Gateway: Kong vs Gateway API routes

Routing is done with Gateway API HTTPRoutes on the Envoy Gateways; see gateway-api-routes.md for the how-to (listeners, annotations, auth, timeouts, backend TLS, Lua, NetworkPolicies, verification).

Use an HTTPRoute when: - The app just needs path-based routing (/api/* → backend) - You don't need API-specific features (JWT validation of arbitrary issuers, request transformation chains) - The app's backend services can be reached directly via Kubernetes services

Use Kong when: - The app requires API gateway features (rate limiting per consumer, JWT validation, request transformation) - The app's Docker Compose already includes Kong with custom plugins - You need to expose multiple APIs with different auth mechanisms

Decision tree:

Does the app's compose.yaml include Kong/Traefik?
├── YES → Can HTTPRoute rules replace it with path-based routing?
│   ├── YES → Use an HTTPRoute (simpler, no extra controller)
│   └── NO → Use Kong (app requires API gateway features)
└── NO → Use an HTTPRoute

Example: Readest - Compose includes Kong for routing /auth/v1/* and /rest/v1/* - HTTPRoute path rules can handle this → no Kong needed

2.4 OIDC Integration: kaniop Pattern

When to use OIDC: - The app supports OAuth2/OIDC login - You want centralized authentication via Kanidm - You want group-based access control

Pattern:

# 1. Create KanidmGroup (access control)
apiVersion: kaniop.rs/v1beta1
kind: KanidmGroup
metadata:
  name: <app>-users
spec:
  kanidmRef: { name: kanidm, namespace: kanidm }

# 2. Create KanidmOAuth2Client (OAuth2 registration)
apiVersion: kaniop.rs/v1beta1
kind: KanidmOAuth2Client
metadata:
  name: <app>
spec:
  kanidmRef: { name: kanidm, namespace: kanidm }
  displayname: <app>
  origin: https://<app>.grigri.cloud/
  redirectUrl:
    - https://<app>.grigri.cloud/<callback-path>
  scopeMap:
    - group: <app>-users
      scopes: [openid, profile, email]
  preferShortUsername: true
  strictRedirectUrl: true

# 3. Reference credentials in app env vars
env:
  OAUTH_CLIENT_ID:
    valueFrom:
      secretKeyRef:
        name: <app>-kanidm-oauth2-credentials
        key: CLIENT_ID
  OAUTH_CLIENT_SECRET:
    valueFrom:
      secretKeyRef:
        name: <app>-kanidm-oauth2-credentials
        key: CLIENT_SECRET
  OIDC_URL: https://idm.grigri.cloud/oauth2/openid/<app>

Common callback paths: - Generic: /oauth/callback, /auth/callback - Immich: /auth/login - FreshRSS: /i/ - Open WebUI: /oauth/oidc/callback

Check the app's documentation for the exact callback URL format.

App without its own login (protected at the gateway): the route gets a SecurityPolicy (Envoy Gateway native OIDC against Kanidm plus a JWT check). There is no shared proxy and no global group: each app has its own Kanidm client, its own <app>-users group and its own claim (access = [<app>]), so a token issued for another app never authorizes this one. Copy the three objects from the recipe in gateway-api-routes.md#authentication (client, SecurityPolicy, stable route name). Apps with their own OIDC login keep it; the policy is added only when the app should not be reachable by anyone outside its group. Add people to the group by hand (kanidm.md).

2.5 Secret Management

Three-tier pattern:

  1. Zalando auto-generated secrets (database credentials)
  2. No ExternalSecret needed
  3. Reference directly: <teamId>.<cluster-name>.credentials.postgresql.acid.zalan.do
  4. Keys: username, password

  5. ExternalSecrets from Vault (app-specific secrets)

  6. API keys, JWT secrets, OAuth credentials, SMTP passwords
  7. Pattern:

    apiVersion: external-secrets.io/v1
    kind: ExternalSecret
    metadata:
      name: <app>-secrets
    spec:
      secretStoreRef:
        kind: ClusterSecretStore
        name: vault
      target:
        name: <app>-secrets
      data:
        - secretKey: JWT_SECRET
          remoteRef:
            key: /<app>/jwt
            property: secret
    

  8. kaniop auto-generated secrets (OIDC client credentials)

  9. No ExternalSecret needed
  10. Reference: <app>-kanidm-oauth2-credentials
  11. Keys: CLIENT_ID, CLIENT_SECRET

Vault path convention: - CLI access: secret/<app>/<secret-type> (e.g., secret/readest/jwt, secret/minio/users) - ExternalSecret reference: /<app>/<secret-type> (without secret/ prefix) - The ClusterSecretStore has secret/ as the base path, so ExternalSecrets omit it

Examples: - CLI: vault kv get secret/minio/users → ExternalSecret: key: /minio/users - CLI: vault kv put secret/readest/jwt secret=... → ExternalSecret: key: /readest/jwt - CLI: vault kv patch secret/minio/users readestPassword=... (add to existing secret)

Common paths: - secret/readest/jwt (secret, anon_key, service_role_key) - secret/immich/jwt (secret) - secret/minio/users (rootUser, rootPassword, veleroPassword, kaniopPassword, readestPassword) - secret/nextcloud/admin (username, password) - secret/nextcloud/smtp (username, password, host)

2.6 Image Pinning

Always pin image tags. Never use latest.

Pattern:

image:
  # renovate: datasource=docker depName=ghcr.io/readest/readest
  repository: ghcr.io/readest/readest
  tag: 0.9.20

Finding the right tag: - Check GitHub releases: https://github.com/<org>/<repo>/releases - Check container registry: ghcr.io/<org>/<repo>/tags or Docker Hub - Use the latest stable release, not pre-release/RC versions

Renovate hints: - Add # renovate: datasource=docker depName=<image> above the repository: line - This enables automatic PR updates when new versions are released - For non-standard registries, add registryUrl=https://ghcr.io

2.7 NetworkPolicy: Only for Software We Do Not Control

Do not add a NetworkPolicy to first-party apps that we build and publish ourselves (for example battery-optimizer): their behaviour is reviewed in code, and their safety guarantees (read-only adapters, no write credentials) live there. Use NetworkPolicies to contain software whose actions we do not control, such as LLM agent harnesses. Remember that ingress isolation stays off cluster-wide because of the Cilium stale-datapath bug (docs/troubleshooting/cilium-stale-bpf-egress.md). Decided by the owner on 2026-10-25, when the battery-optimizer egress policy was removed.

Phase 3: File Structure

3.1 Standard Directory Layout

apps/<app-name>/
├── Chart.yaml                          # Helm chart metadata + dependencies
├── values.yaml                         # App configuration (controllers, services, route, persistence)
└── templates/
    ├── postgresql.yaml                 # Zalando CR (if using Zalando)
    ├── external-secrets.yaml           # Vault secrets (if needed)
    ├── kanidm-oauth2-client.yaml       # OIDC client (if using OIDC)
    ├── kanidm-group.yaml               # OIDC group (if using OIDC)
    ├── pvc.yaml                        # PersistentVolumeClaims (if needed)
    ├── snapshots.yaml                  # ZFS snapshot schedule (if needed)
    └── configmap-*.yaml                # ConfigMaps (if needed)

3.2 Chart.yaml

apiVersion: v2
name: <app-name>
version: 0.0.0
dependencies:
  - name: app-template
    version: 5.1.0
    repository: https://bjw-s-labs.github.io/helm-charts/

3.3 values.yaml Structure

app-template:
  controllers:
    <app-name>:
      labels:
        backup/retain: weekly           # Backup retention policy
      type: statefulset                 # or Deployment
      containers:
        <app-name>:
          image:
            # renovate: datasource=docker depName=<image>
            repository: <image>
            tag: <version>
          env:
            # App-specific environment variables
          probes:
            liveness: &probes
              enabled: true
              custom: true
              spec:
                httpGet:
                  path: /healthz
                  port: <port>
                initialDelaySeconds: 0
                periodSeconds: 10
                timeoutSeconds: 1
                failureThreshold: 3
            readiness: *probes
            startup:
              enabled: true
              custom: true
              spec:
                httpGet:
                  path: /healthz
                  port: <port>
                failureThreshold: 30
                periodSeconds: 10
          resources:
            requests:
              cpu: 10m
              memory: 128Mi
            limits:
              memory: 512Mi

  service:
    <app-name>:
      controller: <app-name>
      ports:
        http:
          port: <port>

  # Gateway API route (internal shown; external: parentRefs `external` / `https-grigri-cloud`,
  # host <app>.grigri.cloud). Both carry the external-dns annotation, no cert-manager annotation.
  # Protected apps add a SecurityPolicy, see gateway-api-routes.md
  route:
    <app-name>:
      kind: HTTPRoute
      annotations:
        external-dns.kubernetes.io/enabled: "true"
      hostnames:
        - <app>.internal.grigri.cloud
      parentRefs:
        - name: internal
          namespace: envoy-gateway
          sectionName: https-internal-grigri-cloud
      rules:
        - backendRefs:
            - identifier: <app-name>
              port: <port>

  defaultPodOptions:
    securityContext:
      runAsUser: <uid>
      runAsGroup: <gid>
      fsGroup: <gid>
      fsGroupChangePolicy: "OnRootMismatch"
    enableServiceLinks: false
    # nodeSelector:
    #   kubernetes.io/hostname: <node>

  persistence:
    config:
      enabled: true
      globalMounts:
        - path: /config
      existingClaim: config-<app>

3.4 PVC Pattern

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app.kubernetes.io/instance: <app>
    app.kubernetes.io/name: <app>
    backup: <app>-zfs                   # For snapshot schedule selector
    backup/retain: weekly
  annotations:
    argocd.argoproj.io/sync-options: Prune=false   # NEVER auto-delete PVCs
  name: config-<app>
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

3.5 Snapshot Schedule Pattern

apiVersion: snapscheduler.backube/v1
kind: SnapshotSchedule
metadata:
  name: <app>-backups
spec:
  retention:
    maxCount: 20
  schedule: "0 1 * * *"               # Daily at 01:00 UTC
  claimSelector:
    matchLabels:
      backup: <app>-zfs                # Matches PVC label

Phase 4: Validation and Deployment

4.1 Pre-deployment Checklist

  • All image tags are pinned (no latest)
  • Renovate hints added above image repositories
  • PVCs have Prune=false annotation
  • PVCs have backup: and backup/retain: labels
  • HTTPRoute on the right Gateway/listener with the external-dns annotation (gateway-api-routes.md); no Ingress, no cert-manager.io/* annotation; SecurityPolicy if the app has no login of its own
  • ExternalSecrets reference correct Vault paths
  • OIDC redirect URLs match the app's callback path
  • Resource requests and limits are defined
  • Probes are configured (liveness, readiness, startup)

4.2 Validation Commands

# Build chart dependencies
helm dependency build apps/<app>/

# Template the chart (validate YAML syntax)
helm template --include-crds --namespace <app> <release-name> apps/<app>/

# Lint the chart (validate Helm best practices)
helm lint apps/<app>/

# Check for common issues
# - Missing image tags
# - Incorrect service references in ingress
# - Missing probe configurations

4.3 Deployment Steps

  1. Create Vault secrets (if needed)

    vault login
    vault kv put secret/<app>/jwt secret=<value> anon_key=<value>
    

  2. Update shared infrastructure (if needed)

  3. Add bucket/user to MinIO
  4. Add ExternalSecret entry for new credentials

  5. Create app files

  6. Chart.yaml
  7. values.yaml
  8. templates/ (postgresql, external-secrets, kanidm, pvc, snapshots)

  9. Validate

    helm dependency build apps/<app>/
    helm template --include-crds --namespace <app> <app> apps/<app>/
    helm lint apps/<app>/
    

  10. Commit and push

    git add apps/<app>/
    git commit -m "<app>: Add <app> deployment"
    git push
    

  11. Verify ArgoCD sync

    kubectl --context=grigri get application <app> -n argocd
    kubectl --context=grigri get pods -n <app>
    

  12. Test the application

  13. Access the ingress URL
  14. Verify OIDC login works
  15. Check logs for errors

Phase 5: Common Pitfalls

5.1 Database Issues

Zalando rejects hyphenated database names - Workaround: Create databases manually via kubectl exec psql - See: docs/troubleshooting/radarr-sqlite-to-postgres.md

Supabase apps need auth schema - Use Zalando for the database + init container for Supabase bootstrap - See: docs/deployment/readest.md

Custom Postgres extensions not in Spilo image - Use custom Spilo image (see immich) or container Postgres - See: apps/immich/templates/postgresql.yaml

5.2 OIDC Issues

Redirect URL mismatch - Check the app's documentation for the exact callback path - Common patterns: /oauth/callback, /auth/callback, /auth/login - kaniop strictRedirectUrl: true rejects mismatched URLs

OIDC client credentials not generated - kaniop creates <app>-kanidm-oauth2-credentials secret automatically - Wait for the secret to appear: kubectl get secret -n <app> <app>-kanidm-oauth2-credentials

5.3 Ingress and Route Issues

Path-based routing conflicts - HTTPRoute matching is segment-based and case-sensitive: Exact beats the longest PathPrefix (/api matches /api/x, not /apix); rule order does not matter - See: docs/deployment/readest.md for a multi-path example with rewrites, gateway-api-routes.md for routes

Large file uploads fail / long requests cut at 60 s - Envoy has no body limit and no total request limit; the gateway-wide idle timeout is 60 s - For a stream that stays silent longer than 60 s, set streamIdleTimeout in a route BackendTrafficPolicy (mergeType: StrategicMerge), never timeouts.request (gateway-api-routes.md, "Timeouts")

503 from the Envoy VIP only - Backend expects TLS (add a BackendTLSPolicy or Backend), or a NetworkPolicy does not admit the Envoy proxy pods. Look at response_flags (UF) in the Envoy proxy access log

5.4 MinIO Issues

Presigned URLs don't work / external downloads fail - The browser fetches presigned URLs directly, so S3_PUBLIC_ENDPOINT must be an internet-reachable host. The internal MinIO host (s3.internal.grigri.cloud) is on the internal Gateway only — external clients can't reach it. - For browser-facing storage use the public MinIO (apps/s3-public/): - In-cluster endpoint (S3_ENDPOINT): http://s3-public-minio.s3-public.svc:9000 - External endpoint (S3_PUBLIC_ENDPOINT): https://s3.grigri.cloud - For server-side-only storage the internal MinIO is fine: - In-cluster: http://minio.minio.svc:9000, external: https://s3.internal.grigri.cloud - See docs/deployment/s3-public.md and section 2.2.

Bucket creation fails - MinIO Helm chart creates buckets on startup - Check bucket name is lowercase, no special characters - Verify policy syntax (ARN format: arn:aws:s3:::<bucket>/*)

5.5 Image Tag Issues

Using latest tag - Always pin to a specific version - Add Renovate hint for automatic updates - Check GitHub releases for latest stable version

Renovate doesn't detect updates - Add # renovate: datasource=docker depName=<image> above repository: - For non-Docker Hub registries, add registryUrl=https://ghcr.io

Phase 6: Documentation

After deployment, document:

  1. Deployment guide in docs/deployment/<app>.md
  2. Architecture diagram
  3. Controllers and their purposes
  4. Database/storage configuration
  5. OIDC integration details
  6. Ingress routing
  7. Secrets required
  8. Deployment steps

  9. Troubleshooting in docs/troubleshooting/<app>-<issue>.md (if issues arise)

  10. Problem description
  11. Root cause
  12. Diagnosis commands
  13. Fix/workaround

  14. AGENTS.md — Add one-line pitfall if non-obvious behavior discovered

  15. Link to troubleshooting doc
  16. Example: "Readest needs Supabase auth schema — use Zalando + init container"

References

  • Helm conventions: docs/conventions/helm.md
  • Cilium networking: docs/conventions/cilium.md
  • Documenting learnings: docs/conventions/documenting-learnings.md
  • Example deployments: docs/deployment/hermes-agent.md, docs/deployment/unifi.md
  • Zalando Postgres patterns: apps/immich/templates/postgresql.yaml, apps/dawarich/templates/postgresql.yaml
  • MinIO patterns: platform/minio/values.yaml
  • OIDC patterns: apps/immich/templates/kanidm-oauth2-client.yaml