Kubernetes makes it easy to schedule a pod anywhere in the cluster—but IBM MQ queue managers are stateful: they remember messages, channel sequence numbers, and object definitions on disk. If that disk is only the container ephemeral layer, a node drain or pod restart wipes your estate. Persistent volumes solve this by binding durable block or file storage to the path where MQ keeps its queue manager data, typically /mnt/mqm in official images. Beginners confuse PersistentVolume (PV), PersistentVolumeClaim (PVC), and StorageClass; operators confuse RWO with RWX and accidentally attach two writers. This tutorial walks through how Kubernetes storage plugs into MQ, sizing and performance classes, reclaim policies that prevent Friday-afternoon disasters, backup and snapshot strategies, expanding volumes, permissions for the mq user, how Native HA changes the storage story, and anti-patterns that destroy repositories.
A StorageClass is a template—fast SSD on AWS gp3, slower magnetic, encrypted by default. A PVC is your application request: give QM1 two hundred gibibytes from class fast-ssd with ReadWriteOnce. Kubernetes binds the PVC to a PV provisioned dynamically or to a pre-created static PV. The pod volumeMount points mountPath /mnt/mqm at that claim. When the pod dies, the PVC remains; the replacement pod reattaches the same data. Changing storage class on a live PVC is usually impossible—you plan class per environment upfront.
| Object | Role | MQ relevance |
|---|---|---|
| StorageClass | Defines provisioner and parameters | Chooses SSD vs HDD, IOPS, encryption |
| PVC | Pod storage request | Size and access mode for /mnt/mqm |
| PV | Actual volume backing claim | Survives pod lifecycle |
ReadWriteOnce means one node can mount read-write at a time—correct for a single queue manager pod. ReadWriteMany allows multiple nodes to mount simultaneously—useful for log sidecars or shared config, not for two queue managers on identical /mnt/mqm. ReadOnlyMany suits distributing trust stores. Picking RWX because it sounds more available and then running two MQ pods against one claim is a data-corruption incident. Native HA and replicated MQ patterns use IBM-supported replication rather than shared filesystem tricks unless documentation explicitly allows them.
The official MQ container expects queue manager files under /mnt/mqm. Your StatefulSet or Deployment volumeMount must align exactly. subPath is rarely used for the whole QM—usually the entire claim mounts at /mnt/mqm. fsGroup or securityContext ensures the container mq user can write; without it pods crash looping with permission errors. Init containers that chown host paths are a smell—fix storage class or fsGroup instead when possible.
1234567891011121314151617181920apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mq-qm1-data spec: accessModes: - ReadWriteOnce storageClassName: fast-ssd resources: requests: storage: 100Gi --- # In pod spec: volumeMounts: - name: qmdata mountPath: /mnt/mqm volumes: - name: qmdata persistentVolumeClaim: claimName: mq-qm1-data
Calculate storage from maximum retained messages times average message size, plus log files, plus FDC and trace if you leave them on the same volume. High-throughput workloads need storage classes with sufficient IOPS and low latency—placing MQ on the cheapest HDD class saves money until syncpoint latency spikes under load. Separate volumes for logs versus data are advanced but help blast-radius when logs fill disk. Monitor kubelet volume stats and MQ queue depth metrics together. allowVolumeExpansion: true on StorageClass lets you grow PVC without remounting a new claim—verify file system resize steps for your cloud.
Reclaim policy Delete removes the cloud disk when PVC is deleted—dangerous in production if a typo in kubectl deletes the claim. Retain keeps the PV object and underlying disk for manual recovery. Production MQ StorageClasses should default to Retain or use RBAC so only break-glass roles delete PVCs. Document runbooks: how to reattach a retained PV to a new PVC after disaster.
The pod is an employee at a hot desk. The persistent volume is a locked drawer that stays in the building when the employee moves desks. MQ writes its memory into the drawer; the next employee opening that desk continues the same story.
IBM MQ Native HA in containers uses multiple pods and replicated storage patterns documented for your release—not a single RWO PVC shared by active-active writers. Read IBM Native HA container guides before sizing three PVCs versus one. Traditional multi-instance queue managers on Linux VMs used shared disk with careful locking; Kubernetes abstractions differ—do not port old MP patterns blindly.
Each queue manager needs its own PVC. Naming claims qm-prod-finance-data versus generic mq-data prevents wrong attachment during Helm upgrades. Labels tying PVC to QMNAME help audits. Namespace per environment (mq-dev, mq-prod) adds isolation.
A persistent volume is a backpack MQ keeps its toys in. When the pod goes home for the night, the backpack stays in the classroom locker so tomorrow's pod can pick up the same toys.
Create a PVC, deploy MQ with /mnt/mqm mount, fill a queue, delete the pod, confirm messages after reschedule.
Document your StorageClass IOPS and whether expansion is enabled.
Run a tabletop: operator deletes PVC by mistake—what does Retain policy save?
1. MQ data in containers lives under:
2. Two pods mounting same QM data RWO:
3. PVC stands for:
4. Retain reclaim policy: