Cloud Native Development with Node.js, Docker, and Kubernetes
Steps to run(you should have docker installed and kubernetes enabled):
Run with docker:
- cd myapp
- build the app into a docker image: docker build -t nodeserver -f Dockerfile .
- run a docker container from the image: docker run -ti -p 3000:3000 nodeserver
- open the browser and go to http://localhost:3000, you should see the express app running
Run with kubernetes(Helm): After finishing the previous steps running with docker:
- cd myapp
- deploy docker image to kubernetes and run the express app: helm install nodeserver chart/nodeserver
- make any changes to the helm chart and redeploy: helm upgrade nodeserver chart/nodeserver
- check and see if all three pods are running: kubectl get pods
- check exposed port, eg. 30524, from the service: kubectl get services
- open the browser and go to http://localhost:30524, you should see the express app running
- use http://localhost:30524/ready or http://localhost:30524/live to check the readiness and liveness of the app
- use http://localhost:30524/metrics to see the metrics of the app
- install Prometheus and Grafana to see the metrics of the app: https://artifacthub.io/packages/helm/prometheus-community/prometheus | https://artifacthub.io/packages/helm/grafana/grafana
- use zipkin for opentracing: https://artifacthub.io/packages/helm/carlosjgp/zipkin
tips: restart the docker client a few times if the kubernetes cluster could not be connected.