Running the IBM MQ container with a read-only root file system
You can configure the IBM® MQ container to run with a read-only root file system. This prevents attackers from copying and running malicious code in the container.
About this task
Enabling the read-only root file system makes the container files immutable. That is, on the container file system, files can be viewed but not modified and no new files can be created. Files can only be modified or created on a mounted file system.
ScratchandTmpvolumes-
Data to be written or modified is divided into two ephemeral volumes:
ScratchandTmp. These volumes are created and mounted into the /run and /tmp directories respectively, in the queue manager container.- The
Scratchvolume contains the files, keystores, and other files that are used for configuring the queue manager. - The
Tmpvolume contains diagnostic files, for example the queue manager RAS files.
When a read-only root file system is enabled and the enabled property of the
ScratchorTmpvolume is set totrue(the default value), an ephemeral volume of typeemptyDiris created and mounted to the queue manager container for the respective ephemeral data.
You can disable the ScratchandTmpvolumes. When you set the enabled property of theScratchorTmpvolume tofalse, a sub-directory of the queue manager data volume (/scratchor/tmp) is mounted to the queue manager container for the respective ephemeral data. If the queue manager data volume is of typepersistent-claim, the queue manager data volume is a Persistent Volume Claim. If the type is set toephemeral, the volume is anemptyDirvolume.When an
emptyDirephemeral volume is created and used forScratch,Tmp, or the queue manager data, any files on this volume are lost on pod restart. If the size of the data in any of these volumes exceeds the value specified for the volume's sizeLimit property, Kubernetes can eject the container and create a new one. The sizeLimit property applies only toemptyDirephemeral volumes.
When ScratchorTmpdata is stored on the queue manager data volume (when the enabled property is set tofalse), and the data volume is a Persistent Volume Claim, this data is by default considered ephemeral because the queue manager container erases this data on startup. You can disable the deletion ofTmpdata by setting theMQ_ENABLE_CLEAN_TMP_ON_STARTenvironment variable tofalse. For information about setting queue manager environment variables, see Example: Supplying additional environment variables for a queue manager. - The
- Considerations for choosing a backing volume
-
Data for an
emptyDirvolume is stored on the backing medium of the node the associated pod is running on. Although the aforementioned sizeLimit property can limit the use of this storage, theemptyDirvolume might run out of capacity before this limit is reached, if the backing medium is filled from another source.
If the size of the backing medium for the node is insufficient, you might want to
store ScratchandTmpdata on the queue manager data volume.
Storing ScratchandTmpdata on the queue manager data volume has other consequences. This storage might be accessed over the network, which means access toScratchandTmpdata is slower. The default size of this volume is2Gi. The default sizeLimit forScratchandTmpvolumes are100Mand2Girespectively, so you should increase the size of the data volume when storing this additional data. If the size of the volume is not large enough,ScratchandTmpdata might consume the volume, preventing the queue manager from functioning normally. SettingMQ_ENABLE_CLEAN_TMP_ON_STARTtofalsemight also lead to this problem, if the data in/tmpis added to over time.
Procedure
A read-only root file system is not enabled by default. To enable it, complete one of the following procedures: