This example deploys a simple "quick start" queue manager that uses ephemeral
(non-persistent) storage and turns off IBM MQ security. Messages are not persisted across restarts
of the queue manager. You can adjust the configuration to change many queue manager
settings.
Before you begin
To complete this example, you must first have completed the following prerequisites:
About this task
This example provides Service, ServiceAccount, and
StatefulSet YAML to define a queue manager to be deployed into Kubernetes.
Procedure
-
Create a Service to provide a consistent IP address for IBM MQ traffic.
Ensure you are in the namespace you created earlier (see Before you begin), then apply the following YAML using the Kubernetes command line or console.
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: integration
app.kubernetes.io/instance: quickstart
app.kubernetes.io/name: ibm-mq
app.kubernetes.io/version: 10.0.0.0
name: quickstart-ibm-mq
spec:
ports:
- name: qmgr
port: 1414
protocol: TCP
targetPort: 1414
- name: metrics
port: 9157
protocol: TCP
targetPort: 9157
selector:
app.kubernetes.io/component: integration
app.kubernetes.io/instance: quickstart
app.kubernetes.io/name: ibm-mq
type: ClusterIP
-
Create a ServiceAccount to use for the queue manager.
The example ServiceAccount below refers to an imagePullSecret
that is used for an entitlement check when the image is pulled. See Preparing to use Kubernetes by creating a pull secret for more information.
kind: ServiceAccount
apiVersion: v1
metadata:
name: quickstart-ibm-mq
labels:
app.kubernetes.io/component: integration
app.kubernetes.io/instance: quickstart
app.kubernetes.io/name: ibm-mq
app.kubernetes.io/version: 10.0.0.0
imagePullSecrets:
- name: ibm-entitlement-key
-
Create the queue manager Pod, managed by a StatefulSet.
In the following YAML, the namespace name is assumed to be
mq-test. Change it to match the name that you are using in your Kubernetes environment for this example.
This YAML creates a single instance queue manager in your Kubernetes environment in the namespace specified. No persistence
volume is created for this instance because our example is for ephemeral storage.
Note: This example uses
IBM MQ Advanced annotations. To use an
IBM MQ license, edit the annotations under
spec.template.metadata to the values that are specified under
IBM MQ or
IBM MQ for Non-Production Environment in
IBM MQ container license annotations.
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: quickstart-ibm-mq
namespace: mq-test
labels:
app.kubernetes.io/component: integration
app.kubernetes.io/instance: quickstart
app.kubernetes.io/name: ibm-mq
app.kubernetes.io/version: 10.0.0.0
spec:
persistentVolumeClaimRetentionPolicy:
whenDeleted: Retain
whenScaled: Retain
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/component: integration
app.kubernetes.io/instance: quickstart
app.kubernetes.io/name: ibm-mq
template:
metadata:
labels:
app.kubernetes.io/component: integration
app.kubernetes.io/instance: quickstart
app.kubernetes.io/name: ibm-mq
app.kubernetes.io/version: 10.0.0.0
statefulSetName: quickstart-ibm-mq
annotations:
# These annotations are critical for the IBM License Service to charge you correctly
productChargedContainers: qmgr
productID: 208423bb063c43288328b1d788745b0c
productMetric: PROCESSOR_VALUE_UNIT
productName: IBM MQ Advanced
productVersion: 10.0.0.0
spec:
restartPolicy: Always
serviceAccountName: quickstart-ibm-mq
terminationGracePeriodSeconds: 30
securityContext: {}
containers:
- resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: '1'
memory: 1Gi
readinessProbe:
exec:
command:
- chkmqready
initialDelaySeconds: 10
timeoutSeconds: 3
periodSeconds: 5
successThreshold: 1
failureThreshold: 1
terminationMessagePath: /run/termination-log
name: qmgr
livenessProbe:
exec:
command:
- chkmqhealthy
initialDelaySeconds: 90
timeoutSeconds: 5
periodSeconds: 10
successThreshold: 1
failureThreshold: 1
env:
- name: LICENSE
# if you accept the license, change the following value to "accept"
value: view
- name: MQ_QMGR_NAME
value: QUICKSTART
- name: MQ_MULTI_INSTANCE
value: 'false'
- name: MQ_ENABLE_METRICS
value: 'true'
- name: MQ_ENABLE_EMBEDDED_WEB_SERVER
value: 'false'
- name: MQ_LOGGING_CONSOLE_FORMAT
value: basic
- name: DEBUG
value: 'false'
- name: MQ_ENABLE_TRACE_STRMQM
value: 'false'
- name: MQ_EPHEMERAL_PREFIX
value: /run/mqm
- name: MQ_GRACE_PERIOD
value: '29'
- name: MQ_NATIVE_HA
value: 'false'
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
runAsNonRoot: true
readOnlyRootFilesystem: false
ports:
- containerPort: 1414
protocol: TCP
- containerPort: 9157
protocol: TCP
terminationMessagePolicy: File
# The image to pull. This example uses a prebuilt MQ Advanced image from IBM Container Registry
image: cp.icr.io/cp/ibm-mqadvanced-server:9.4.1.0-r1
imagePullPolicy: IfNotPresent
serviceAccount: quickstart-ibm-mq
dnsPolicy: ClusterFirst
serviceName: qm
podManagementPolicy: OrderedReady
updateStrategy:
type: OnDelete
-
Confirm that the queue manager is running
The queue manager is now being deployed. Confirm it is in Running state, for
example by listing the queue manager pods:
kubectl get pods --selector app.kubernetes.io/instance=quickstart
Note that this must return a single pod, and the READY field must show the
value 1/1.
- View the queue manager status
Run the following command, specifying the full
name of the queue manager
pod:
kubectl exec -t <qmgr_pod_name> -- dspmq -m QUICKSTART
This
should return a response similar to the
following:
QMNAME(QUICKSTART) STATUS(Running)
Results
You have successfully deployed a simple IBM MQ queue
manager, of type single instance, on your Kubernetes
platform.