Customized Artemis Broker Configuration With Init Containers on Kubernetes or Openshift
In this article, we will discuss and explore options on how we can customize the configuration for Artemis Broker on Kubernetes or OpenShift.
Join the DZone community and get the full member experience.Join For Free
Apache ActiveMQ Artemis is a powerful open-source multi-protocol message broker. Red Hat AMQ 7 is the enterprise distribution of Apache ActiveMQ Artemis. Also, there is artemiscloud.io available for Kubernetes and OpenShift.
In this article, we will discuss how we can customize the configuration for Artemis Broker on Kubernetes. This could be helpful for those who are migrating from the Standalone version of AMQ 7 or Artemis to AMQ 7 on OpenShift. For beginners, the using_operator article would be helpful. In this article too, I am referring to this article for basic setup.
I am using minikube version: v1.19.0 for testing this setup on my laptop.
By default, broker configuration doesn't have to divert configuration. A divert just route messages from one address to another address in the same broker. Thus there is no need for an external connector to move messages from one destination to another, simple broker configuration using divert will move the messages. Following the configuration we will make here exclusive is set as false which means a copy of the message will be routed or forwarded from priceUpdates address/destination to priceForwarding address/destination.
So, let's start now
1. Deploy Artemis Operator
2. Configurations for Artemis init container: We need config/post-config.sh file and Dockerfile. Dockerfile refers to artemis-broker-init image, also config folder with post-config.sh file.
3. Content of post-config.sh file: Here we are adding divert and address configurations. At the end of the post-config.sh with sed command we are appending these configuration to default broker.xml. Here We don't have to set this
CONFIG_INSTANCE_DIR environment variable; it is resolved itself by init container and broker.
4. Create a customized init Docker Image.
5. Deploy Artemis broker instance using init image we just created: Within the git repository we cloned in first step, we can find examples activemq-artemis-operator/deploy/examples. We can create a artemis-basic-deployment-init.yaml with same content of artemis-basic-deployment.yaml. Than we can modify artemis-basic-deployment-init.yaml with image as broker image and initImage with the image we created.
6. Now send some messages to test Divert functionality.
7. Check If broker.xml has divert and address configuration set.
That's it, guys. I hope you will find this article helpful. When containers are immutable, it means any changes at runtime will not persist after pod restart, but with init containers, we can have our own customized image and this will persist during and after restart too.
Opinions expressed by DZone contributors are their own.