Namespaces are used to separate resources into logical groups. They also impact how internal DNS works.
At Boot.dev, we have all of our production backend services in a namespace, let's pretend it's called "backend". Each time I use kubectl to work with the backend services, I have to specify the namespace:
kubectl -n backend get pods
Kubernetes makes it really easy for pods to communicate with each other. It does this by automatically creating DNS entries for each service. The format is:
<service-name>.<namespace>.svc.cluster.local
In reality, the .svc.cluster.local isn't needed in most scenarios. If you just use http://<service-name>.<namespace> for the api->crawler communication, it will work. When working in the same namespace, you can even just use http://<service-name>. That wouldn't work for us in our scenario just because the crawler is in its own separate namespace.
Unless a service really needs to be made available to the outside world, it's better to keep it internal to the cluster. Internal communications are great because:
The architecture of SynergyChat is a good example of this. We expose a single JSON API to the outside world, and if the pod that serves those HTTP requests doesn't have all the info it needs locally, it makes internal HTTP requests to other services.