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:
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
NAME READY STATUS RESTARTS AGE
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?
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
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);
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()
serverConfigurationBuilder.servers("axonserver")
configurer.registerComponent(AxonServerConfiguration::class.java) { serverConfigurationBuilder.build() }
`
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