Search code examples
kuberneteskubernetes-service

Kubernetes - Best way to communicate between two containers and to the outside word


I have two Kubernetes developpements: one with a Grafana pod, and the other with an InfluxDB pod.

I want:

1) to expose my Grafana:3000 to the outside word

2) Grafana to be able to connect to InfluxDB:8086

I've seen it done with two separate "services": one Grafana Service (type = NodePort, target port = 3000) and one InfluxDB service (type = ClusterIP, target port = 8086).

It works ok. Yet can/should it be done with just one "service" ?


Solution

  • For north south traffic i.e exposing a service outside the cluster LoadBalancer or preferably ingress is better than NodePort because when NodePort is used if the Node IP or Port changes then the clients need to make changes in the endpoint that they are using to access the service.

    For east-west traffic between services within the cluster clusterIP service is good enough.