<p>It might take a while to explain what I'm trying to do but bear with me please.</p>
<p>I have the following infrastructure specified:
<a href="https://i.stack.imgur.com/mHJcE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mHJcE.png" alt="enter image description here" /></a></p>
<p>I have a job called <code>questo-server-deployment</code> (I know, confusing but this was the only way to access the deployment without using ingress on minikube)</p>
<p>This is how the parts should talk to one another:
<a href="https://i.stack.imgur.com/pRZA8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pRZA8.png" alt="enter image description here" /></a></p>
<p>And <a href="https://github.com/matewilk/questo/pull/8/files#diff-a9b6f2819e0e34608760f562298832266b7da1a55cb004d9cdc7e2dc8c6d6e54" rel="nofollow noreferrer">here</a> you can find the entire Kubernetes/Terraform config file for the above setup</p>
<p>I have 2 endpoints exposed from the <code>node.js</code> app (<code>questo-server-deployment</code>)
I'm making the requests using <code>10.97.189.215</code> which is the <code>questo-server-service</code> external IP address (as you can see in the first picture)</p>
<p>So I have 2 endpoints:</p>
<ul>
<li>health - which simply returns <code>200 OK</code> from the <code>node.js</code> app - and this part is fine confirming the node app is working as expected.</li>
<li>dynamodb - which should be able to send a request to the <code>questo-dynamodb-deployment</code> (pod) and get a response back, but it can't.</li>
</ul>
<p>When I print env vars I'm getting the following:</p>
<pre><code>➜ kubectl -n minikube-local-ns exec questo-server-deployment--1-7ptnz -- printenv
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=questo-server-deployment--1-7ptnz
DB_DOCKER_URL=questo-dynamodb-service
DB_REGION=local
DB_SECRET_ACCESS_KEY=local
DB_TABLE_NAME=Questo
DB_ACCESS_KEY=local
QUESTO_SERVER_SERVICE_PORT_4000_TCP=tcp://10.97.189.215:4000
QUESTO_SERVER_SERVICE_PORT_4000_TCP_PORT=4000
QUESTO_DYNAMODB_SERVICE_SERVICE_PORT=8000
QUESTO_DYNAMODB_SERVICE_PORT_8000_TCP_PROTO=tcp
QUESTO_DYNAMODB_SERVICE_PORT_8000_TCP_PORT=8000
KUBERNETES_SERVICE_HOST=10.96.0.1
KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://10.96.0.1:443
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1
QUESTO_SERVER_SERVICE_SERVICE_HOST=10.97.189.215
QUESTO_SERVER_SERVICE_PORT=tcp://10.97.189.215:4000
QUESTO_SERVER_SERVICE_PORT_4000_TCP_PROTO=tcp
QUESTO_SERVER_SERVICE_PORT_4000_TCP_ADDR=10.97.189.215
KUBERNETES_PORT_443_TCP_PROTO=tcp
QUESTO_DYNAMODB_SERVICE_PORT_8000_TCP=tcp://10.107.45.125:8000
QUESTO_DYNAMODB_SERVICE_PORT_8000_TCP_ADDR=10.107.45.125
KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443
QUESTO_SERVER_SERVICE_SERVICE_PORT=4000
QUESTO_DYNAMODB_SERVICE_SERVICE_HOST=10.107.45.125
QUESTO_DYNAMODB_SERVICE_PORT=tcp://10.107.45.125:8000
KUBERNETES_SERVICE_PORT_HTTPS=443
NODE_VERSION=12.22.7
YARN_VERSION=1.22.15
HOME=/root
</code></pre>
<p>so it looks like the configuration is aware of the dynamodb address and port:</p>
<pre><code>QUESTO_DYNAMODB_SERVICE_PORT_8000_TCP=tcp://10.107.45.125:8000
</code></pre>
<p>You'll also notice in the above env variables that I specified:</p>
<pre><code>DB_DOCKER_URL=questo-dynamodb-service
</code></pre>
<p>Which is supposed to be the <code>questo-dynamodb-service</code> url:port which I'm assigning to the config <a href="https://github.com/matewilk/questo/pull/8/files#diff-a9b6f2819e0e34608760f562298832266b7da1a55cb004d9cdc7e2dc8c6d6e54R163" rel="nofollow noreferrer">here</a> (in the configmap) which is then used <a href="https://github.com/matewilk/questo/pull/8/files#diff-a9b6f2819e0e34608760f562298832266b7da1a55cb004d9cdc7e2dc8c6d6e54R67" rel="nofollow noreferrer">here</a> in the <code>questo-server-deployment</code> (job)</p>
<p>Also, when I log:</p>
<pre><code>kubectl logs -f questo-server-deployment--1-7ptnz -n minikube-local-ns
</code></pre>
<p>I'm getting the following results:</p>
<p><a href="https://i.stack.imgur.com/4Oh6s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Oh6s.png" alt="enter image description here" /></a></p>
<p>Which indicates that the app (node.js) tried to connect to the db (dynamodb) but on the wrong port <code>443</code> instead of <code>8000</code>?</p>
<p>The <code>DB_DOCKER_URL</code> should contain the full address (with port) to the <code>questo-dynamodb-service</code></p>
<p>What am I doing wrong here?</p>
<p>Edit ----</p>
<p>I've explicitly assigned the port <code>8000</code> to the <code>DB_DOCKER_URL</code> as suggested in the answer but now I'm getting the following error:
<a href="https://i.stack.imgur.com/3t7tD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3t7tD.png" alt="enter image description here" /></a></p>
<p>Seems to me there is some kind of default behaviour in Kubernetes and it tries to communicate between pods using <code>https</code> ?</p>
<p>Any ideas what needs to be done here?</p>

<p>How about specify the port in the ConfigMap:</p>
<pre><code>...
data = {
  DB_DOCKER_URL = ${kubernetes_service.questo_dynamodb_service.metadata.0.name}:8000
...
</code></pre>
<p>Otherwise it may default to 443.</p>
