<p>I am using Docker Desktop on windows 10. And I generate kubernetes NodePort Service to access from client web browser (<a href="http://10.110.201.24:30008/hello/praveen" rel="nofollow noreferrer">http://10.110.201.24:30008/hello/praveen</a>) but service is not accessible.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  selector:
    matchLabels:
      run: spring-app
  replicas: 1
  template:
    metadata:
      labels:
        run: spring-app
    spec:
      containers:
        - name: spring-boot
          image: praveen1233/spring-boot:v1
          ports:
            - containerPort: 80
</code></pre>

<p>service </p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: service
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30008
</code></pre>

<p>DockerFile </p>

<pre><code>FROM openjdk:8u212-jdk-slim
LABEL maintainer="praveen.ambati33@gmail.com"
VOLUME /tmp
EXPOSE 5001
ARG JAR_FILE=target/spring-boot-app.jar
ADD ${JAR_FILE} spring-boot-app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/spring-boot-app.jar"]
</code></pre>

<p>I have wrote simple web based spring boot application as below </p>

<pre><code>@RestController
public class HelloController {
    @GetMapping( value = "hello/{input}")
    public String getMessage(@PathVariable String input){
        return "Hi "+input;
    }
}
</code></pre>

<p>application.properties</p>

<pre><code>server.port=5000
</code></pre>

<p>I could see everything looks good in terms of Deployment, Pod and Services status. However I am not able to access the application. </p>

<pre><code>kubectl get all
NAME                            READY   STATUS             RESTARTS   AGE
pod/my-app-7b77675f79-wwbfl     1/1     Running            0          32m

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/kubernetes   ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP        6d1h
service/service      NodePort    10.110.201.24   &lt;none&gt;        80:30008/TCP   23m

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/my-app     1/1     1            1           32m

NAME                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/my-app-7b77675f79     1         1         1       32m
</code></pre>

<p>I am guessing their could be different way of accessing ip in Docker Hub which I am not able figure it out! Could you please help. Appreciated !</p>

<p>Docker and k8s versions as below </p>

<pre><code>Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
</code></pre>

Uday Kiran
<p>Your port setting is not straight.</p>

<p>You have port 80 in deployment yml, 5001 in DockerFile and 5000 in application properties. They should match.</p>

<p><strong>Update</strong></p>

<p>The other problem is that your Service doesn't have a selector. So the Service doesn't know to which pod the traffic should be routed.</p>

<pre><code>spec:
  type: NodePort
  ports:
    - port: 5000
      targetPort: 5000
      nodePort: 30008
  selector:
    app: my-app
</code></pre>

<p>The Deploment has to have a corresponding label.</p>

<pre><code>metadata:
  name: my-app-v1
  labels:
    app: my-app
    version: v1
</code></pre>
