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.
1
$ docker run -d --name axonserver -p 8024:8024 -p 8124:8124 axoniq/axonserver
Copied!
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.
1
$ curl -s http://localhost:8024/v1/public/me
Copied!
This displays the information below:
1
{
2
"authentication": false,
3
"clustered": false,
4
"ssl": false,
5
"adminNode": true,
6
"developmentMode": false,
7
"storageContextNames": [
8
"default"
9
],
10
"contextNames": [
11
"default"
12
],
13
"httpPort": 8024,
14
"grpcPort": 8124,
15
"internalHostName": null,
16
"grpcInternalPort": 0,
17
"name": "{axon-server-name}",
18
"hostName": "{axon-server-hostname}"
19
}
Copied!
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.
1
axoniq.axonserver.snapshot.storage=/eventdata
2
axoniq.axonserver.controldb-path=/data
3
axoniq.axonserver.pid-file-location=/data
4
logging.file=/data/axonserver.log
5
logging.file.max-history=10
6
logging.file.max-size=10MB
Copied!

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.
1
$ mkdir -p axonserverse/data axonserverse/events axonserverse/config
2
$ (
3
> echo axoniq.axonserver.name=axonserver
4
> echo axoniq.axonserver.hostname=localhost
5
> ) > axonserverse/config/axonserver.proprties
Copied!
To start the container with the customizations done above, the following command can be executed:
1
docker run -d --rm --name axonserver -p 8024:8024 -p 8124:8124 -v `pwd`/axonserverse/data:/data -v `pwd`/axonserverse/events:/eventdata -v `pwd`/axonserverse/config:/config axoniq/axonserver
Copied!
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.
1
version: '3.3'
2
services:
3
axonserver:
4
image: axoniq/axonserver
5
hostname: axonserver
6
volumes:
7
- axonserver-data:/data
8
- axonserver-events:/eventdata
9
- axonserver-config:/config:ro
10
ports:
11
- '8024:8024'
12
- '8124:8124'
13
- '8224:8224'
14
networks:
15
- axon-demo
16
17
volumes:
18
axonserver-data:
19
driver: local
20
driver_opts:
21
o: bind
22
type: none
23
device: ${PWD}/axonserverse/data
24
axonserver-events:
25
driver: local
26
driver_opts:
27
o: bind
28
type: none
29
device: ${PWD}/axonserverse/events
30
axonserver-config:
31
driver: local
32
driver_opts:
33
o: bind
34
type: none
35
device: ${PWD}/axonserverse/config
36
37
networks:
38
axon-demo:
Copied!
Starting the Axon Server SE using the docker-compose command is depicted below.
1
$ docker-compose up
2
Creating network "docker-compose_axon-demo" with the default driver
3
Creating volume "docker-compose_axonserver-data" with local driver
4
Creating volume "docker-compose_axonserver-events" with local driver
5
Creating volume "docker-compose_axonserver-config" with local driver
6
Creating docker-compose_axonserver_1 ... done
7
Attaching to docker-compose_axonserver_1
8
axonserver_1 | _ ____
9
axonserver_1 | / \ __ _____ _ __ / ___| ___ _ ____ _____ _ __
10
axonserver_1 | / _ \ \ \/ / _ \| '_ \\___ \ / _ \ '__\ \ / / _ \ '__|
11
axonserver_1 | / ___ \ > < (_) | | | |___) | __/ | \ V / __/ |
12
axonserver_1 | /_/ \_\/_/\_\___/|_| |_|____/ \___|_| \_/ \___|_|
13
axonserver_1 | Standard Edition Powered by AxonIQ
Copied!

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.
1
apiVersion: apps/v1
2
kind: StatefulSet
3
metadata:
4
name: axonserver
5
labels:
6
app: axonserver
7
spec:
8
serviceName: axonserver
9
replicas: 1
10
selector:
11
matchLabels:
12
app: axonserver
13
template:
14
metadata:
15
labels:
16
app: axonserver
17
spec:
18
containers:
19
- name: axonserver
20
image: axoniq/axonserver
21
imagePullPolicy: Always
22
ports:
23
- name: grpc
24
containerPort: 8124
25
protocol: TCP
26
- name: gui
27
containerPort: 8024
28
protocol: TCP
29
volumeMounts:
30
- name: data
31
mountPath: /data
32
- name: events
33
mountPath: /eventdata
34
readinessProbe:
35
httpGet:
36
path: /actuator/info
37
port: 8024
38
initialDelaySeconds: 5
39
periodSeconds: 5
40
timeoutSeconds: 1
41
failureThreshold: 30
42
livenessProbe:
43
httpGet:
44
path: /actuator/info
45
port: 8024
46
initialDelaySeconds: 5
47
periodSeconds: 10
48
successThreshold: 1
49
failureThreshold: 3
50
volumeClaimTemplates:
51
- metadata:
52
name: events
53
spec:
54
accessModes: [ "ReadWriteOnce" ]
55
resources:
56
requests:
57
storage: 5Gi
58
- metadata:
59
name: data
60
spec:
61
accessModes: [ "ReadWriteOnce" ]
62
resources:
63
requests:
64
storage: 1Gi
65
---
66
apiVersion: v1
67
kind: Service
68
metadata:
69
name: axonserver-gui
70
labels:
71
app: axonserver
72
spec:
73
ports:
74
- name: gui
75
port: 8024
76
targetPort: 8024
77
selector:
78
app: axonserver
79
type: LoadBalancer
80
---
81
apiVersion: v1
82
kind: Service
83
metadata:
84
name: axonserver
85
labels:
86
app: axonserver
87
spec:
88
ports:
89
- name: grpc
90
port: 8124
91
targetPort: 8124
92
clusterIP: None
93
selector:
94
app: axonserver
95
---
Copied!
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.
1
$ kubectl create ns ${axonserverse-ns}
2
namespace/running-axon-server created
Copied!
The next step would be to deploy to the cluster.
1
$ kubectl apply -f axonserver.yml -n ${axonserverse-ns}
2
statefulset.apps/axonserver created
3
service/axonserver-gui created
4
service/axonserver created
Copied!
This completes a basic setup to help install Axon Server SE on Kubernetes.
Last modified 26d ago