Skip to content

Tusd config history


title: tusd configuration history description: Why the production tusd Deployment looks the way it does: the read-only /tmp fix, the single-replica decision and routing. audience: internal type: explanation owner: platform-team last_reviewed: 2026-11-19


Overview

tusd handles resumable file uploads (via the tus protocol) for playout content, storing final files in SeaweedFS (S3-compatible) and notifying coreapi via a webhook once an upload completes.

Setting Value
Namespace production
Image tusproject/tusd:v2.4.0 (pinned exact version, not a floating tag)
Replicas 1
Storage backend SeaweedFS S3 (seaweedfs-s3.seaweedfs.svc.cluster.local:8333, bucket playtelly)
Base path /playout/files/
Hook endpoint coreapi-service.production.svc.cluster.local:3000/hooks/tusd (fires on post-finish)

Fixed bug: read-only file system on every upload chunk

Symptom

Every PATCH request (the actual file-data upload step, after the initial POST creates the upload) failed with:

level=ERROR event=InternalServerError ... message="open /tmp/tusd-s3-tmp-XXXXXXX: read-only file system"
UploadCreated (the POST) always succeeded — only the actual data-writing step (PATCH) failed, every single time, on every upload attempt.

Root cause

tusd's S3 storage backend has a documented requirement: it temporarily buffers each uploaded chunk to local disk (/tmp) before pushing it to S3, as part of how it implements S3 multipart uploads. This is expected, necessary behavior — not a bug in tusd itself.

The Deployment's securityContext includes readOnlyRootFilesystem: true (a genuine, intentional security hardening measure, kept as-is). This blocks writes anywhere on the container's filesystem, including /tmp — directly conflicting with tusd's actual runtime requirement.

Fix

Mount a dedicated, writable emptyDir volume specifically at /tmp, leaving the rest of the filesystem read-only:

      containers:
        - name: tusd
          volumeMounts:
            - name: tmp
              mountPath: /tmp
          securityContext:
            readOnlyRootFilesystem: true   # unchanged — still fully read-only elsewhere
            # ...rest of securityContext unchanged...
      volumes:
        - name: tmp
          emptyDir: {}

emptyDir volumes are explicitly exempt from the readOnlyRootFilesystem restriction — this is the standard, documented Kubernetes pattern for giving a hardened container scratch space without weakening its overall security posture.

Confirmation the fix worked

Post-fix, logs show the full successful sequence:

ChunkWriteStart ... maxSize=... offset=0
ChunkWriteComplete ... bytesWritten=<real-size>      <- previously always 0
UploadFinished ... size=<total-size>
HookInvocationStart type=post-finish
HookInvocationFinish type=post-finish


Decision: single replica, not multiple

Why multiple replicas were considered, and rejected

tusd's S3 backend design means upload data and metadata are stored in S3 itself (a .info object plus an S3 multipart upload per upload) — not on the pod's local disk. This makes multi-pod setups theoretically possible, since any pod reading from the same S3 bucket can see any upload's state.

However, tusd's own official documentation (tus.io) explicitly warns: "If you are running more than a single tus instance, a special routing mechanism may be required." The actual risk: tusd's upload-locking mechanism (preventing two simultaneous requests from corrupting the same upload) defaults to in-memory, per-pod locking — two separate pods have no way to coordinate with each other. If a client's requests for the same upload land on two different pods (e.g. due to a retry or load-balancer behavior), there's a real risk of a race condition corrupting that upload.

The safe way to run multiple replicas would require consistent-hash routing at the APISIX layer (keying on the upload ID in the URL path) to guarantee all requests for one upload always reach the same pod — adding real configuration complexity and a new class of potential misconfiguration risk.

Decision

