![[OpenShift Container Platform]](ngocp.gif)
![[Kubernetes]](ngkube.gif)
![[Amazon EKS]](ngeks.gif)
Example: Configuring Native HA using the IBM MQ Operator
This example deploys a queue manager using the native high availability feature by using the IBM® MQ Operator. Mutual TLS is used for authentication, to map from a TLS certificate to an identity in the queue manager.
Before you begin
To complete this example, you must first have completed the following prerequisites:
- Create a project/namespace for this example on your cluster.
- On the command line, log into your cluster, then switch to the above namespace.
- Ensure the IBM MQ Operator is installed and available in the above namespace.
About this task
This example provides a custom resource YAML defining a queue manager to be deployed. It also details the additional steps required to deploy the queue manager with TLS enabled.
Procedure
- Create a pair of certificates as described in Creating a self-signed PKI using OpenSSL.
-
Create a config map containing MQSC commands and an INI file
Create a Kubernetes ConfigMap containing the MQSC commands to create a new queue and a SVRCONN channel, and to add a channel authentication record that allows access to the channel.Ensure you are in the namespace you created earlier (see Before you begin), then enter the following YAML in the OCP web console, or using the command line.
The MQSC defines a channel calledapiVersion: v1 kind: ConfigMap metadata: name: example-nativeha-configmap data: example-tls.mqsc: | DEFINE CHANNEL('MTLS.SVRCONN') CHLTYPE(SVRCONN) SSLCAUTH(REQUIRED) SSLCIPH('ANY_TLS13_OR_HIGHER') REPLACE SET CHLAUTH('MTLS.SVRCONN') TYPE(SSLPEERMAP) SSLPEER('CN=*') USERSRC(NOACCESS) ACTION(REPLACE) SET CHLAUTH('MTLS.SVRCONN') TYPE(SSLPEERMAP) SSLPEER('CN=example-app1') USERSRC(MAP) MCAUSER('app1') ACTION(REPLACE) SET AUTHREC PRINCIPAL('app1') OBJTYPE(QMGR) AUTHADD(CONNECT,INQ) DEFINE QLOCAL('EXAMPLE.QUEUE') REPLACE SET AUTHREC PROFILE('EXAMPLE.QUEUE') PRINCIPAL('app1') OBJTYPE(QUEUE) AUTHADD(BROWSE,PUT,GET,INQ) example-tls.ini: | Service: Name=AuthorizationService EntryPoints=14 SecurityPolicy=UserExternalMTLS.SVRCONNand a queue calledEXAMPLE.QUEUE. The channel is configured to allow access only to clients which present a certificate with a "common name" ofexample-app1. This is the common name used in one of the certificates created in Step 1. Connections on this channel with this common name are mapped to a user ID ofapp1, which is authorized to connect to the queue manager, and to access the example queue. The INI file enables a security policy which means that theapp1user ID does not need to exist in an external user registry — it exists only as a name in this configuration. -
Deploy the queue manager
Create a new queue manager by using the following custom resource YAML. Ensure you are in the namespace that you created before you begin this task.
The availability type is set to
NativeHAand persistent storage is selected. The default storage class configured in your Kubernetes cluster will be used. If you do not have a storage class configured as default, or you want to use a different storage class, adddefaultClass:understorage_class_namespec.queueManager.storage.The three pods in a Native HA queue manager replicate data over the network. This link is not encrypted by default, but this example uses the queue manager's certificate for encrypting traffic. You can specify a different certificate for additional security. The Native HA TLS Secret must be a Kubernetes TLS Secret, which has a particular structure (for example, the private key must be called
tls.key).Note that the
example-qm-tlsSecret was created in Step 1, and theexample-nativeha-configmapConfigMap was created in Step 2Note:The following YAML uses an IBM MQ Advanced license, though you can also use an IBM MQ license. For more information, see Configuring Native HA and Cross-Region Replication on IBM MQ licensed Queue Managers by using the IBM MQ Operator.
Important: If you accept the IBM MQ Advanced license agreement, changeaccept: falsetoaccept: true. See mq.ibm.com/v1beta1: Current license versions for details on the license.- Example QueueManager for Red Hat® OpenShift®
- Deploy your queue manager with the following configuration, using the command line or using the
Red Hat OpenShift Container Platform web
console.
apiVersion: mq.ibm.com/v1beta1 kind: QueueManager metadata: name: exampleqm spec: license: accept: false license: L-CXDB-XTZ9J8 use: Production queueManager: name: EXAMPLEQM availability: type: NativeHA tls: secretName: example-qm-tls mqsc: - configMap: name: example-nativeha-configmap items: - example-tls.mqsc ini: - configMap: name: example-nativeha-configmap items: - example-tls.ini storage: queueManager: type: persistent-claim version: 10.0.0.0-r1 pki: keys: - name: default secret: secretName: example-qm-tls items: - tls.key - tls.crt - ca.crt - Example QueueManager for Amazon EKS
Deploy your queue manager with the following configuration on an Amazon EKS cluster.
apiVersion: mq.ibm.com/v1beta1 kind: QueueManager metadata: name: exampleqm spec: license: accept: false license: L-CXDB-XTZ9J8 use: Production queueManager: name: EXAMPLEQM availability: type: NativeHA tls: secretName: example-qm-tls mqsc: - configMap: name: example-nativeha-configmap items: - example-tls.mqsc ini: - configMap: name: example-nativeha-configmap items: - example-tls.ini storage: queueManager: type: persistent-claim route: enabled: false metrics: serviceMonitor: enabled: false version: 10.0.0.0-r1 pki: keys: - name: default secret: secretName: example-qm-tls items: - tls.key - tls.crt - ca.crt web: enabled: false route: enabled: falsespec.queueManager.route.enabled,spec.queueManager.metrics.serviceMonitor.enabled, andspec.web.route.enabledare set tofalsebecause these are Red Hat OpenShift specific features that are enabled by default. These features must be disabled explicitly on Amazon EKS.
-
Confirm that the queue manager is running
The queue manager is now being deployed. Confirm it is in
Runningstate before proceeding. For example:- For deployments on the Red Hat OpenShift Container Platform:
oc get qmgr exampleqm - For deployments on Amazon EKS:
kubectl get qmgr exampleqm
- For deployments on the Red Hat OpenShift Container Platform:
-
Test the connection to the queue manager
To confirm the queue manager is configured for mutual TLS communication, follow the steps in the appropriate link for your platform:
- Red Hat OpenShift: Testing a mutual TLS connection to a queue manager from your laptop for Red Hat OpenShift
- Amazon EKS: Testing a mutual TLS connection to a queue manager from a client application on your laptop for Amazon EKSImportant: Amazon EKS users must complete the steps to Configuring a LoadBalancer to connect to a queue manager for Amazon EKS deployments before continuing on this page.
-
Force the active pod to fail
To validate the automatic recovery of the queue manager, simulate a pod failure:
-
View the active and standby pods
Run the following command:
- For deployments on the Red Hat OpenShift Container Platform:
oc get pods --selector app.kubernetes.io/instance=exampleqm - For deployments on Amazon EKS:
kubectl get pods --selector app.kubernetes.io/instance=exampleqm
1/1, whereas the standby pod returns the value0/1. - For deployments on the Red Hat OpenShift Container Platform:
-
Delete the active pod
Run the following command, specifying the full name of the active pod:
- For deployments on the Red Hat OpenShift Container Platform:
oc delete pod exampleqm-ibm-mq-<VALUE> - For deployments on Amazon EKS:
kubectl delete pod exampleqm-ibm-mq-<VALUE>
- For deployments on the Red Hat OpenShift Container Platform:
- View the pod status again (see step 6.a).
-
View the queue manager status
Run the following command, specifying the full name of the
<ACTIVE_POD>. The active pod should be in ready state (this is the pod with theREADYvalue of1/1shown by the pod status command in the previous step):- For deployments on the Red Hat OpenShift Container Platform:
oc exec -t <ACTIVE_POD> -- dspmq -o nativeha -x -m EXAMPLEQM - For deployments on Amazon EKS:
kubectl exec -t <ACTIVE_POD> -- dspmq -o nativeha -x -m EXAMPLEQM
You should see the status shows that the active instance has changed, for example:QMNAME(EXAMPLEQM) ROLE(Active) INSTANCE(inst1) INSYNC(Yes) QUORUM(3/3) INSTANCE(inst1) ROLE(Active) REPLADDR(9.20.123.45) CONNACTV(Yes) INSYNC(Yes) BACKLOG(0) CONNINST(Yes) ALTDATE(2022-01-12) ALTTIME(12.03.44) INSTANCE(inst2) ROLE(Replica) REPLADDR(9.20.123.46) CONNACTV(Yes) INSYNC(Yes) BACKLOG(0) CONNINST(Yes) ALTDATE(2022-01-12) ALTTIME(12.03.44) INSTANCE(inst3) ROLE(Replica) REPLADDR(9.20.123.47) CONNACTV(Yes) INSYNC(Yes) BACKLOG(0) CONNINST(Yes) ALTDATE(2022-01-12) ALTTIME(12.03.44) - For deployments on the Red Hat OpenShift Container Platform:
-
Test the connection to the queue manager again
Note: You do not need to repeat the steps to configure the connection, only those to put and receive messages to or from the queueTo confirm the queue manager has recovered, follow the steps in the appropriate link for your platform:
-
View the active and standby pods
Results
You deployed a queue manager with native high availability and mutual TLS authentication, and verified that it automatically recovers when the active Pod fails.