Utkarsh Jain
12/26/2025, 7:03 AMERROR - prefect.Run dbt | RunImage got error when reading pod log: , I am trying to trobleshoot if this is actually related to the kubernetes node somehow or the some misconfig in prefect flowsMarvin
12/26/2025, 7:03 AMMarvin
12/26/2025, 7:09 AMkubectl auth can-i get pods/log --as=system:serviceaccount:<namespace>:<service-account> -n <job-namespace>
kubectl auth can-i get pods --as=system:serviceaccount:<namespace>:<service-account> -n <job-namespace>
- If needed, grant:
apiVersion: <http://rbac.authorization.k8s.io/v1|rbac.authorization.k8s.io/v1>
kind: ClusterRole
metadata:
name: prefect-worker
rules:
- apiGroups: [""]
resources: ["pods","pods/log"]
verbs: ["get","list","watch"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["create","get","list","watch","delete","patch"]
---
apiVersion: <http://rbac.authorization.k8s.io/v1|rbac.authorization.k8s.io/v1>
kind: ClusterRoleBinding
metadata:
name: prefect-worker
roleRef:
apiGroup: <http://rbac.authorization.k8s.io|rbac.authorization.k8s.io>
kind: ClusterRole
name: prefect-worker
subjects:
- kind: ServiceAccount
name: <service-account>
namespace: <namespace>
- API watch/log stream timeouts
- The worker streams logs via the K8s API; if the stream goes idle or logs expire, you’ll see this error.
- Increase watch timeouts in your Kubernetes work pool’s base job template:
{
"job_configuration": {
"stream_output": true,
"pod_watch_timeout_seconds": 120,
"job_watch_timeout_seconds": 300
}
}
- Apply via UI (edit the work pool’s job template) or CLI by saving JSON and running:
prefect work-pool update <your-pool> --base-job-template ./template.json
- Container ended before logs were read (very short runs, restarts, or pod deletion)
- Check the pod and container state:
kubectl get pods -n <ns> -l <http://prefect.io/flow-run-id=<flow-run-id|prefect.io/flow-run-id=<flow-run-id>>
kubectl describe pod <pod> -n <ns>
kubectl logs <pod> -n <ns> --previous
- If you see OOMKilled/Evicted, address resources; otherwise the logging error is often benign.
- Node/resource pressure or networking drops
- Look for node pressure and evictions:
kubectl top nodes
kubectl top pods -A
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
- Ensure your worker can keep a stable connection to the API server (long-lived connections). Prefect’s K8s worker enables TCP keepalive by default.
Turn on more diagnostics
- Raise Prefect’s logging to see the underlying K8s client error/code:
# Worker environment
PREFECT_LOGGING_LEVEL=DEBUG
PREFECT_LOGGING_LOGGERS_PREFECT_KUBERNETES_LEVEL=DEBUG
- Then review the worker logs around the error for clues like 401/403 (RBAC), 410 (expired watch), or connection timeouts.
What I’d like from you to pinpoint it
- Prefect version and prefect-kubernetes version
- Work pool type (Kubernetes?) and the job namespace/service account used
- Whether runs succeed but logs cut off, or the entire run fails
- A kubectl describe pod and kubectl logs (or --previous if it restarted) from an affected run
- Any 401/403/410 codes in the worker logs after enabling DEBUG as above
If helpful, I can review your work pool’s base job template to make sure timeouts and stream_output are set correctly.
ReferencesMarvin
12/26/2025, 7:09 AM--base-job-template). There aren’t per-flag CLI options for the Kubernetes timeouts; they live in the job configuration.Utkarsh Jain
12/26/2025, 7:09 AM