Given this is a private, internal upload service (not public-facing, not expected to need to scale beyond one pod's capacity), the added complexity and risk of a subtle multi-pod locking bug was judged not worth it. Single replica (replicas: 1) was chosen instead.

What was removed as a consequence

Since these two resources only make sense for a multi-replica setup, both were deleted:

  • PodDisruptionBudget (minAvailable: 1) — with only one pod total, this rule can never be satisfied while also allowing that pod to be evicted, meaning it would actively block legitimate node drains/maintenance rather than provide any real protection.
  • HorizontalPodAutoscaler (minReplicas: 2) — directly conflicted with replicas: 1 on the Deployment; if left in place, the HPA would have fought the Deployment's spec and silently forced it back to 2 replicas.
  • The podAntiAffinity block (previously used to spread replicas across different nodes) was also removed from the Deployment itself, since it has no purpose with only one pod.

What was kept

The rollingUpdate strategy (maxUnavailable: 0, maxSurge: 1) was kept even with a single replica — it still provides a real benefit: during a deploy, Kubernetes starts the new pod and waits for it to be healthy before terminating the old one, avoiding any gap in availability during the brief rollout window (running 2 pods only transiently during that transition, not as a steady state).

When to revisit this decision

If kubectl top pods -n production shows tusd genuinely hitting its CPU/memory limits under real load, or if brief downtime during a pod restart becomes unacceptable — that's the point to revisit multi-replica, with proper consistent-hash routing configured from the start, not before.


Final Deployment (reference)

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: tusd
    environment: production
  name: tusd
  namespace: production
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: tusd
  template:
    metadata:
      labels:
        app: tusd
        environment: production
    spec:
      terminationGracePeriodSeconds: 60
      containers:
        - name: tusd
          image: tusproject/tusd:v2.4.0
          imagePullPolicy: IfNotPresent
          args:
            - -s3-bucket
            - playtelly
            - -s3-endpoint
            - http://seaweedfs-s3.seaweedfs.svc.cluster.local:8333
            - -base-path=/playout/files/
            - -behind-proxy
            - -hooks-http=http://coreapi-service.production.svc.cluster.local:3000/hooks/tusd
            - -hooks-enabled-events=post-finish
            - -cors-allow-origin=.*
            - -cors-allow-methods=POST,GET,HEAD,PATCH,DELETE,OPTIONS
            - -cors-allow-headers=*
            - -cors-expose-headers=*
          envFrom:
            - configMapRef:
                name: tusd-config
            - secretRef:
                name: tusd-s3-credentials
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          volumeMounts:
            - name: tmp
              mountPath: /tmp
          securityContext:
            runAsNonRoot: true
            runAsUser: 1000
            runAsGroup: 1000
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          livenessProbe:
            httpGet:
              path: /metrics
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 5
          readinessProbe:
            httpGet:
              path: /metrics
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 5
          resources:
            limits:
              cpu: "1"
              memory: 1Gi
            requests:
              cpu: 200m
              memory: 256Mi
      volumes:
        - name: tmp
          emptyDir: {}

Routing — how requests actually reach tusd

Confirmed architecture (via playtelly.castis.io, using the Kubernetes Gateway API HTTPRoute rather than the classic ApisixRoute CRD):

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: tellyboard-route
  namespace: production
spec:
  parentRefs:
    - name: apisix-gateway
      namespace: apisix
  hostnames:
    - playtelly.castis.io
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /tellyboard
      backendRefs:
        - name: tellyboard-service
          port: 80
    - matches:
        - path:
            type: PathPrefix
            value: /playout
      backendRefs:
        - name: tellyboard-service
          port: 80

Both /tellyboard and /playout route to the same backend (tellyboard-service), which internally proxies /playout/files/ to the actual tusd Service via its own nginx config (proxy_pass ${TUSD_URL}).


Troubleshooting reference

Symptom Cause Fix
PATCH fails with open /tmp/tusd-s3-tmp-...: read-only file system readOnlyRootFilesystem: true without a writable /tmp volume Confirm the emptyDir volume + volumeMount at /tmp is present (see above)
Upload POST succeeds (201), but the generated url= shows http:// instead of https:// Missing/incorrect X-Forwarded-Proto handling somewhere upstream of tusd Confirm -behind-proxy flag is present, and that whatever proxies to tusd (nginx, APISIX route) sets X-Forwarded-Proto: https correctly
POST /playout/files/ returns 405 Method Not Allowed Request never reaches tusd at all — likely caught by a frontend's default SPA/static-file handler before reaching the proxy rule Confirm the specific location /playout/files/ (or equivalent) proxy rule exists and is matched before any catch-all/SPA fallback rule
Upload data never lands / ERR_INCOMPLETE_UPLOAD on later GET Client never sent the follow-up PATCH requests after the initial POST (frontend/tus-client issue, not a server misconfiguration) Check the browser's Network tab for actual PATCH requests during upload; confirm the tus client library is correctly configured
Considering 2+ replicas for HA Real risk of upload corruption from uncoordinated in-memory locks across pods Do not scale beyond 1 replica without also configuring consistent-hash routing in APISIX first