<p>Can someone please help me complete this scenario as I have everything running successfully but with no end result as expected. I have a PostgreSQL database and Redis (back-end) Pods along with a front-end API application that I will be using to send API requests. Unfortunately, after setting up everything and making sure they are all running on the Kubernetes dashboard, when sending an API request there is nothing happening as if there is no connection between my services. Before desperately posting here I did some research to find a solution to this problem, I tried this tutorial of using a <a href="https://shinesolutions.com/2018/10/25/deploying-a-full-stack-application-to-google-kubernetes-engine/" rel="nofollow noreferrer">ingress-service</a> to connect my services but did not work. I also came across this <a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/" rel="nofollow noreferrer">tutorial</a> that will connect my back-end service to my front-end service using some sort of upstream configuration file but it did not do the trick.</p>
<p>Here is my YAML configuration files if anyone is interested:</p>
<blockquote>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
   name: dictionary-project
   labels:
     app: net
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dictionary
      tier: frontend
  template:
    metadata:
      labels:
        app: dictionary
        tier: frontend
    spec:
       hostNetwork: true
       containers:
       - name: dictionaryapi
         image: amin/dictionary_server_api:latest
         ports:
         - containerPort: 400
</code></pre>
<hr />
<pre><code>apiVersion: v1
kind: Service
metadata:
   name: dictionary-service
   labels:
     app: net
spec:
  selector:
      app: dictionary
      tier: frontend
  type: NodePort 
  ports:
  - nodePort: 31003
    port: 67
    targetPort: 400
    protocol: TCP
</code></pre>
<hr />
<pre><code>apiVersion: v1
kind: Service
metadata:
    name: postgrebackendservice
    labels:
       run: backend
spec:
 selector:
      app: postgres
      tier: backend
 type: ClusterIP
 ports:
    - port: 5432
      targetPort: 5432
      name: postgresdb
</code></pre>
<hr />
<pre><code>apiVersion: v1
kind: Service
metadata:
    name: reddisbackendservice
    labels:
        run: backend
spec:
  selector:
      app: reddis
      tier: backend
  type: ClusterIP
  ports:
  - port: 6379
    targetPort: 6379
    name: client
  - port: 16379
    targetPort: 16379
    name: gossip
</code></pre>
</blockquote>
<p>Output of all services:</p>
<pre><code>Name:                     dictionary-service
Namespace:                default
Labels:                   app=net
Annotations:              &lt;none&gt;
Selector:                 app=dictionary,tier=frontend
Type:                     NodePort
IP:                       10.126.146.18
Port:                     &lt;unset&gt;  67/TCP
TargetPort:               400/TCP
NodePort:                 &lt;unset&gt;  31003/TCP
Endpoints:                192.168.x.x:400
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;

Name:              postgrebackendservice
Namespace:         default
Labels:            run=backend
Annotations:       Selector:  app=postgres,tier=backend
Type:              ClusterIP
IP:                10.182.374.13
Port:              postgresdb  5432/TCP
TargetPort:        5432/TCP
Endpoints:         192.168.x.x:5432
Session Affinity:  None
Events:            &lt;none&gt;

Name:              reddisbackendservice
Namespace:         default
Labels:            run=backend
Annotations:       Selector:  app=reddis,tier=backend
Type:              ClusterIP
IP:                10.182.0.60
Port:              client  6379/TCP
TargetPort:        6379/TCP
Endpoints:         192.168.x.x:6379
Port:              gossip  16379/TCP
TargetPort:        16379/TCP
Endpoints:         192.168.x.x:16379
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>
<p>I am testing my front-end API application on a web browser by sending a http://{workernodeIP}:31003/swagger but the page is not loading due to no connection to the server.</p>
<h3>Cluster information:</h3>
<pre><code>Kubernetes version: v1.18.6
Environment being used: bare-metal, 1 VM Master Node and 1 VM Worker Node
Installation method: kubeadm
Host OS: Ubuntu 18.04
CNI and version: calico
CRI and version: Docker 19.03.6
</code></pre>

amin
<p>From the docs <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core" rel="nofollow noreferrer">here</a></p>
<blockquote>
<p><strong>containerPort</strong>:
List of ports to expose from the container. <strong>Exposing a port here gives
the system additional information about the network connections a
container uses, but is primarily informational</strong>. Not specifying a port
here DOES NOT prevent that port from being exposed. Any port which is
listening on the default &quot;0.0.0.0&quot; address inside a container will be
accessible from the network. Cannot be updated.</p>
</blockquote>
<p>As you can see <code>containerPort</code> is information and does not make the app listen on that port. For really making the app listen on port <code>400</code> you need change port in code.</p>
