<p>I have created two PODs running in my minikube environment in windows 10. One POD with Spring boot application container and another POD with mysql container. For Spring boot application POD with service type is nodePort and for MYSQL pod, service with type is clusterIP. Means Mysql pod needs to communicate inside the cluster only. But for Spring boot application needs to access from browser so i configured NodePort.</p>
<p>i configured 30096 for NodePort. But i checked in my browser (minikube ip:nodePort).Its not working. So i try to execute the command &quot;minikube service service-name&quot; and output shows one different port(59870)</p>
<p><a href="https://i.stack.imgur.com/6SHzu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6SHzu.png" alt="enter image description here" /></a></p>
<p><strong>MYSQL_DEPLOYMENT_YML:</strong></p>
<pre><code>    apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: bcp-mysql
  labels:
    app: bcp-mysql
spec:
  selector:
    matchLabels:
      app: bcp-mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: bcp-mysql
    spec:
      containers:
      - image: &lt;myrepo&gt;/mysql:5.7
        name: mysql
        env:
          - name: MYSQL_ROOT_PASSWORD
            value: password
          - name: MYSQL_DATABASE
            value: database
          - name: MYSQL_USER
            value: root
          - name: MYSQL_PASSWORD
            value: password
        ports:
        - containerPort: 3306
          name: mysql
        imagePullPolicy: Always
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
      imagePullSecrets:
        - name: regcred
---
apiVersion: v1
kind: Service
metadata:
  name: bcp-mysql
spec:
  selector:
    app: bcp-mysql
  ports:
    - port: 3306
      targetPort: 3306
  type: ClusterIP
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: bcp-mysql
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
</code></pre>
<p><strong>Spring_boot_deployment.yml:</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: bcpdashboard
  labels: 
    app: bcpdashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bcpdashboard
  template:
    metadata:
      labels:
        app: bcpdashboard
    spec:
      containers:
        - name: app
          image: &lt;myrepo&gt;/bcpdashboard:latest
          ports:
            - containerPort: 9097
          imagePullPolicy: Always
          env:
          - name: SPRING_DATASOURCE_URL
            value: jdbc:mysql://bcp-mysql:3306/bcp?autoReconnect=true&amp;useSSL=false
      imagePullSecrets:
        - name: regcred
---

apiVersion: v1  
kind: Service  
metadata:  
  name: bcpdashboard  
spec:
  selector:
    app: bcpdashboard
  ports:
    - port: 9097
      targetPort: 9097
      nodePort: 30096
  type: NodePort
---
</code></pre>
<p><a href="https://i.stack.imgur.com/eWdba.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eWdba.png" alt="enter image description here" /></a></p>
<p>My minikube ip is localhost IP only. So i try to run (<a href="http://127.0.0.1:30096" rel="nofollow noreferrer">http://127.0.0.1:30096</a>). Its not working. So i try to execute &quot;minikube service bcpdashboard&quot;</p>
<p><a href="https://i.stack.imgur.com/nD6ID.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nD6ID.png" alt="enter image description here" /></a></p>
<p>And <a href="http://127.0.0.1:59870/" rel="nofollow noreferrer">http://127.0.0.1:59870/</a> is working fine and i dont know about the port number 59870. How it is assigned automatically and start point to spring boot application POD even i configured nodeport.
<a href="https://i.stack.imgur.com/NzJvs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NzJvs.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/2LQ7Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2LQ7Z.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/6PpGD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6PpGD.png" alt="enter image description here" /></a></p>
<p>Anyone face the same issue &amp; please let me know how to make it work with nodePort and also is there any issues in deployment yaml configurations.</p>

A.S.karthick
<p>Seems like the behavior is specific to your setup of minikube, using your deployment yaml in my setup, everything functions as it's stated, i.e. only <code>curl http://127.0.0.1:30096/</code> responds w/ 200.</p>

<p>I used <a href="https://hub.docker.com/r/strm/helloworld-http/" rel="nofollow noreferrer">helloworld-http</a> as the image, and k8s 16 w/ docker-desktop 2.3. The deployment yaml looks something this:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: bcpdashboard
  labels:
    app: bcpdashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bcpdashboard
  template:
    metadata:
      labels:
        app: bcpdashboard
    spec:
      containers:
        - name: app
          image: strm/helloworld-http
          ports:
            - containerPort: 80
          imagePullPolicy: Always
          env:
          - name: SPRING_DATASOURCE_URL
            value: jdbc:mysql://bcp-mysql:3306/bcp?autoReconnect=true&amp;useSSL=false
      imagePullSecrets:
        - name: regcred
---

apiVersion: v1
kind: Service
metadata:
  name: bcpdashboard
spec:
  selector:
    app: bcpdashboard
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30096
  type: NodePort
---
</code></pre>

<p>Have you tried using <a href="https://www.docker.com/blog/docker-windows-desktop-now-kubernetes/" rel="nofollow noreferrer">docker-windows-desktop-kubernetes</a> ? You could give that a try, it will atleast isolate the problem for you.</p>
