Chapter 2. Installing and Deploying AMQ Broker on OpenShift Container Platform
2.1. Installing the AMQ Broker on OpenShift Container Platform image streams and application templates Copy linkLink copied to clipboard!
The AMQ Broker on OpenShift Container Platform image is not available in the service catalog, so you must manually install the image.
Procedure
Log in to OpenShift as a cluster administrator (or as a user that has project administrator access to the global openshift project), for example:
oc login -u system:admin
$ oc login -u system:admin
Copy to Clipboard Copied! Toggle word wrap Toggle overflow At the command line, run the following commands to update the core AMQ Broker on OpenShift Container Platform image stream in the openshift project:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou might receive error messages indicating some image streams already exist after invoking the
create
command. A single command to create and replace is not available.Run the following command to update the AMQ Broker templates:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou might receive "already exists" error messages after invoking the
create
command.
2.2. Deploying the AMQ Broker on OpenShift Container Platform image Copy linkLink copied to clipboard!
The AMQ Broker on OpenShift Container Platform image requires a service account for deployments. Service accounts are API objects that exist within each project. Three service accounts are created automatically in every project:
-
builder
: This service account is used by build pods. It contains thesystem:image-builder
role from which you can push images to any image stream in the project using the internal Docker registry. -
deployer
: This service account is used by deployment pods. It contains thesystem:deployer
role from which you can view and modify replication controllers and pods in the project. -
default
: This service account is used to run all other pods unless you specify a different service account.
Service accounts can be created or deleted like any other API object. For multiple-node deployments, the service account must have the view
role enabled so that it can discover and manage the various pods in the cluster. In addition, you must configure SSL to enable connections to AMQ Broker from outside of the OpenShift Container Platform instance; for more information about how to configure SSL see Configuring SSL. The type of discovery protocol that is used for discovering of AMQ Broker mesh endpoints is JGroups with OpenShift.dns ping protocol.
Procedure
-
Add the
view
role to the service account:
oc policy add-role-to-user view -z default
$ oc policy add-role-to-user view -z default
2.3. Configuring SSL Copy linkLink copied to clipboard!
For a minimal SSL configuration to allow connections outside of OpenShift Container Platform, AMQ Broker requires a broker keystore, a client keystore, and a client truststore that includes the broker keystore. The broker keystore is also used to create a secret for the AMQ Broker on OpenShift Container Platform image, which is added to the service account.
The following example commands use Java KeyTool, a package included with the Java Development Kit, to generate the necessary certificates and stores.
Procedure
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.ks
Copy 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_cert
Copy 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.ks
Copy 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_cert
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the client’s certificate from the keystore:
keytool -export -alias client -keystore client.ks -file client_cert
$ keytool -export -alias client -keystore client.ks -file client_cert
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Import the client’s exported certificate into a broker SERVER truststore:
keytool -import -alias client -keystore broker.ts -file client_cert
$ keytool -import -alias client -keystore broker.ts -file client_cert
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Generating the AMQ Broker secret Copy linkLink copied to clipboard!
The broker keystore can be used to generate a secret for the namespace, which is also added to the service account so that the applications can be authorized.
Procedure
In a command line, run the following command:
oc create secret generic <secret-name> --from-file=<broker-keystore> --from-file=<broker-truststore> oc secrets add sa/<service-account-name> secret/<secret-name>
$ oc create secret generic <secret-name> --from-file=<broker-keystore> --from-file=<broker-truststore> $ oc secrets add sa/<service-account-name> secret/<secret-name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5. Creating an SSL route Copy linkLink copied to clipboard!
After the AMQ Broker on OpenShift Container Platform image has been deployed, an SSL route needs to be created for the AMQ Broker transport protocol port to allow connections to AMQ Broker outside of OpenShift.
In addition, selecting Passthrough for TLS Termination relays all communication to AMQ Broker without the OpenShift router decrypting and resending it. Only SSL routes can be exposed because the OpenShift router requires SNI to send traffic to the correct service. For more information see Secured Routes.
The default ports for the various AMQ Broker transport protocols are:
AMQ Broker transport protocol | Default port |
---|---|
All protocols | 61616 |
All protocols (SSL) | 61617 |
AMQP | 5672 |
AMQP (SSL) | 5671 |
MQTT | 1883 |
MQTT (SSL) | 8883 |
STOMP | 61613 |
STOMP (SSL) | 61612 |
2.6. Customizing AMQ Broker configuration files for deployment Copy linkLink copied to clipboard!
If you are using a template from an alternate repository, AMQ Broker configuration files such as artemis-users.properties
can be included. When the image is downloaded for deployment, these files are copied from <amq-home>/conf/
to the <broker-instance-dir>/etc/
directory on AMQ Broker, which is committed to the container and pushed to the OpenShift registry.
If using this method, ensure that the placeholders in the configuration files (such as AUTHENTICATION
) are not removed, as these placeholders are necessary for building the AMQ Broker on OpenShift Container Platform image.
2.7. Configuring client connections Copy linkLink copied to clipboard!
Clients for the AMQ Broker on OpenShift Container Platform image must specify the OpenShift router port (443) when setting the broker URL for SSL connections. Otherwise, AMQ Broker attempts to use the default SSL port (61617). Including the failover protocol in the URL preserves the client connection in case the pod is restarted or upgraded, or a disruption occurs on the router.
... factory.setBrokerURL("failover://ssl://<route-to-broker-pod>:443"); ...
...
factory.setBrokerURL("failover://ssl://<route-to-broker-pod>:443");
...
External clients do not support HA.