<p>I'm running a simple spring microservice project with Minikube. I have two projects: lucky-word-client (on port 8080) and lucky-word-server (on port 8888). But I can't communicate client with server. Infact if lucky-word-client communicates with lucky-word-server, the result is the word "Evviva", else the word is "Default". When I run on terminal: <code>minikube service lucky-client</code> the output is Default, instead of Evviva.</p>

<p>This is the file Dockerfile of lucky-word-server:</p>

<pre><code>FROM frolvlad/alpine-oraclejdk8 

ADD build/libs/common-config-server-0.0.1-SNAPSHOT.jar common-config-server.jar

EXPOSE 8888

ENTRYPOINT ["/usr/bin/java", "-Xmx128m", "-Xms128m"]

CMD ["-jar", "common-config-server.jar"]
</code></pre>

<p>This is the file Dockerfile of lucky-word-client:</p>

<pre><code>FROM frolvlad/alpine-oraclejdk8 

ADD build/libs/lucky-word-client-0.0.1-SNAPSHOT.jar lucky-word-client.jar

EXPOSE 8080

ENTRYPOINT ["/usr/bin/java", "-Xmx128m", "-Xms128m"]

CMD ["-jar", "-Dspring.profiles.active=italian", "lucky-word-client.jar"]
</code></pre>

<p>This is deployment of lucky-word-server:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: lucky-server
spec:
  selector:
      matchLabels:
        app: lucky-server
  replicas: 1
  template:
    metadata:
      labels:
        app: lucky-server
    spec:
      containers:
        - name: lucky-server
          image: lucky-server-img
          imagePullPolicy: Never
          ports:
            - containerPort: 8888
</code></pre>

<p>This is the service of lucky-word-server:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: lucky-server
spec:
  selector:
    app: lucky-server
  ports:
  - protocol: TCP
    port: 8888
  type: NodePort
</code></pre>

<p>This is the deployment of lucky-word-client:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: lucky-client
spec:
  selector:
      matchLabels:
        app: lucky-client
  replicas: 1
  template:
    metadata:
      labels:
        app: lucky-client
    spec:
      containers:
        - name: lucky-client
          image: lucky-client-img
          imagePullPolicy: Never
          ports:
            - containerPort: 8080
</code></pre>

<p>This is the service of lucky-word-client:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: lucky-client
spec:
  selector:
    app: lucky-client
  ports:
  - protocol: TCP
    port: 8080
  type: NodePort
</code></pre>

Danny
<p>As @suren stated you should specify the target port in the service definition.</p>

<p>And you should change the endpoint URL of the server that client calls to reflect minikube_host_ip. There are couple of ways to achieve that. The naive method would be as follows. </p>

<p>Change your Kubernetes service for the server to have a static Nodeport as follows: </p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: lucky-server
spec:
  selector:
    app: lucky-server
  ports:
  - protocol: TCP
    port: 8080
    nodePort: 32002
  type: NodePort
</code></pre>

<p>And in your client code just change the endpoint of the server as follows: 
http://{minikube_host_ip}:32002  Replace your {minikube_host_ip} with the ip address of the minikube host here.</p>

<p>But if you don't want to hard code the minikube ip you can inject it as an environment variable in your Kuberenetes deployment script. And that environment variable should be captured in your docker file.  </p>
