Persistent Volumes

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.

PV, PVC, and StorageClass in Plain Terms

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.

Kubernetes storage objects
ObjectRoleMQ relevance
StorageClassDefines provisioner and parametersChooses SSD vs HDD, IOPS, encryption
PVCPod storage requestSize and access mode for /mnt/mqm
PVActual volume backing claimSurvives pod lifecycle

Access Modes: RWO Versus RWX

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.

Mounting /mnt/mqm Correctly

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.

yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
apiVersion: 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

Sizing and Performance

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 Policies and Operational Safety

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.

Explainer: Notebook That Stays When the Desk Moves

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.

Backups, Snapshots, and Restore

  1. Quiesce or stop MQ per IBM guidance before application-consistent snapshot if required.
  2. Use volume snapshots for fast point-in-time; test restore quarterly.
  3. Export object definitions with dumpmqcfg or GitOps separately—disk snapshot without config export still needs matching channel secrets.
  4. Cross-region DR may replicate snapshots or use MQ Native HA cross-region features instead of manual file copy.

Native HA and Storage

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.

Multi-Queue Manager Clusters

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.

Troubleshooting Volume Issues

  • Pod Pending — PVC unbound: no StorageClass, quota exceeded, or wrong zone.
  • CrashLoop permission denied — fsGroup or SELinux on host path.
  • Disk full — expand PVC or purge logs; MQ may reject PUTs.
  • Wrong queue manager after restart — new empty PVC mounted; verify claimName in StatefulSet volumeClaimTemplates.

Explain Like I'm Five: Persistent Volumes

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.

Practice Exercises

Exercise 1

Create a PVC, deploy MQ with /mnt/mqm mount, fill a queue, delete the pod, confirm messages after reschedule.

Exercise 2

Document your StorageClass IOPS and whether expansion is enabled.

Exercise 3

Run a tabletop: operator deletes PVC by mistake—what does Retain policy save?

Frequently Asked Questions

Frequently Asked Questions

Test Your Knowledge

Test Your Knowledge

1. MQ data in containers lives under:

  • /mnt/mqm
  • /var/log only
  • /etc/passwd
  • /root

2. Two pods mounting same QM data RWO:

  • Corruption risk
  • Automatic HA
  • Doubles throughput
  • Required always

3. PVC stands for:

  • PersistentVolumeClaim
  • Portable Volume Copy
  • Public VLAN Channel
  • Process Verify Control

4. Retain reclaim policy:

  • Keeps PV after PVC delete
  • Deletes instantly
  • Disables TLS
  • Starts channels
Published
Read time20 min
AuthorMainframeMaster
Verified: IBM MQ 9.4 Kubernetes documentation