Can't communicate from one pod to other pod with a service

3/20/2020

I have two pods with the following configuration:

POD 1 YAML FILE:

apiVersion: apps/v1
kind: Deployment
metadata:
 name: pmplab-nginx-deployment
 labels:
  service: pmplab-nginx-service
spec:
 selector:
  matchLabels:
   app: pmplab-nginx
 template:
  metadata:
   labels:
    app: pmplab-nginx
  spec:
   containers:
    - image: nginx-pmplab-kubernetes
      name: pmplab-nginx
      imagePullPolicy: IfNotPresent
      ports:
       - containerPort: 80

POD 2 YAML FILE:

apiVersion: v1
kind: Deployment
metadata:
 name: pmplab-login-deployment
 labels:
  service: pmplab-login-service
spec:
 selector:
  matchLabels:
   app: pmplab-login
 template:
  metadata:
   labels:
    app: pmplab-login-selector
  spec:
   containers:
    - image: login-pmplab-kubernetes
      name: login-pmplab
      imagePullPolicy: IfNotPresent
      ports:
       - containerPort: 10070

SERVICE YAML FILE:

apiVersion: v1
kind: Service
metadata:
 name: pmplab-login-service
 namespace: default
spec:
 selector:
  app: pmplab-login-selector
 ports:
  - name: login
    port: 10070

I want to curl POD2 from POD1.

Right now if i use the POD2 IP from the command sudo kubectl get pods -o wide --all- namespaces it works but i can't do it using the service.

I have tried:

curl pmplab-login-service:10070 -> curl: (6) Could not resolve host: pmplab_login_service

curl $(PMPLAB_LOGIN_SERVICE_HOST):10070 -> curl: (7) Failed to connect to 10.99.143.9 port 10070: Connection timed out

-- Jaume Garcia Sanchez
kubernetes

1 Answer

3/21/2020

After so much research i realized that kore-dns did not have endpoints then i restarted minikube and now everything works fine now.

-- Jaume Garcia Sanchez
Source: StackOverflow