<p>I try to spin up a small kubernetes cluster consisting of just a frontend and a backend, but I can't get it to work. My main problem is that my frontend cannot find my backend through the defined service. What am I missing here? Maybe it's worth to mention that I work with minikube.</p>
<p>frontend</p>
<pre><code>useEffect(() =&gt; {
async function fetchData() {
  try {
    const result = await axios.get(&quot;http://simplebackend-service:8080/&quot;);
    setData(result.data);
  } catch (error) {
    console.log(error);
  }
}

fetchData();
  }, []);
</code></pre>
<p>backend</p>
<pre><code>const express = require(&quot;express&quot;);
const app = express();
const port = 8080;
var cors = require(&quot;cors&quot;);

app.use(cors());

app.get(&quot;/&quot;, (req, res) =&gt; {
  res.send({
    hey: &quot;hello my friend&quot;,
  });
});

app.listen(port, () =&gt; {
  console.log(`Example app listening at http://localhost:${port}`);
});
</code></pre>
<p>simple-frontend.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: simplefrontend-deployment
  labels:
    app: simplefrontend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: simplefrontend
  template:
    metadata:
      labels:
        app: simplefrontend
    spec:
      containers:
        - name: simplefrontend
          image: image
          ports:
            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: simplefrontend-service
spec:
  type: NodePort
  selector:
    app: simplefrontend
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
      nodePort: 30100
</code></pre>
<p>simple-backend.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: simplebackend-deployment
  labels:
    app: simplebackend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: simplebackend
  template:
    metadata:
      labels:
        app: simplebackend
    spec:
      containers:
        - name: simplebackend
          image: image
          ports:
            - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: simplebackend-service
spec:
  selector:
    app: simplebackend
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
</code></pre>
<p>after I have applied the deployments and services with the command <code>kubectl apply -f ...</code> to the cluster, I create a tunnel to the frontend using the <code>minikube service simplefrontend-service</code> command. There I get the error net::ERR_NAME_NOT_RESOLVED displayed. Why is that not working, What am I missing here?</p>

quinzo    
<p>There are multiple issues with the manifest and the application config.</p>
<pre><code>await axios.get(&quot;http://simplebackend-service/&quot;);
</code></pre>
<p>it should specify backend port and namespace (if running in a different namespace) i.e <code>SERVICENAME.NAMESPACE:SERVICE_PORT</code></p>
<pre><code>await axios.get(&quot;http://simplebackend-service:SERVICE_PORT/&quot;);
</code></pre>
<p>Backend service should be pointing to right port</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: simplebackend-service
spec:
  selector:
    app: simplebackend
  ports:
    - protocol: TCP
      port: 27017
      targetPort: 8080
</code></pre>
<p><code>targetport</code> should be <code>8080</code> as the backend listening on port <code>8080</code></p>
