<p>I've been looking for a similar question for a while but I haven't found one. I have a remote Kubernetes cluster with the architecture of one master and two workers. The versions installed are as following:
Kubernetes: 1.15.1-0
Docker: 18.09.1-3.el7
I'm trying to deploy &amp; expose a JAR file of Spring project that has one REST endpoint.</p>
<p>Deployment.yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: microservices-deployment
  labels:
    app: microservices-deployment
spec:
  replicas: 3
  template:
    metadata:
      name: microservices-deployment
      labels:
        app: microservices-deployment
    spec:
      containers:
        - name: microservices-deployment
          image: **my_repo**/*repo_name*:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8085
      restartPolicy: Always
  selector:
    matchLabels:
      app: microservices-deployment
</code></pre>
<p>service.yaml:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: microservices-service
spec:
  selector:
    app: microservices-deployment
  ports:
    - port: 8085
      targetPort: 8085
  type: NodePort
</code></pre>
<p>my application.properties:</p>
<pre><code>server.port=8085
</code></pre>
<p>Dockerfile:</p>
<pre><code>FROM openjdk:8
ADD target/microservices.jar microservices.jar
EXPOSE 8085
ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;microservices.jar&quot;]
</code></pre>
<p>It looks like my pods are ready and everything looks good, but I can't access the service I exposed even from the master's terminal.
Does anyone have any idea?
Thanks in advance.</p>
<p><em><strong>UPDATE</strong></em></p>
<p>I'm able to telnet from my master to port 30000 on my nodes (after I specified 30000 as my NodePort), as well as telnet to my pods on port 8085. When I'm trying to telnet from the master to any other port in the nodes\pods I get refuse, so I think that's a good start. Still, I'm unable to access the rest endpoint I specified although it is working on Docker locally:
docker run -p 8085:8085 <em>IMAGE_NAME</em></p>

<p>The problem was a network problem. Accessing the endpoint from one of the workers did the trick. Thanks for all.</p>
