<p>I created a small java application launching manually a jetty server listening to the address 127.0.0.1 port 8081. 
The small server app listens for <code>GET</code> requests to the subaddress /dockerClient/ping, and answers "pong".</p>

<p>I test with SoapUI on <code>http://127.0.0.1:8081/dockerClient/ping</code>, and I get my pong.</p>

<p>I create a docker image, deploy the application on minikube and expose a service with the following configuration:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: client
labels:
  tier: frontend
spec:
   replicas: 1
   selector:
      matchLabels:
      tier: frontend
   template:
      metadata:
       labels:
         tier: frontend
      spec:
        containers:
        - name: docker-client
          image: docker-client
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 8081
---
apiVersion: v1
kind: Service
metadata:
  name: client-service
  labels:
    tier: frontend
spec:
  type: NodePort
  ports:
  - port: 8081
    protocol: TCP
    name: http
  selector:
    tier: frontend
</code></pre>

<p>Once I deploy and expose, I get the following information:</p>

<pre><code>NAME             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
client-service   NodePort    10.107.64.238   &lt;none&gt;        8081:31703/TCP   19m
</code></pre>

<p>I try to use SoapUI to reach the service :
For this, I retrieve the IP of the minikube using :</p>

<pre><code>echo $(minikupe ip)
</code></pre>

<p>Then, I try a <code>GET</code> request to <code>http://$(minikube ip):31703/dockerClient/ping</code>, but the request is refused.</p>

<p>I tried on <code>http://$(minikube ip):8081/dockerClient/ping</code>, same.</p>

<p>What do I do wrong? How can I reach the jetty server exposing my ping?</p>

Joel
<p>In your service yml, you just tell the port (it can only be used within the cluster), it is not enough to expose your service outside your minikube, you also need to specify the targetPort (should match the container port e.g.8081) and nodePort (it is the port you can ping from localhost e.g. 31081).</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: client-service
  labels:
    tier: frontend
spec:
  type: NodePort
  ports:
  - port: 8081 # access within the cluster
    targetPort: 8081 # should match to the container port
    nodePort: 31081 # expose outside the cluster and range from 30000 to 32767
    protocol: TCP
    name: http
  selector:
    tier: frontend
</code></pre>

<p>After you added the targetPort and nodePort, you can get the public endpoint by:</p>

<pre><code>minikube service client-service --url
</code></pre>

<p>P.S. nodePort is optional, minikube would assign an random port from the range if nodePort has not been specified.</p>
