Skip to content

Very simple NodeJS application for K3S Example Project

Notifications You must be signed in to change notification settings

madlopt/simple-nodejs-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A very simple NodeJS app for K3S Example Project

You can configure it via the following environment variables:

      - name: PROJECT_NAME
        value: "nodejs-test-app"
      - name: CONSOLE_LOG_TIMEOUT
        value: "5000"
      - name: METRICS_ROUTE
        value: "/metrics"
      - name: METRICS_PORT
        value: "80"
      - name: METRICS_COMPONENT
        value: "applications"
      - name: METRICS_SOURCE
        value: "nodejs-test-app"
      - name: METRICS_NAMESPACE
        value: "default"

The app is just sending PROJECT_NAME is alive message to the console every CONSOLE_LOG_TIMEOUT milliseconds and exposing the metrics endpoint on the METRICS_ROUTE route and METRICS_PORT port.

Metrics & Prom-Client Memory Leak

There are a lot of default metrics available, from the prom-client library. And the one is custom one http_requests_counter which is a counter of all the requests to the application just as an example of custom metric you can add.

I'm using a wrapper service/collectDefaultMetricsWrapper.js for the prom-client library, because the library has a memory leak when it's accessing the gc. So the wrapper is simply excluding the gc usage from the metrics. You are free to use it.

DockerHub Image

The image I'm using for K3S Example Project is there you can pull it by running docker pull madloptus/nodejsapp

Running the app locally

Not sure even if someone will need it, but if you want to run the app locally, there is the docket-compose file for that. Just run docker-compose up and the app will be available on the http://localhost:80. If you want to run if without anything just on your local machine, don't forget to run npm install before the first run.

About

Very simple NodeJS application for K3S Example Project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published