<p>I have 3 services which are axon, command and query. I am trying running them via Kubernetes. With docker-compose and swarm works perfectly. But somehow not working via K8s. 
Getting following error:</p>

<p><code>Connecting to AxonServer node axonserver:8124 failed: UNAVAILABLE: Unable to resolve host axonserver</code>
Below are my config files. </p>

<pre><code> `
  apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    name: axonserver
    labels:
      app: axonserver
  spec:
    serviceName: axonserver
    replicas: 1
    selector:
      matchLabels:
        app: axonserver
    template:
      metadata:
        labels:
          app: axonserver
      spec:
        containers:
          - name: axonserver
            image: axoniq/axonserver
            env:
            - name: AXONSERVER_HOSTNAME
             value: axonserver
            imagePullPolicy: Always
            ports:
            - name: grpc
              containerPort: 8124
              protocol: TCP
            - name: gui
              containerPort: 8024
              protocol: TCP
</code></pre>

<p>`</p>

<p>Here is command-service yaml contains service as well.</p>

<pre><code>  apiVersion: 
  kind: Pod
  metadata:
    name: command-service
    labels:
      name: peanuts
      app: axonserver
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: axonserver
      spec:
        containers:
        - image: celcin/command-svc
          name: command-service
          ports:
          - containerPort: 8080
          restartPolicy: Always
        status: {}
   ---
   apiVersion: v1 
   kind: Service
   metadata:
     name: command-service
       labels:
         name: peanuts
         app: axonserver
   spec:
     ports:
     - name: "8081"
       port: 8081
       targetPort: 8080
     selector:
       labels:
         app: axonserver
</code></pre>

<p>`</p>

<p>Here is last service as query-service yml file</p>

<pre><code> ` apiVersion: v1
   kind: Pod
   metadata:
     name: query-service
     labels:
       name: peanuts
       app: axonserver
   spec:
     replicas: 1
       template:
       metadata:
         labels:
           app: axonserver
       spec:
         containers:
         - image: celcin/query-svc
           name: query-service
           ports:
           - containerPort: 8080
         restartPolicy: Always
       ---
   apiVersion: v1
   kind: Service
   metadata:
     name: query-service
     labels:
       name: peanuts
       app: axonserver
   spec:
     ports:
     - name: "8082"
       port: 8082
       targetPort: 8080
     selector:
       labels:
         app: axonserver`
</code></pre>

<p>your YAML is somehow mixed. If I understood you correctly, you have three services:</p>

<ul>
<li>command-service</li>
<li>query-service</li>
<li>axonserver</li>
</ul>

<p>Your setup should be configured in a way that <code>command-service</code> and <code>query-service</code> expose their ports, but both use ports exposed by <code>axonserver</code>. Here is my attempt for your YAML:</p>

<pre><code> apiVersion: apps/v1
 kind: StatefulSet
 metadata:
   name: axonserver
   labels:
     app: axonserver
 spec:
   serviceName: axonserver
   replicas: 1
   selector:
     matchLabels:
       app: axonserver
   template:
     metadata:
       labels:
         app: axonserver
     spec:
       containers:
         - name: axonserver
           image: axoniq/axonserver
           imagePullPolicy: Always
         - name: grpc
           containerPort: 8124
           protocol: TCP
         - name: gui
           containerPort: 8024
           protocol: TCP
</code></pre>

<p>The ports your defined in:</p>

<pre><code>       ports:
         - name: command-srv
           containerPort: 8081
           protocol: TCP
         - name: query-srv
           containerPort: 8082
           protocol: TCP 
</code></pre>

<p>are not ports of Axon Server, but of your <code>command-service</code> and <code>query-service</code> and should be exposed in those containers.</p>

<p>Kind regards,</p>

<p>Simon</p>
