Kanishk Khandelwal
Kanishk Khandelwal

Reputation: 11

How to connect microservice with NATS docker image inside kubernetes cluster

I was trying to connect 2 microservices via nats which worked out pretty well in local environment, i used docker image of NATS and used its pub-sub model. But now my task is to connect those 2 microservices inside kubernetes cluster. I made docker images of those microservices but can't figure out how to connect them via the container image of NATS.

docker image of NATS - https://hub.docker.com/_/nats

Upvotes: 1

Views: 390

Answers (1)

JArgente
JArgente

Reputation: 2297

To communicate two pods in kubernetes you have to expose them using a service. If you dont want to expose them to outside the cluster you can use ClusterIP as service type.

You can see here all the documentation about services in kubernetes.

https://kubernetes.io/docs/concepts/services-networking/service/

Upvotes: 2

Related Questions