Skip to content

Instantly share code, notes, and snippets.

@rahulk789
Last active November 29, 2023 10:14
Show Gist options
  • Save rahulk789/616643b75337f255c9403009456003d0 to your computer and use it in GitHub Desktop.
Save rahulk789/616643b75337f255c9403009456003d0 to your computer and use it in GitHub Desktop.

Scalable Node.js Application Deployment on Kubernetes

Abstract:

A real time chat application through socket.io has been implemented and hosted through node.js server. The application is shipped as a docker image available on dockerhub which is then deployed as pods through k0s kubernetes cluster. The monitoring is performed by Prometheus and the front-end dashboard is provided through Grafana.The WAF for the node application is implemented through a helmet. Helmet is a npm package which configures http headers to be more secure.The CI/CD is implemented through github and github-actions.

Scaling:

Horizontal pod autoscaling has been developed to scale pods based on cpu resource consumption. Manifest files have been used to deploy the same. The pods have been tested with a payload and the scaling has been observed (refer to screenshots 1 2 and 3) The pods eventually downscale after a period of time.

Monitoring:

Prometheus scrapes the node exporters running on kubernetes and creates metrics and logs. These metrics are then used by Grafana through specific queries. We can observe that there is a peak in cpu cycles and the number of packets received by the application in the prometheus and grafana dashboards. Logs can be seen in screenshot 4. screenshots 5,6,7,8,9

CI/CD

Github has been used for maintaining different branches and versions of the application source code. Building and testing of the application’s docker image has been done through workflow in github-actions. Refer screenshot 10,11 Security The application has been secured with https (screenshot 12) with ssl certificates generated with openssl. Note:since the certificates are self signed, there is a warning shown. The waf as mentioned earlier has been implemented using helmet. Refer screenshot 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment