<p>Following is my application deployment yaml file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: sharemarket-crud-deployment
spec:
  selector:
    matchLabels:
      app: sharemarket-k8s-sb-service
  replicas: 2
  template:
    metadata:
      labels:
        app: sharemarket-k8s-sb-service
    spec:
      containers:
        - name: sharemarket-k8s-sb-service-container
          image: joy999/shareserviceproj:release06
          ports:
            - containerPort: 8080
          env:   # Setting Enviornmental Variables
            - name: DB_HOST   # Setting Database host address from configMap
              valueFrom :
                configMapKeyRef :
                  name : db-config
                  key :  host

            - name: DB_NAME  # Setting Database name from configMap
              valueFrom :
                configMapKeyRef :
                  name : db-config
                  key :  dbName

            - name: DB_USERNAME  # Setting Database username from Secret
              valueFrom :
                secretKeyRef :
                  name : mysql-secrets
                  key :  username

            - name: DB_PASSWORD # Setting Database password from Secret
              valueFrom :
                secretKeyRef :
                  name : mysql-secrets
                  key :  password

---

apiVersion: v1 # Kubernetes API version
kind: Service # Kubernetes resource kind we are creating
metadata: # Metadata of the resource kind we are creating
  name: springboot-sb-service-svc
spec:
  selector:
    app: springboot-k8s-sb-service
  ports:
    - protocol: &quot;TCP&quot;
      port: 8080 # The port that the service is running on in the cluster
      targetPort: 8080 # The port exposed by the service
  type: NodePort # type of the service.
</code></pre>
<p>I can see pods are created successfully, services are also good. Database is also good with table created.</p>
<p><a href="https://i.stack.imgur.com/OURng.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OURng.jpg" alt="enter image description here" /></a></p>
<p>The exposed port service shows as 30119 but if I POST or GET the request from postman, I am getting fallowing error all the time:</p>
<p>POST <a href="http://192.168.99.100:30119/stock" rel="nofollow noreferrer">http://192.168.99.100:30119/stock</a>
Error: connect ETIMEDOUT 192.168.99.100:30119</p>
<p>GET <a href="http://192.168.99.100:30119/stock/1" rel="nofollow noreferrer">http://192.168.99.100:30119/stock/1</a>
Error: connect ETIMEDOUT 192.168.99.100:30119</p>
<p>Can anyone please help to troubleshoot the issue.</p>

user2746466
<p>You need to expose the NodePort PORT as well, so you can reach this service from outside the cluster. Your GET request tries to reach port 30119, but you only exposed 8080, make sure to expose 30119</p>
<pre><code>type: NodePort
ports:
 port: 8080
 TargetPort: 8080
 nodePort: 30119
</code></pre>
<p>Another way for you is a load balancer, and use the end point.</p>
<pre><code>Kubectl get endpoints -A
</code></pre>
