<p>Any help will be appreciated.</p>

<p>I'm trying to send a request from pod to pod inside a k8s cluster in the same namespace running on AWS.</p>

<p>I've added a pod that serves requests coming from port 5000,
from within the pod I manage to run a curl command successfully:</p>

<pre><code>curl -i \
  --header "Content-Type: application/json" \
  --request POST \
  --data '[[5.1, 3.5, 1.4, 0.2]]' \
  localhost:5000/predict
</code></pre>

<p>I've added a service to the pod to expose an endpoint so I can send traffic to it:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
  name: sklearn-iris-bentoml-deployment-sklearn-iris-example
  namespace: bentoml
  ownerReferences:
  selfLink: /api/v1/namespaces/bentoml/services/sklearn-iris-bentoml-deployment-sklearn-iris-example
  labels:
    run: my-bentoml
spec:
  ports:
  - name: http
    port: 5000
    protocol: TCP
    targetPort: 5000
  selector:
    run: my-bentoml
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
</code></pre>

<p>The service:</p>

<pre><code>➜ kubectl get svc -n bentoml
NAME                                                   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
sklearn-iris-bentoml-deployment-sklearn-iris-example   ClusterIP   10.110.5.245   &lt;none&gt;        5000/TCP   5h6m
</code></pre>

<p>The endpoint:</p>

<pre><code>➜ k get endpoints sklearn-iris-bentoml-deployment-sklearn-iris-example -n bentoml
NAME                                                   ENDPOINTS             AGE
sklearn-iris-bentoml-deployment-sklearn-iris-example   10.110.115.108:5000   5h6m
</code></pre>

<p>When I try to connect through telnet from a different pod in the same namespace, it fails:</p>

<pre><code>root@my-shell:/# telnet 10.110.115.108 5000
Trying 10.110.115.108...
telnet: Unable to connect to remote host: Connection refused
</code></pre>

<p>I'm not sure whether I should configure a DNS since I don't have intentions to send traffic from outside the cluster so the network is mainly focused inside the cluster</p>

torpido
<p>Make sure the the application pod is listening on <code>0.0.0.0</code> instead of <code>127.0.0.1</code> or <code>localhost</code>. This can typically be changed in the code of the application and depends on the language of the application.</p>
