Automating the IBM MQ Upgrade on Redhat OpenShift Using BuildConfigs as CI/CD
This article explains the IBM MQ upgrade automatically using buildconfigs following that uses Image stream to trigger the new build for upgrade IBM MQ.
Join the DZone community and get the full member experience.
Join For FreeIn this article, I will walk you through the IBM MQ upgrade automatically using buildconfigs following that uses Image stream to trigger the new build for upgrade IBM MQ on OpenShift Container Platform 4.x cluster setup on Linux. Further, I will be creating ImageStream, Dockerfile, BuidConfig and triggering the build to upgrade IBM MQ on OCP.
Prerequisite
Verify that your OpenShift cluster is up and running.
- Check the compatibility of the new version of IBM MQ with your OpenShift environment, and verify the system requirements.
- Check if there is any known issue or limitation with the new version of IBM MQ by reviewing the IBM MQ documentation.
- Create a backup of the existing IBM MQ installation data and configuration.
Automating IBM MQ Upgrade on OCP
Create the image stream for IBM MQ with the latest or specific version by running the following image stream definition file.
ImageStream Definition YAML
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: ibm-mq-server
namespace: samp-mq-ns
spec:
lookupPolicy:
local: false
tags:
- from:
kind: DockerImage
name: ibmcom/mq
name: <latest-version>
annotations:
description: IBM MQ Server <latest-version>
iconClass: icon-ibm-mq
tags: mq,ibm,middleware
This YAML file creates an ImageStream object named "ibm-mq-server" with a single tag for version <latest-version> of the IBM MQ Server image. The from
field specifies the source Docker image for the tag and the annotations
field provides additional metadata for the tag.
To create the ImageStream object in your OpenShift project, save this YAML file to a file on your local system and then run the following command:
oc create -f mq-server-is.yaml
Image Build Definition on Docker File
This Dockerfile installs IBM MQ version <latest-version> on a UBI 8 base image. The rpm
command is used with the -Uvh
option to upgrade the existing IBM MQ installation to the new version.
You can modify this Dockerfile to use a different version of IBM MQ by changing the MQ_URL
argument to point to the URL of the installation package for the desired version and updating the MQ_PACKAGES
variable with the names of the RPM packages required for that version. Be sure also to update any other relevant parts of the Dockerfile, such as the exposed ports, entry point script, and user.
FROM registry.access.redhat.com/ubi8/ubi:latest
LABEL maintainer="Your Name <yourname@example.com>"
ARG MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev932_ubuntu_x86-64.tar.gz
ARG MQ_PACKAGES="MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesSDK-*.rpm MQSeriesSamples-*.rpm"
ENV LANG=en_US.UTF-8
# Install IBM MQ
RUN mkdir /tmp/mq \
&& cd /tmp/mq \
&& curl -LO $MQ_URL \
&& tar -zxvf ./*.tar.gz \
&& rm -f ./*.tar.gz \
&& cd MQServer \
&& ./mqlicense.sh -text_only -accept \
&& yum -y update \
&& yum -y install gskit \
&& rpm -Uvh --force-debian $MQ_PACKAGES \
&& /opt/mqm/bin/setmqinst -p /opt/mqm -i
# Create MQ data directory
RUN mkdir -p /var/mqm \
&& chown mqm:mqm /var/mqm \
&& chmod 770 /var/mqm
# Expose default MQ ports
EXPOSE 1414 9443
# Define the entrypoint script
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Set the default user
USER mqm
Definition of BuildConfig File
Below YAML file creates a BuildConfig object named "ibm-mq-server-upgrade" that builds an image for version <latest-version> of the IBM MQ Server using the ImageStream created in the previous example. The output
field specifies that the output should be saved to the ibm-mq-server:<latest-version>
tag in an ImageStream. The source
field specifies the input source for the build, which is an existing image in the ibm-mq-server
ImageStream. The strategy
field specifies the build strategy to use, which is the default Docker strategy using a base image from the ubi8
ImageStream. The triggers
field specifies that the build should be triggered by an ImageChange event.
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: ibm-mq-server-upgrade
namespace: samp-mq-ns
spec:
output:
to:
kind: ImageStreamTag
name: ibm-mq-server:<latest-version>
source:
git:
uri: <git-repo-url>
ref: <git-repo-ref>
contextDir: <dockerfile-directory>
type: Dockerfile
strategy:
dockerStrategy:
dockerfilePath: <dockerfile-path>
from:
kind: ImageStreamTag
name: ubi8:latest
triggers:
- type: ImageChange
imageChange: {}
To create the BuildConfig object in your OpenShift project, save this YAML file to a file on your local system and then run the following command:
oc create -f ibm-mq-server-upgrade.yaml
Start the build process by running the following command:
oc start-build ibm-mq-server-upgrade --from-dir=<directory-containing-dockerfile>
Replace <directory-containing-dockerfile>
with the path to the directory containing the Dockerfile on your local system.
This will start a new build process for the upgraded version of IBM MQ. Once the build is complete, the new image will be pushed to the specified ImageStream tag, and you can deploy the updated IBM MQ image to your OpenShift environment.
Summary
Automating the upgrade of IBM MQ on Red Hat OpenShift using buildconfig with imagestream, the existing imagestream for IBM MQ is used to create a new buildconfig that specifies the updated Dockerfile. The buildconfig is then run to create a new image, which is tagged with the latest version of IBM MQ. Finally, the image is deployed using a new deployment configuration, and any dependent applications are updated as necessary.
Opinions expressed by DZone contributors are their own.
Comments