Building an image with custom MQSC and INI files, using the Red Hat OpenShift CLI
Use an Red Hat® OpenShift® Container Platform Pipeline to create a new IBM® MQ container image, with MQSC and INI files you want to be applied to queue managers using this image. This task should be completed by a project administrator
Before you begin
You need to install the Red Hat OpenShift Container Platform command-line interface.
Log into your cluster using cloudctl login (for IBM Cloud Pak® for Integration), or oc login.
If you don't have a Red Hat OpenShift Secret for the IBM Entitled Registry in your Red Hat OpenShift project, then follow the steps for Create the entitlement key secret.
ImageStreamAn image stream and its associated tags provide an abstraction for referencing container images from within Red Hat OpenShift Container Platform. The image stream and its tags allow you to see what images are available and ensure that you are using the specific image you need even if the image in the repository changes.
oc create imagestream mymq
BuildConfigfor your new imageA
BuildConfigwill allow builds for your new image, which will be based off the IBM official images, but will add any MQSC or INI files you want to be run on container start-up.
Create a YAML file defining the
BuildConfigresourceFor example, create a file called "mq-build-config.yaml" with the following contents:
You will need to replace the two places where the base IBM MQ is mentioned, to point at the correct base image for the version and fix you want to use (see Release history for IBM MQ Operator for details). As fixes are applied, you will need to repeat these steps to re-build your image.
apiVersion: build.openshift.io/v1 kind: BuildConfig metadata: name: mymq spec: source: dockerfile: |- FROM cp.icr.io/cp/ibm-mqadvanced-server-integration:18.104.22.168-r1 RUN printf "DEFINE QLOCAL(foo) REPLACE\n" > /etc/mqm/my.mqsc \ && printf "Channels:\n\tMQIBindType=FASTPATH\n" > /etc/mqm/my.ini LABEL summary "My custom MQ image" strategy: type: Docker dockerStrategy: from: kind: "DockerImage" name: "cp.icr.io/cp/ibm-mqadvanced-server-integration:22.214.171.124-r1" pullSecret: name: ibm-entitlement-key output: to: kind: ImageStreamTag name: 'mymq:latest-amd64'
This example creates a new image based on the IBM official image, and adds files called "my.mqsc" and "my.ini" into the /etc/mqm directory. Any MQSC or INI files found in this directory will be applied by the container at start-up. INI files are applied using the crtmqm -ii option, and merged with the existing INI files. MQSC files are applied in alphabetical order.
It is important that your MQSC commands are repeatable, as they will be run every time the queue manager starts up. This typically means adding the
REPLACEparameter on any
DEFINEcommands, and adding the
IGNSTATE(YES)parameter to any
BuildConfigto the server.
oc apply -f mq-build-config.yaml
- Create a YAML file defining the
Run a build to create your image
Start the build
oc start-build mymqYou should see output similar to the following:
Check the status of the build
For example, you can run the following command, using the build identifier returned in the previous step:
oc describe build mymq-1
- Start the build
Deploy a queue manager, using your new image
Follow the steps described in Deploying a queue manager onto a Red Hat OpenShift Container Platform cluster, adding your new custom image into the YAML.You could add the following snippet of YAML into your normal
QueueManagerYAML, where my-namespace is the Red Hat OpenShift project/namespace you are using, and image is the name of the image you created earlier (for example, "mymq:latest-amd64"):
spec: queueManager: image: image-registry.openshift-image-registry.svc:5000/my-namespace/my-image