+

Search Tips | Advanced Search

Building an image with custom MQSC and INI files, using the OpenShift CLI

Use an Red Hat OpenShift Container Platform Pipeline to create a new IBM MQ container image, with MQSC and INI files we want to be applied to queue managers using this image. This task should be completed by a project administrator


Before starting

We need to install the Red Hat OpenShift Container Platform command-line interface.

Log into the cluster using cloudctl login (for IBM Cloud Pak for Integration), or oc login.

If you don't have an OpenShift Secret for the IBM Entitled Registry in your Red Hat OpenShift project, then follow the steps for Preparing the OpenShift project for IBM MQ using the OpenShift CLI.


Procedure

  1. Create an ImageStream An 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 we are using the specific image we need even if the image in the repository changes.
    oc create imagestream mymq
  2. Create a BuildConfig for the new image A BuildConfig will allow builds for the new image, which will be based off the IBM official images, but will add any MQSC or INI files we want to be run on container start-up.
    1. Create a YAML file defining the BuildConfig resource For example, create a file called "mq-build-config.yaml" with the following contents:
      apiVersion: build.openshift.io/v1
      kind: BuildConfig
      metadata:
        name: mymq
      spec:
        source:
          dockerfile: |-
            FROM cp.icr.io/cp/ibm-mqadvanced-server-integration:9.2.0.0-r1-amd64
            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:9.2.0.0-r1-amd64"
            pullSecret:
              name: ibm-entitlement-key
        output:
          to:
            kind: ImageStreamTag
            name: 'mymq:latest-amd64'
      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 we want to use. As fixes are applied, we will need to repeat these steps to re-build your image.

      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 REPLACE parameter on any DEFINE commands, and adding the IGNSTATE(YES) parameter to any START or STOP commands.

    2. Apply the BuildConfig to the server.
      oc apply -f mq-build-config.yaml

  3. Run a build to create your image
    1. Start the build
      oc start-build mymq
      We should see output similar to the following:
      build.build.openshift.io/mymq-1 started
    2. Check the status of the build For example, we can run the following command, using the build identifier returned in the previous step:
      oc describe build mymq-1

  4. Deploy a queue manager, using your new image Follow the steps described in Deploying a queue manager using the OpenShift CLI, adding your new custom image into the YAML. You could add the following snippet of YAML into your normal QueueManager YAML, where my-namespace is the OpenShift project/namespace we 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
    

Parent topic: Deploying IBM MQ certified containers using the IBM MQ Operator


Related tasks

Last updated: 2020-10-04