Generic Query about Node port and Cluster IP services

Hi All,
I am doing my CKA course and I have a generic query about the following scenario.

In case we have two nodes Node-A and Node-B
The web app containers running are on Node-A
While, the Db-Containers are running on Node-B

If the Web app-containers need access to the Db-Containers, would they make use of the cluster IP service or Node port service to access the Db-Containers.
What would be the work flow in this case.

The types of service you can create are

  • ClusterIP - This allows access between workloads inside the cluster, and is the type you need for what you describe above
  • NodePort - Makes the service accessible from outside the cluster so you can e.g. browse to a service that has a web UI.
  • LoadBalancer - Also makes the service visible from outside the cluster, but generally requires you to be running the cluster in cloud like AWS as this type of service causes a cloud load balancer to be created.

So

  • The DB containers need a ClusterIP service for the web app to get to the database
  • The web app containers would need a NodePort service so you can browse it.