puppetdb: unique per-pod command-queue directory #340
Reference in New Issue
Block a user
Delete Branch "benvin/puppetdb-per-pod-queue"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
PuppetDB runs as a Deployment (HPA
minReplicas: 2,maxReplicas: 5) with its vardir/opt/puppetlabs/server/data/puppetdbbacked by a single ReadWriteMany cephfs PVC (puppetserver-puppetdb-claim). Every replica mounts the same path, so all pods share onestockpile/command queue. PuppetDB's stockpile holds unprocessed commands and is not safe for concurrent writers from multiple processes — shared, the pods corrupt each other's queue/stockpile.Change
POD_NAMEvia the downward API (fieldRef: metadata.name) to the puppetdb container and thecreate-log-dirinit container.puppetdb-storagewithsubPathExpr: $(POD_NAME)on both, so each pod gets its own vardir subtree (<pvc>/<pod-name>/) — hence its ownstockpile/command queue — while still living on the shared, persistent RWX volume.Approach
Chose subPathExpr with pod name over converting to a StatefulSet: it is the minimal correct fix for a Deployment on a shared RWX PVC, keeps the existing HPA (which targets a Deployment) intact, and keeps the queue persistent per pod (not an emptyDir), so unprocessed commands survive restarts. PuppetDB's
vardirdefault is unchanged (/opt/puppetlabs/server/data/puppetdb); the container still sees the mount at that path, so the app config and the k8s mount agree with no configmap change. The stockpile resolves to<vardir>/stockpile, now per-pod.Current replica count: HPA min 2 / max 5 (actively multi-pod, so the corruption is live, not just a future scaling risk).
Note: at rollout, pods move from the shared root of the PVC to per-pod subdirs; any commands sitting in the old shared
stockpile/are orphaned once. This is a one-time cutover — the authoritative data is in Postgres and agents resubmit on their next run.https://claude.ai/code/session_01JUoARVdmhxKQHyyyp1pxeT