can not access to service in postman

1/17/2021

i create a image of my project in nodejs .

i write Development yaml :

apiVersion: apps/v1
kind: Deployment
metadata:
  name: user-depl
  labels:
    app: user-depl
spec:
  replicas: 3
  selector:
    matchLabels:
      app: user-pod
      departemant: user
  template:
      metadata: 
        labels: 
          app: user-pod
          departemant: user
      spec:
        containers: 
          - name : user-pod
            image: kia9372/store-user
            ports:
             - containerPort: 4000

and create a Services :

apiVersion: v1
kind: Service
metadata:
  name: user-service
  labels:
    app: user-service
spec:
  selector:
    app: user-pod
  ports:
    - name: user 
      protocol: TCP
      port: 4000
      targetPort: 4000

and when i run this command kubectl get services it show me this :

user-service ClusterIP 10.109.72.253 <none> 4000/TCP 36m

and when i send request to this service in postman it not show me any thing .

https://10.109.72.253:4000/user

it show me this error :

Error: connect ETIMEDOUT 10.109.72.253:4000

whats the problem ? how can i solve this problem ???

-- Mr-Programer
kubectl
kubernetes

1 Answer

1/17/2021
  • Your service is not of type load balancer so you will not be able to access it.
  • Since you did not specify any other type ClusterIP is the default for the Service.

ClusterIP

Exposes the Service on a cluster-internal IP.
Choosing this value makes the Service only reachable from within the cluster

Here is a sample code on how to access it using NoodePort/ClusterIP https://github.com/nirgeier/KubernetesLabs/tree/master/Labs/05-Services


enter image description here Img source: https://medium.com/avmconsulting-blog/service-types-in-kubernetes-24a1587677d6

-- CodeWizard
Source: StackOverflow