Chapter 3. Tutorials
These tutorials follow on from and assume an OpenShift Container Platform 3.9 instance similar to that created in OpenShift Container Platform 3.9 Getting Started.
In this tutorial you prepare and deploy a multiple-node AMQ Broker instance with persistent storage.
3.1. Preparing the AMQ Broker deployment Copy linkLink copied to clipboard!
Procedure
At a command prompt, create a new project:
oc new-project amq-demo
$ oc new-project amq-demoCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a service account to be used for the AMQ Broker deployment:
echo '{"kind": "ServiceAccount", "apiVersion": "v1", "metadata": {"name": "amq-service-account"}}' | oc create -f -$ echo '{"kind": "ServiceAccount", "apiVersion": "v1", "metadata": {"name": "amq-service-account"}}' | oc create -f -Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the view role to the service account. The view role enables the service account to view all the resources in the amq-demo namespace, which is necessary for managing the cluster when using the OpenShift dns-ping protocol for discovering the mesh endpoints.
oc policy add-role-to-user view system:serviceaccount:amq-demo:amq-service-account
$ oc policy add-role-to-user view system:serviceaccount:amq-demo:amq-service-accountCopy to Clipboard Copied! Toggle word wrap Toggle overflow AMQ Broker requires a broker keystore, a client keystore, and a client truststore that includes the broker keystore. This example uses Java Keytool, a package included with the Java Development Kit, to generate dummy credentials for use with the AMQ Broker installation.
Generate a self-signed certificate for the broker keystore:
keytool -genkey -alias broker -keyalg RSA -keystore broker.ks
$ keytool -genkey -alias broker -keyalg RSA -keystore broker.ksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Export the certificate so that it can be shared with clients:
keytool -export -alias broker -keystore broker.ks -file broker_cert
$ keytool -export -alias broker -keystore broker.ks -file broker_certCopy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a self-signed certificate for the client keystore:
keytool -genkey -alias client -keyalg RSA -keystore client.ks
$ keytool -genkey -alias client -keyalg RSA -keystore client.ksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a client truststore that imports the broker certificate:
keytool -import -alias broker -keystore client.ts -file broker_cert
$ keytool -import -alias broker -keystore client.ts -file broker_certCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the broker keystore file to create the AMQ Broker secret:
oc secrets new amq-app-secret broker.ks
$ oc secrets new amq-app-secret broker.ksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the secret to the service account created earlier:
oc secrets add sa/amq-service-account secret/amq-app-secret
$ oc secrets add sa/amq-service-account secret/amq-app-secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Deploying the image and template Copy linkLink copied to clipboard!
Procedure
-
Navigate to the OpenShift web console and log in, selecting the
amq-demoproject space. - Click Add to Project > Browse catalog to list all of the default image streams and templates.
-
Use the Filter search bar to limit the list to those that match
amq. You might need to click See all to show the desired application template. Select a template. This example uses the
amq-broker-71-persistence-ssl.yamltemplate to allow for persistent storage and SSL.Expand Table 3.1. Example template Environment variable Value APPLICATION_NAME
broker
AMQ_TRANSPORTS
openwire
AMQ_USER
amq-demo-user
AMQ_PASSWORD
password
VOLUME_CAPACITY
512Mi
AMQ_KEYSTORE_TRUSTSTORE_DIR
/etc/amq-secret-volume
AMQ_TRUSTSTORE
broker.ts
AMQ_TRUSTSTORE_PASSWORD
password
AMQ_KEYSTORE
broker.ks
AMQ_KEYSTORE_PASSWORD
password
IMAGE_STREAM_NAMESPACE
openshift
3.3. Post-deployment Copy linkLink copied to clipboard!
3.3.1. Creating a route Copy linkLink copied to clipboard!
You must create a route for the broker so that clients outside of OpenShift Container Platform can connect using SSL. By default, the OpenWire protocol uses the 61617/TCP port.
Only one broker can be scaled up. You cannot scale up multiple brokers.
Procedure
- Click Create a Route and from the Service drop-down menu, click broker-amq-tcp-ssl.
- Select the Secure route check box to display the TLS parameters.
- From the TLS Termination drop-down menu, click Passthrough. This selection relays all communication to AMQ Broker without the OpenShift router decrypting and resending it.
Clients can now connect to the broker by specifying the following in their configuration:
factory.setBrokerURL("failover://ssl://broker-amq-demo.example.com:443");factory.setBrokerURL("failover://ssl://broker-amq-demo.example.com:443");Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3.1.1. Monitoring AMQ Broker Copy linkLink copied to clipboard!
This tutorial demonstrates how to monitor AMQ Broker.
Prerequisite
You must have created a project and a service account, and added the view role to the service account for AMQ Broker deployment. For more information see Preparing the AMQ Broker deployment.
Procedure
At the command line, go to your project:
oc project monitoramq
$ oc project monitoramqCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a new broker instance to the
monitoramqproject, using theamq-broker-71-basictemplate from theopenshiftnamespace:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the list of running pods:
oc get pods NAME READY STATUS RESTARTS AGE broker-amq-1-ftqmk 1/1 Running 0 14d
$ oc get pods NAME READY STATUS RESTARTS AGE broker-amq-1-ftqmk 1/1 Running 0 14dCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
oc logscommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run your query to monitor your broker for
MaxConsumers:curl -k -u admin:admin http://console-broker.monitoramq.apps.example.com/console/jolokia/read/org.apache.activemq.artemis:broker=%22broker%22,component=addresses,address=%22TESTQUEUE%22,subcomponent=queues,routing-type=%22anycast%22,queue=%22TESTQUEUE%22/MaxConsumers {"request":{"mbean":"org.apache.activemq.artemis:address=\"TESTQUEUE\",broker=\"broker\",component=addresses,queue=\"TESTQUEUE\",routing-type=\"anycast\",subcomponent=queues","attribute":"MaxConsumers","type":"read"},"value":-1,"timestamp":1528297825,"status":200}$ curl -k -u admin:admin http://console-broker.monitoramq.apps.example.com/console/jolokia/read/org.apache.activemq.artemis:broker=%22broker%22,component=addresses,address=%22TESTQUEUE%22,subcomponent=queues,routing-type=%22anycast%22,queue=%22TESTQUEUE%22/MaxConsumers {"request":{"mbean":"org.apache.activemq.artemis:address=\"TESTQUEUE\",broker=\"broker\",component=addresses,queue=\"TESTQUEUE\",routing-type=\"anycast\",subcomponent=queues","attribute":"MaxConsumers","type":"read"},"value":-1,"timestamp":1528297825,"status":200}Copy to Clipboard Copied! Toggle word wrap Toggle overflow