<p>I'm looking to use Kubernetes DNS to requetes pods from pods. All is in my Kubernetes cluster.</p>

<p>I would like to use a http requeste from a web app to call another web app </p>

<p>For exemple I would like to call ProductWebApp from DashboardWebApp</p>

<p>I found kubernetes rest api</p>

<p>➜  ~ kubectl exec -it dashboard-57f598dd76-54s2x -- /bin/bash</p>

<p>➜  ~ curl -X GET <a href="https://4B3449144A41F5488D670E69D41222D.sk1.us-east-1.eks.amazonaws.com/api/v1/namespaces/staging/services/product-app/proxy/api/product/5bf42b2ca5fc050616640dc6" rel="nofollow noreferrer">https://4B3449144A41F5488D670E69D41222D.sk1.us-east-1.eks.amazonaws.com/api/v1/namespaces/staging/services/product-app/proxy/api/product/5bf42b2ca5fc050616640dc6</a> 
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {</p>

<p>},
  "status": "Failure",
  "message": "services \"product-app\" is forbidden: User \"system:anonymous\" cannot get services/proxy in the namespace \"staging\"",
  "reason": "Forbidden",
  "details": {
    "name": "product-app",
    "kind": "services"
  },
  "code": 403
}%        </p>

<p>I don't understand why it's block</p>

<p>I found also this url<br>
➜  ~ curl -XGET product-app.staging.svc.cluster.local/api/product/5bf42b2ca5fc050616640dc6</p>

<p>But it's also not work </p>

<p>So what is the good way to make a call from a pod to service ?</p>

Maryo
<p>For when <em>both</em> ProductWebApp and DashboardWebApp are running on the <em>same</em> Kubernetes cluster:</p>

<p>Define a Service as described <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="noreferrer">here</a> for the app that you want to call (ProductWebApp) using <code>type: ClusterIP</code> service; configure the calling app (DashboardWebApp) with the service name as the URI to call.</p>

<p>For example, assuming ProductWebApp is in a namespace named <code>staging</code>, define a service named <code>product-app</code> for the ProductWebApp deployment and then configure the DashboardWebApp to call ProductWebApp at this URI:</p>

<pre><code>http://product-app.staging.svc.cluster.local/end/point/as/needed
</code></pre>

<p>Replace http with https if the ProductWebApp endpoint requires it. Notice that a Service name can be the same as the name of the Deployment for which the service is.</p>

<p>This works when the Kubernetes cluster is running a DNS service (and most clusters do) - see this <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="noreferrer">link</a> and specifically the <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#a-records" rel="noreferrer">A records</a> section.</p>
