<p>I'm following the spring and kubernetes integration tutorial:</p>

<p><a href="https://spring.io/guides/gs/spring-boot-kubernetes/" rel="nofollow noreferrer">https://spring.io/guides/gs/spring-boot-kubernetes/</a></p>

<p>In my current scenario, I have 1 master and 2 workers servers.</p>

<p>When I deploy the file below using the command <code>kubectl apply -f deployment.yaml</code>, I can make a request from within the master server using <code>kubectl port-forward svc/demo 8080:8080</code> and <code>curl localhost:8080/actuator/health</code>.</p>

<p>What I want to do is an external request (a public computer - my computer) to access the service that I created (<code>kubernetes_master_ip:8080/actuator</code>), but when I try this, I get "connection refused".</p>

<p>What is missing?</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: demo
  name: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: demo
    spec:
      containers:
      - image: springguides/demo
        name: demo
        resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: demo
  name: demo
spec:
  ports:
  - name: 8080-8080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: demo
  type: ClusterIP
status:
  loadBalancer: {}
</code></pre>

<p>You need to change the type of service to expose the application. There are two ways:
- LoadBalancer type: (Only on cloud providers)
- NodePort type: Can be done on-premise or minikube.</p>

<p>Change your service yaml to below:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: demo
  name: demo
spec:
  ports:
  - name: 8080-8080
    port: 8080
    nodePort: 31234
    protocol: TCP
    targetPort: 8080
  selector:
    app: demo
  type: NodePort
</code></pre>

<p>Once the service is executed. check the application Node IP on which container is created.</p>

<pre><code>kubectl get pods -o wide
</code></pre>

<p>then try to access the application at:
<a href="http://node_ip:31234/actuator" rel="nofollow noreferrer">http://node_ip:31234/actuator</a></p>
