<p>I configure my services with type ClusterIP. And I want to make them communicated.</p>

<h1>Service</h1>

<pre><code>apiVersion: v1
kind: Service
metadata:
 labels:
  app: app-backend-deployment
 name: app-backend
spec:
 type: ClusterIP
 ports:
 - port: 8020
   protocol: TCP
   targetPort: 8100
 selector:
  app: app-backend
</code></pre>

<h1>Deployment</h1>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
 labels:
  app: app-backend
 name: app-backend-deployment
spec:
 replicas: 1
 selector:
    matchLabels:
      app: app-backend
 template:
    metadata:
      labels:
        app: app-backend
    spec:
     containers:
     - name: app-backend
       image: app-backend
       ports:
       - containerPort: 8100
       imagePullPolicy: Never
</code></pre>

<h1>ConfigMap</h1>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: backend-conf # name of configMap
data:
  BACKEND_SERVICE_HOST: app-backend:8020
</code></pre>

<p>And that is what I pass to the frontend service, and I want to make a REST call through the DNS name for example <a href="http://app-backend:8020/get/1" rel="nofollow noreferrer">http://app-backend:8020/get/1</a>. But like I see in the console app cannot resolve DNS name <code>net::ERR_NAME_NOT_RESOLVED</code>.</p>

<p>I also check pod nslookup:</p>

<pre><code>busybox nslookup app-backend.default.svc.cluster.local
Server:         10.96.0.10
Address:        10.96.0.10:53

Name:   app-backend.default.svc.cluster.local
Address: 10.106.41.36
</code></pre>

<p>And compare it to </p>

<pre><code>kubectl describe svc app-backend
Name:              app-backend
Namespace:         default
Labels:            app=app-backend-deployment
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"...
Selector:          app=app-backend
Type:              ClusterIP
IP:                10.106.41.36
Port:              &lt;unset&gt;  8020/TCP
TargetPort:        8100/TCP
</code></pre>

<p>And like you can see there is the same IP on Address but I don't know and where to look what is wrong why dns resolver doesn't work.  <code>kubectl version Client "v1.15.5", Server Version:"v1.17.3",</code></p>

Adriano
<p>Because of that frontend service that was served to the local machine (that how Angular works) REST request cannot go through Kubernetes DNS with another backend service. I need to communicate them through the Ingress. Due to different annotations, I have to use 2 Ingress. Meaby there is a better way to use just one, but when I want to use only one Ingress I can't find a way to make them both working, with the same annotation.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 annotations:
  kubernetes.io/ingress.class: nginx
  nginx.ingress.kubernetes.io/rewrite-target: /$2
 name: app-backend-ingress
spec:
 rules:
 - host: app.io
   http:
     paths:
       - path: /api(/|$)(.*)
         backend:
          serviceName: app-backend
          servicePort: 8020
---  
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 annotations:
  kubernetes.io/ingress.class: nginx
  nginx.ingress.kubernetes.io/rewrite-target: /
 name: app-frontend-ingress
spec:
 rules:
 - host: app.io
   http:
     paths:
       - path: /
         backend:
          serviceName: app-frontend
          servicePort: 80
</code></pre>
