Kubernetes ERR_NAME_NOT_RESOLVED

7/25/2019

I have two deployments, one for backend and one for frontend and two services for them. Frontend Service is set as a LoadBalancer and it is exposed as expected(using minikube tunnel). Backend service shouldnt be exposed outside of the cluster, therefore I didnt set any type of service(default is ClusterIP which is available only within a cluster). Now I would like to make calls from frontend to backend. When I type

kubectl exec -it FRONT_END_POD_NAME -- /bin/sh

And then use curl I can get all resources which I expect, however, when I open my website application which fetches the same resource as I type in curl, there is an error in console net::ERR_NAME_NOT_RESOLVED. Do You have any idea why is that happening, even when I am able to curl it from my frontend and everything works? How to fix it?

apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-deployment
  labels:
    app: backend
spec:
  selector:
    matchLabels:
      app: backend
  replicas: 1
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend
          image: ajris/site_backend:pr-kubernetes
          ports:
            - containerPort: 8080
====
apiVersion: v1
kind: Service
metadata:
  name: backend-service
  labels:
    app: backend
spec:
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 8081
      targetPort: 8080
===
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend-deployment
  labels:
    app: frontend
spec:
  selector:
    matchLabels:
      app: frontend
  replicas: 1
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
        - name: frontend
          image: ajris/site_frontend:travis-66
          ports:
            - containerPort: 3000
          imagePullPolicy: Always
===
apiVersion: v1
kind: Service
metadata:
  name: frontend-service
  labels:
    app: frontend
spec:
  ports:
    - protocol: TCP
      port: 3001
      targetPort: 3000
  selector:
    app: frontend
  type: LoadBalancer
-- Ajris
kubectl
kubernetes
minikube

0 Answers