Axon Framework app having issues connecting to Axon Server on Kubernetes

Hey guys,

Could anyone help me out here? I’ve just deployed my app built with Axon Framework to k8s to the same namespace with Axon Server following the example in the docs. However the app cannot connect to the server:

2020-05-20 07:34:50.222 [main] WARN o.a.a.c.AxonServerConnectionManager - Connecting to AxonServer node [localhost]:[8124] failed: UNAVAILABLE: io exception

I’m guessing this is because the app is looking for AxonServer on localhost, whereas it’s running in another pod:

➜ ~ kubectl get pods -n production
axonserver-0 1/1 Running 0 126m
backend-deployment-5d9dcd9487-9xz9d 1/1 Running 0 126m


Is there a config option somewhere to point the app framework to axonserver instead of localhost so that it will look for it in another pod?

Thanks in advance!

PS: I should mention we’re using Kotlin + Ktor rather than Spring Boot, so is not being picked up

Hello Krystian,

You should use the internal DNS of your Kubernetes cluster.
For example, you can set env variable on your application AXON_AXONSERVER_SERVERS: "axonserver-0.axonserver.default.svc.cluster.local:8124" Please mind the namings here, I’m not sure how do you named Axon Server stateful set.

If you would use spring properties/yml then the name of the property is axon.axonserver.servers=axonserver-0.axonserver.default.svc.cluster.local:8124


Thanks a lot Ivan! I’ve tried that, but it does not seem to be picked up at all, even though the env var is set:

➜ ~ kubectl exec -it backend-deployment-6c79cf7d46-dq7mw -n production – /bin/sh


root@backend-deployment-6c79cf7d46-dq7mw:/# echo $AXON_AXONSERVER_SERVERS

The app is still complaining:

2020-05-20 10:17:09.388 [main] WARN o.a.a.c.AxonServerConnectionManager - Connecting to AxonServer node [localhost]:[8124] failed: UNAVAILABLE: io exception

PS: I’ve also tried with the exact save value you provided, which should be correct. My stateful set is indeed called axonserver

➜ ~ kubectl exec -it backend-deployment-69599f458f-67htw -n production -- /bin/bash root@backend-deployment-69599f458f-67htw:/# echo $AXON_AXONSERVER_SERVERS axonserver-0.axonserver.default.svc.cluster.local:8124

I assume you’re using the configuration API to configure your components? If that’s the case, you can change the configuration of the AxonServer Connector by doing:

AxonServerProperties properties = new AxonServerProperties();
// set correct properties;
configurer.registerComponent(c -> properties);

Hope this helps.

Oh gosh, thanks @Allard, I was slowly descending into madness trying to shove this config into other configs. I would not have thought about this registerComponent thing. I’m guessing you meant AxonServerConfiguration, so I set the hostname as follows:


val serverConfigurationBuilder = AxonServerConfiguration.Builder()
configurer.registerComponent( { }


Would it not make sense to add this into docs? Setting hostname (or configuring connection to server in general) is a pretty common task I would say :slight_smile:

Ahh, I missed that you are using Ktor and the configuration API (no spring boot).