<p>I am using minikube on windows 10. And I generate kubernetes NodePort Service to access from client web browser. First the below codes are resources configuration file.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: blog-system 
  labels:
    app: blog-pod 
spec:
  containers:
  - name: blog-app
    image: app:latest 
    imagePullPolicy: Never 
    ports:
      - containerPort: 8080
    args: ["-t", "-i"]
  - name: blog-mysql
    image: mysql:latest 
    env:
      - name: MYSQL_ROOT_PASSWORD
        value: password
      - name: MYSQL_PASSWORD
        value: password
      - name: MYSQL_DATABASE
        value: test
    ports:
      - containerPort: 3306

---
apiVersion: v1
kind: Service
metadata:
  name: blog-app-svc
spec:
  type: NodePort   
  selector:
    app: blog-pod  
  ports:
  - name: http
    port: 8080
    protocol: TCP
    targetPort: 80
    nodePort: 31000
</code></pre>

<p>The Kubernetes pods and services are generated successfully.</p>

<pre><code>&gt; kubectl get services
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
blog-app-svc   NodePort    10.100.32.119   &lt;none&gt;        8080:31000/TCP   79s
kubernetes     ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP          5m54s

&gt; minikube service blog-app-svc --url
http://192.168.5.25:31000
</code></pre>

<p>However the access to this kubernetes nodeport service is rejected even with all of these urls.</p>

<pre><code>http://10.100.32.119:31000
http://10.100.32.119:8080
http://192.168.5.25:31000
</code></pre>

<p>I have no idea where the errors are on the resources configuration file, service part or pod part. Any idea, please.</p>

Joseph Hwang
<p>The <code>targetPort</code> of your Service doesn't match the <code>containerPort</code> of your Pod.</p>

<p>Your Service declaration says that <code>nodePort</code> 31000 on any node in the cluster, or <code>port</code> 8080 on the special host name <code>blog-app-svc.default.svc.cluster.local</code> within the cluster, forwards to <code>targetPort</code> 80 in some pod with an <code>app: blog-pod</code> label.  You have that pod, but it's listening to ports 8080 and 3306 and not port 80.</p>

<p>If you swap <code>port</code> and <code>targetPort</code> then the default HTTP port 80 on the Service will forward to port 8080 in your pod, which is probably what you're after.</p>
