{"id":14155328,"url":"https://github.com/juffalow/node-express-kubernetes-example","last_synced_at":"2026-02-28T20:44:00.087Z","repository":{"id":81736423,"uuid":"408584596","full_name":"juffalow/node-express-kubernetes-example","owner":"juffalow","description":"Simple NodeJS application to explain basic parts of Kubernetes.","archived":false,"fork":false,"pushed_at":"2023-06-10T18:19:01.000Z","size":160,"stargazers_count":14,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T08:52:22.278Z","etag":null,"topics":["example-project","express","kubernetes","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://node-example.juffalow.com","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juffalow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-20T20:04:56.000Z","updated_at":"2024-11-25T22:26:12.000Z","dependencies_parsed_at":"2023-07-09T08:16:21.959Z","dependency_job_id":null,"html_url":"https://github.com/juffalow/node-express-kubernetes-example","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/juffalow/node-express-kubernetes-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juffalow%2Fnode-express-kubernetes-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juffalow%2Fnode-express-kubernetes-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juffalow%2Fnode-express-kubernetes-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juffalow%2Fnode-express-kubernetes-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juffalow","download_url":"https://codeload.github.com/juffalow/node-express-kubernetes-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juffalow%2Fnode-express-kubernetes-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29951659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T18:42:55.706Z","status":"ssl_error","status_checked_at":"2026-02-28T18:42:48.811Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example-project","express","kubernetes","nodejs","typescript"],"created_at":"2024-08-17T08:02:50.977Z","updated_at":"2026-02-28T20:44:00.046Z","avatar_url":"https://github.com/juffalow.png","language":"HTML","readme":"# Node Express Kubernetes Example\n\nSimple NodeJS application to explain basic parts of Kubernetes.\n\n* [Run simple Node.js application in Kubernetes cluster (DigitalOcean)](https://juffalow.com/blog/javascript/run-simple-node-application-in-kubernetes-cluster)\n\n## Routes\n\nThe `/app-id` route returns random string generated on application start, so that user can see if he is connecting to different pods (containers).\n\n```json\n{\"appId\":\"1.13.647\"}\n```\n\nAnother request should return a different number in the end.\n\n```json\n{\"appId\":\"1.13.539\"}\n```\n\nThe `/evn/:name` route returns environment variable as a proof that the application has access to values passed from *Kubernetes Secret*. For example you can try `/env/secretParameter`.\n\n```json\n{\"secretParameter\":\"DatabaseCredentials\"}\n```\n\n## Test readiness probe\n\nIf starting of a *pod* can take some time, you can define a `readinessProbe`. This is also usable if the *pod* has some unfinished work and is not available to receive any other requests. The check in this case is set to http get, so if it returns http status code `200` kubernetes will include the *pod* and if it returns status code `500` it will exclude the *pod*.\n\nYou can test it by refreshing the page and checking the `appId` and then visit [http://\u0026lt;IP address\u0026gt;/ready/toggle](https://kubernetes.kontentino.dev/ready/toggle), which will toggle the readiness for 10 seconds. During this time one of the app ids should not occure again.\n\n## Test liveness probe\n\nIf some fatal error occured or something else that actually blocked the whole process and the app is basically dead, the `livenessProbe` check detects it and restarts the *pod*. To see this in action, you need to check *pods*:\n\n```shell\nkubectl get pods\n```\n\nThis will return:\n\n```\nNAME                                                 READY   STATUS    RESTARTS   AGE\nnode-docker-kubernetes-deployment-78f7d56b4b-2sg69   1/1     Running   0          5m37s\nnode-docker-kubernetes-deployment-78f7d56b4b-d8n9h   1/1     Running   0          5m26s\n```\n\nIf you visit [http://\u0026lt;IP address\u0026gt;/alive/toggle](https://kubernetes.kontentino.dev/alive/toggle) and refresh the app a few times, one of the ids should not occure for a while. And if you check the *pods* again, the `restarts` info in one of the *pods* should show you `1`:\n\n```\nNAME                                                 READY   STATUS    RESTARTS   AGE\nnode-docker-kubernetes-deployment-78f7d56b4b-2sg69   1/1     Running   1          5m37s\nnode-docker-kubernetes-deployment-78f7d56b4b-d8n9h   1/1     Running   0          5m26s\n```\n\n## Test\n\n```js\nlet number = 0;\n\nconst load = async () =\u003e {\n  return fetch('https://node-test.kontentinoservices.dev/app-id')\n    .then(response =\u003e response.json())\n    .then((data) =\u003e {\n      console.log(`${number} App ID: ${data.appId}`);\n    });\n}\n\nconst sleep = async (ms) =\u003e {\n  return new Promise((resolve) =\u003e {\n    setTimeout(resolve, ms);\n  });\n}\n\nwhile (true) {\n  number++;\n  await load();\n  await sleep(1000);\n}\n```\n\n## Links\n\n* [Kubernetes Tutorial - Step by Step Introduction to Basic Concepts](https://auth0.com/blog/kubernetes-tutorial-step-by-step-introduction-to-basic-concepts/)\n* [Use Images in Your Registry with Kubernetes](https://www.digitalocean.com/docs/images/container-registry/quickstart/#use-images-in-your-registry-with-kubernetes)\n* [Docker best practices with Node.js](https://dev.to/nodepractices/docker-best-practices-with-node-js-4ln4)\n* [Node.js Best Practices - Docker](https://github.com/goldbergyoni/nodebestpractices/tree/master/sections/docker)\n\n## License\n\n[MIT license](./LICENSE)\n","funding_links":[],"categories":["typescript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuffalow%2Fnode-express-kubernetes-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuffalow%2Fnode-express-kubernetes-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuffalow%2Fnode-express-kubernetes-example/lists"}