Axon Server SE
This section is split into 3 sub-sections.
Docker Image
Axon provides a ready to use Axon Server SE image. The image is built using a compact image from Google’s “distroless” base images at the gcr.io repository, in this case “gcr.io/distroless/java:11”.
To run the provided image the command below can be executed. This starts Axon Server SE in a docker container with exposes the HTTP (8024) and GRPC (8124) ports to the host.
A quick verification of the running docker container can be done by querying the REST API that is available to retrieve configuration information for a running Axon Server instance.
This displays the information below:
The application is installed in the root with a minimal properties file which is depicted below. The “/data” and “/eventdata” directories are created as volumes, and their data will be accessible on the local filesystem somewhere in Docker’s temporary storage tree.
Customization
The directory locations for the volumes can be specified as per your requirements. The image also has a third directory "/config" which is not marked as a volume. This gives you the capability to have an "axonserver.properties" file which can be placed in this location to override the above mentioned settings as well as add new properties similar to a local install.
Assuming that you have a directory "axonserverse" which will be the designated location for your volumes and configuration information.
We will first create the sub-directories for the volumes/configuration. We will also add a couple of custom properties (name/hostname) to the axonserver.properties file which will be placed in the config sub-directory. As stated above, you can add additional properties to control the configuration.
To start the container with the customizations done above, the following command can be executed:
Now if you query the API (utilizing the “curl” command depicted above) it will show that it is running with name “axonserver” and hostname “localhost”. Also the data directory will contain the ControlDB file, PID file, and a copy of the log output. The “events” directory will have the event and snapshot data.
This completes a basic setup of the Axon Server SE Docker image with implementation of customizations.
Docker Compose
Running Axon Server SE in docker-compose helps address more complex requirements around distributed scenarios. The following file will help start Axon Server SE with “./data”, “./events”, and “./config” mounted as volumes and the config directory is actually Read-Only.
This again assumes that you have a directory "axonserverse" which will be the designated location for your volumes and configuration information.
Starting the Axon Server SE using the docker-compose command is depicted below.
Kubernetes
An Axon Server SE instance has a clear and persistent identity, in that it saves identifying information about itself in the controlDB. Also, if it is used as an event store, the context’s events will be stored on disk as well, essentially Axon Server SE is a stateful application.
In the context of Kubernetes that means we want to bind every Axon Server deployment to its own storage volumes, and also to a predictable network identity. Kubernetes provides us with a StatefulSet deployment class which does just that i.e. StatefulSets represent a set of Pods with unique, persistent identities and stable hostnames that is maintained regardless of where they are scheduled.
A sample YAML descriptor is depicted below which defines a StatefulSet for Axon Server and two Services (axon-server-gui / axonserver) to provide access to the HTTP and gRPC ports.
Important to note here is that this is a pretty basic descriptor in the sense that it does not have any settings for the amount of memory and/or cpu to reserve for Axon Server SE which you may want to do for long-running deployments.
To deploy, you would need a Kubernetes cluster and access to the kubectl utility to help control these clusters. For a development Kubernetes cluster, it is recommended to use minikube or Red Hat CodeReady Containers which installs a Red Hat OpenShift Kubernetes cluster on your laptop. For production it is recommended to use a managed service like AWS EKS / Google's GKE or Azure's AKS.
The first step would be to create a separate namespace for Axon Server SE.
The next step would be to deploy to the cluster.
This completes a basic setup to help install Axon Server SE on Kubernetes.
Last updated