Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mborne/debug
[DEV] A sample application to illustrate some Docker and Kubernetes features (auto-restarts, memory limits,...)
https://github.com/mborne/debug
Last synced: 3 months ago
JSON representation
[DEV] A sample application to illustrate some Docker and Kubernetes features (auto-restarts, memory limits,...)
- Host: GitHub
- URL: https://github.com/mborne/debug
- Owner: mborne
- License: mit
- Created: 2023-11-26T23:25:51.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-07-12T16:25:08.000Z (6 months ago)
- Last Synced: 2024-10-08T15:13:49.390Z (3 months ago)
- Language: JavaScript
- Size: 112 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mborne/debug
A buggy API to illustrate Docker and Kubernetes features :
![docs/screenshot.png](docs/screenshot.png)
## Parameters
| Name | Description | Default |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `DEBUG_PORT` | Listening port | `3000` |
| `DEBUG_COLOR` | A color to illustrates env vars handling and blue/green deployments | `null` |
| `LOG_FORMAT` | Log format to illustrate JSON parsing ("simple" or "json") | `"simple"` |
| `LOG_LEVEL` | [Log level](https://github.com/winstonjs/winston?tab=readme-ov-file#using-logging-levels) ("debug", "verbose", "info", "warn", "error") | `"info"` |## Usage
### Usage with docker
See [docker-compose.yml](docker-compose.yml) :
```bash
# start on http://localhost:3000
docker compose up -d --build# simulate crash
curl -X POST http://localhost:3000/api/bug/crash# simulate memory leak
while true; do curl -X POST -sS http://localhost:3000/api/bug/memory-leak ; echo; sleep 1; done
```### Kubernetes usage
In one terminal :
```bash
# deploy
kubectl -k manifests
# To watch pods restarts :
watch kubectl get pods -o wide
# To watch pods CPU / RAM :
watch kubectl top pods
```In another terminal :
```bash
# create temp pod
kubectl run terminal --rm -it --image=ghcr.io/mborne/terminal:latest --restart=Never -- /bin/sh# get metadata
curl -sS http://debug/api/metadata | jq# crash random pod
curl -X POST -sS http://debug/api/bug/crash | jq
# simulate memory leak
while true; do curl -X POST -sS http://debug/api/bug/memory-leak | jq ; sleep 5; done
```### Local usage
```bash
# install stress-ng
sudo apt-get update
sudo apt-get install -y stress-ng# install dependencies
npm install
# start on http://localhost:3000
npm run start
```## License
[MIT](LICENSE)