This project demonstrates how to use Docker Compose to manage multiple services that interact with each other through Docker networking. It includes two Node.js projects (producer
and consumer
) written in TypeScript.
- Docker
- Docker Compose
- Node.js
- npm
- Visual Studio Code or another code editor
Before running the services, make sure to install the necessary dependencies for both projects.
Navigate to the producer
directory and install the dependencies:
cd producer
npm install
Navigate to the consumer directory and install the dependencies:
cd consumer
npm install
Running the Projects You can use Docker Compose to build and run the projects.
docker-compose up --build
This command will:
Build the Docker images for both the producer and consumer services. Start the services and make them available on ports 3000 and 4000, respectively.
Once the services are running, you can interact with them using a web browser or a tool like curl.
To send a message from the producer
to the consumer
, access the following URL:
curl http://localhost:3000/send
You should receive a response indicating that the producer
successfully communicated with the consumer
.
This is an alternative approach to the docker-compose.
Follow this article: https://gist.github.com/genedy2017/142861e20a7c88b3ac7a78c86e09a5da
Start Minikube using Docker as the driver and configure Docker environment:
minikube start --driver=docker
eval $(minikube -p minikube docker-env)
Build the Docker images locally for producer and consumer services:
docker build -t producer:local -f producer/Dockerfile --no-cache ./producer
docker build -t consumer:local -f consumer/Dockerfile --no-cache ./consumer
Forward ports to access the services locally:
kubectl port-forward svc/producer 3000:3000
kubectl port-forward svc/consumer 4000:4000
Then, you can test the endpoints
minikube service producer
minikube service consumer
kubectl get deployments
kubectl get services
kubectl delete deployment consumer
kubectl delete deployment producer
helmfile apply
helmfile --log-level=debug apply
helmfile sync
kubectl describe pods -l app=consumer
kubectl describe pods -l app=producer
kubectl logs -l app=consumer
kubectl logs -l app=producer
Check if the Helm releases are actually deployed:
helm ls --namespace default
This should list the consumer and producer releases if they are deployed.
helm template ./k8s/helm/consumer -f ./k8s/helm/consumer/values.yaml
helm template ./k8s/helm/producer -f ./k8s/helm/producer/values.yaml
docker images | grep local