<p>I have deployed a mongo db, Spring Boot BE, Angular app within GKE. My FE service is a load balancer, it needs to connect with my BE to get data but I'm getting an console error in my browser: <strong>GET <a href="http://contactbe.default.svc.cluster.local/contacts" rel="nofollow noreferrer">http://contactbe.default.svc.cluster.local/contacts</a> net::ERR_NAME_NOT_RESOLVED</strong>. My FE needs to consume <em>/contacts</em> endpoint to get data. I'm using DNS from my BE service (contactbe.default.svc.cluster.local) within my Angular app. It is my yml file that I used to create my deployment:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mongo
  labels:
    run: mongo
spec:
  type: NodePort
  ports:
  - port: 27017
    targetPort: 27017
    protocol: TCP
  selector:
    run: mongo
---
apiVersion: apps/v1beta1
kind: Deployment
metadata: 
  name: mongo
spec:
  template:
    metadata:
      labels:
        run: mongo
    spec:
      containers:
      - name: mongo
        image: mongo
        ports:
        - containerPort: 27017
---        
apiVersion: v1
kind: Service
metadata:
  name: contactbe
  labels:
    app: contactbe
spec:
  type: NodePort 
  ports:
  - port: 8181
    targetPort: 8181
    protocol: TCP
  selector:
    app: contactbe
---
apiVersion: apps/v1beta1
kind: Deployment
metadata: 
  name: contactbe
spec:
  template:
    metadata:
      labels:
        app: contactbe
    spec:
      containers:
      - name: contactbe
        image: glgelopfalcon/k8s_contactbe:latest
        ports:
        - containerPort: 8181
---
apiVersion: apps/v1beta1 # for versions before 1.9.0 use apps/v1beta2 
kind: Deployment 
metadata: 
  name: angular-deployment 
spec: 
  selector: 
    matchLabels: 
      app: angular 
  replicas: 2 # tells deployment to run 2 pods matching the template 
  template: 
    metadata: 
      labels: 
        app: angular 
    spec: 
      containers: 
      - name: angular 
        image: glgelopfalcon/my-angular-app:latest 
        ports: 
        - containerPort: 80
--- 
# https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service  
kind: Service 
apiVersion: v1 
metadata: 
  name: angular-service 
spec: 
  selector: 
    app: angular 
  ports: 
  - port: 80
    targetPort: 80
    protocol: TCP
  type: LoadBalancer 
</code></pre>

<p>I googled a lot but I still have not found how to solve this problem. I would appreciate if someone could give a hand. </p>

<p><a href="https://i.stack.imgur.com/O2aBS.png" rel="nofollow noreferrer">Console error</a></p>

user3380193
<p>check for your load balancer having open port 27017 as your sending request to port 27017</p>

<p>otherwise you can change service node port to 80 and target port will be same</p>
