[OpenShift Container Platform][IBM Cloud Pak for Integration]

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.

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 you are using the specific image you need even if the image in the repository changes.
    oc create imagestream mymq
  2. Create a BuildConfig for your new image
    A BuildConfig will 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.
    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.3.4.1-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:9.3.4.1-r1"
            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 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.

      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
      You should see output similar to the following:
      build.build.openshift.io/mymq-1 started
    2. 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
  4. 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 QueueManager YAML, 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