sa# Node.js container native design POC Proof of concept of Node.js container native design implementing the following tenets:
- DevOps automation
- Single concern principle
- Service discovery
- High Observability
- Lifecycle conformance
- Runtime confinement
- Process disposability
- Image immutability
The scope of the project is to produce a working node.js based e-commerce application using the above principles. The proposed approach is to create a simple node.js based application based on microservices, incorporating container native design technologies such as high observability, image immutability, and process disposability. This project will make use of existing NPM modules where possible e.g. kube-probe, nodeshift, swagger-ui-express, and third party tools e.g. Istio for microservice management. The output from this project will be a comprehensive example of cloud native node.js application development.
- Openshift 3.9 installation
- Openshift cli user with admin rights
oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin developer
oc login -u developer
oc new-project samplenode
From OCP portal, create a project "mongodb" and within this project deploy MongoDB (Ephemeral)
!!Will change!!
From Mongo pod terminal
mongo admin --username admin --password admin_pass
use test
db.products.insert({"product_id":2.0,"id":"B000JZ4HQO","title":"Clickart 950 000 - Premier image pack (dvd-rom)","description":"Clickart 950 000 - Premier image pack (dvd-rom)","manufacturer":"Broderbund","price":100.0,"image":"6.jpeg"})
db.reviews.insert({"product_id":2.0,"id":"B000JZ4HQO","title":"Best product I've ever purchased","userId":"Tom Smith"})
db.cart.insert({"product_id":2.0,"id":"B000JZ4HQO","quantity": "1","userId":"Tom Smith"})
From each folder [cart, catalog, gateway, reviews] run
npm run openshift
Once all components are deployed the list of pods should be: (Note each pod shows two containers ready)
Each Pod should contain two containers e.g.
curl http://gateway-samplenode.router.default.svc.cluster.local/products?[1-20]
The response from the curl command should be something like:
http://gateway-samplenode.router.default.svc.cluster.local/products?19 --> <stdout>
--_curl_--http://gateway-samplenode.router.default.svc.cluster.local/products?19
"[{\"_id\":\"5b08448645d5281f811b81f1\",\"product_id\":2,\"id\":\"B000JZ4HQO\",\"title\":\"Clickart 950 000 - Premier image pack (dvd-rom)\",\"description\":\"Clickart 950 000 - Premier image pack (dvd-rom)\",\"manufacturer\":\"Broderbund\",\"price\":100,\"image\":\"6.jpeg\",\"reviews\":\"[{\\\"_id\\\":\\\"5b08448645d5281f811b81f2\\\",\\\"product_id\\\":2,\\\"id\\\":\\\"B000JZ4HQO\\\",\\\"title\\\":\\\"Best product I've ever purchased\\\",\\\"userId\\\":\\\"Tom Smith\\\"}]\"}]"
Once the services are all operational, navigate to http://gateway-samplenode.router.default.svc.cluster.local/api-docs to view the swagger api ui.
Once Jaeger is configured correctly, you should now see trace metrics e.g.
and
And Directed Acyclic Graph e.g.
istioctl create -f ./http-fault.yaml
istioctl delete -f ./http-fault.yaml