-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from mohsenasm/dev_stats
Show container / node stats
- Loading branch information
Showing
28 changed files
with
798 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
push: | ||
branches: | ||
- 'master' | ||
- 'dev_security' | ||
- 'dev_stats' | ||
tags: | ||
- 'v*' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ RUN yarn install --production | |
|
||
# elm doesn't work under alpine 6 or 8 | ||
FROM node:10.16.0-buster-slim AS elm-build | ||
WORKDIR /home/node/app | ||
RUN npm install --unsafe-perm -g [email protected] --silent | ||
RUN apt-get update; apt-get install -y netbase | ||
COPY elm-package.json ./ | ||
WORKDIR /home/node/app/elm-client | ||
COPY ./elm-client/elm-package.json . | ||
RUN elm package install -y | ||
COPY . . | ||
COPY ./elm-client/ /home/node/app/elm-client/ | ||
RUN elm make Main.elm --output=client/index.js | ||
|
||
FROM base AS release | ||
|
@@ -28,11 +28,12 @@ RUN wget -O lego_v4.14.2_linux_amd64.tar.gz https://github.com/go-acme/lego/rele | |
ENV LEGO_PATH=/lego-files | ||
|
||
COPY --from=dependencies /home/node/app/node_modules node_modules | ||
COPY --from=elm-build /home/node/app/client/ client | ||
COPY --from=elm-build /home/node/app/elm-client/client/ client | ||
COPY server server | ||
COPY server.sh server.sh | ||
COPY crontab /var/spool/cron/crontabs/root | ||
|
||
# ENV PORT=8080 | ||
# HEALTHCHECK --interval=5s --timeout=3s \ | ||
# CMD curl --fail http://localhost:$PORT/_health || exit 1 | ||
# HEALTHCHECK --interval=5s --timeout=3s \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,68 +4,95 @@ A simple monitoring dashboard for Docker in Swarm Mode. | |
|
||
![Example Dashboard](./swarm.gif) | ||
|
||
## About | ||
Swarm Dashboard shows you all the tasks running on a Docker Swarm organized | ||
by service and node. It provides a space-efficient visualization | ||
and works well at a glance. You can use it as a simple live dashboard of the state of your Swarm. | ||
|
||
Swarm dashboard shows you all the tasks running on a Docker Swarm organized | ||
by service and node. It provides a visualization that's space-efficient | ||
and works well at a glance. | ||
It also shows the CPU/Memory/Disk usage of your swarm node and containers. | ||
|
||
You can use it as a simple live dashboard of the state of your Swarm. | ||
## Usage | ||
|
||
The Dashboard has a node.js server which streams swarm updates to an Elm client | ||
over a WebSocket. | ||
|
||
### Prior art | ||
|
||
* Heavily inspired by [Docker Swarm Visualiser](https://github.com/dockersamples/docker-swarm-visualizer) | ||
|
||
## Running | ||
|
||
At the moment, the dashboard needs to be deployed on one of the swarm managers. | ||
The dashboard needs to be deployed on one of the swarm managers. | ||
You can configure it with the following Docker compose file: | ||
|
||
```yml | ||
# compose.yml | ||
version: "3" | ||
|
||
services: | ||
dashboard: | ||
image: mohsenasm/swarm-dashboard | ||
swarm-dashboard: | ||
image: mohsenasm/swarm-dashboard:dev_stats | ||
volumes: | ||
- "/var/run/docker.sock:/var/run/docker.sock" | ||
- lego-files:/lego-files | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
ports: | ||
- 8081:8081 | ||
- 8080:8080 | ||
environment: | ||
PORT: 8081 | ||
PORT: 8080 | ||
ENABLE_AUTHENTICATION: "false" | ||
# ENABLE_AUTHENTICATION: "true" | ||
# AUTHENTICATION_REALM: "KuW2i9GdLIkql" | ||
# USERNAME: "admin" | ||
# PASSWORD: "supersecret" | ||
ENABLE_HTTPS: "false" | ||
# ENABLE_HTTPS: "true" | ||
# HTTPS_HOSTNAME: "example.com" | ||
# LEGO_NEW_COMMAND_ARGS: "--accept-tos [email protected] --domains=example.com --dns cloudflare run" | ||
# LEGO_RENEW_COMMAND_ARGS: "--accept-tos [email protected] --domains=example.com --dns cloudflare renew" | ||
# CLOUDFLARE_EMAIL: "[email protected]" | ||
# CLOUDFLARE_API_KEY: "yourprivatecloudflareapikey" | ||
NODE_EXPORTER_SERVICE_NAME_REGEX: "node-exporter" | ||
CADVISOR_SERVICE_NAME_REGEX: "cadvisor" | ||
deploy: | ||
replicas: 1 | ||
placement: | ||
constraints: | ||
- node.role == manager | ||
|
||
node-exporter: | ||
image: quay.io/prometheus/node-exporter:v1.6.1 | ||
volumes: | ||
- '/:/host:ro' | ||
command: | ||
- '--path.rootfs=/host' | ||
deploy: | ||
mode: global | ||
|
||
volumes: | ||
lego-files: | ||
cadvisor: | ||
image: gcr.io/cadvisor/cadvisor | ||
volumes: | ||
- /:/rootfs:ro | ||
- /var/run:/var/run:rw | ||
- /sys:/sys:ro | ||
- /var/lib/docker/:/var/lib/docker:ro | ||
- /dev/disk/:/dev/disk:ro | ||
deploy: | ||
mode: global | ||
``` | ||
and deploy with | ||
``` | ||
$ docker stack deploy -c compose.yml svc | ||
$ docker stack deploy -c compose.yml sd | ||
``` | ||
|
||
Note that the usage of `node-exporter` and `cadvisor` are optional, to fetch node CPU/Memory/Disk usage and containers' CPU/Memory usage respectively. If you don't need this feature, make sure to remove `NODE_EXPORTER_SERVICE_NAME_REGEX` and `CADVISOR_SERVICE_NAME_REGEX` envs. | ||
|
||
## Advance Usage | ||
|
||
List of environment variables for more customization: | ||
|
||
| Enviroment Varibles | Example | Considration | | ||
|--------------------------------------|-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| PORT | 8080 | HTTP / HTTPS port | | ||
| ENABLE_AUTHENTICATION | true | false by default | | ||
| AUTHENTICATION_REALM | MyRealm | Use this env if ENABLE_AUTHENTICATION is `true`. | | ||
| USERNAME | admin | Use this env if ENABLE_AUTHENTICATION is `true`. | | ||
| PASSWORD | supersecret | Use this env if ENABLE_AUTHENTICATION is `true`. | | ||
| ENABLE_HTTPS | true | false by default | | ||
| LEGO_PATH | /lego-files | Use this env if ENABLE_HTTPS is `true`. Lego is used to create the SSL certificates. Create a named volume for this path to avoid the creation of a new certificate on each run. | | ||
| HTTPS_HOSTNAME | swarm-dashboard.example.com | Use this env if ENABLE_HTTPS is `true`. | | ||
| LEGO_NEW_COMMAND_ARGS | --accept-tos --email=[email protected] --domains=swarm-dashboard.example.com --dns cloudflare run | Use this env if ENABLE_HTTPS is `true`. | | ||
| LEGO_RENEW_COMMAND_ARGS | --accept-tos --email=[email protected] --domains=swarm-dashboard.example.com --dns cloudflare renew | Use this env if ENABLE_HTTPS is `true`. | | ||
| CLOUDFLARE_EMAIL | [email protected] | You can use any [DNS provider that Lego supports](https://go-acme.github.io/lego/dns/). | | ||
| CLOUDFLARE_API_KEY | yourprivatecloudflareapikey | You can use any [DNS provider that Lego supports](https://go-acme.github.io/lego/dns/). | | ||
| DOCKER_UPDATE_INTERVAL | 1000 | Refresh interval in ms. | | ||
| METRICS_UPDATE_INTERVAL | 5000 | Refresh interval in ms. | | ||
| NODE_EXPORTER_SERVICE_NAME_REGEX | node-exporter | Use this env to enable `node-exporter` integration. | | ||
| NODE_EXPORTER_INTERESTED_MOUNT_POINT | /rootfs | You may need this config if you have not specified `--path.rootfs` for `node-exporter`. | | ||
| NODE_EXPORTER_PORT | 9100 | | | ||
| CADVISOR_SERVICE_NAME_REGEX | cadvisor | Use this env to enable `cadvisor` integration. | | ||
| CADVISOR_PORT | 8080 | | | ||
|
||
|
||
## Security | ||
|
||
+ We redact docker event data before sending them to the client. The previous version was sending the whole docker event data, including environment variables (someone might have stored some passwords in them, by mistake!). So, please consider using the newer version. | ||
|
@@ -93,12 +120,15 @@ There are two considerations for any serious deployment of the dashboard: | |
|
||
* Show more service details (published port, image name, and version) | ||
* Node / Service / Task details panel | ||
* Show node / task resources (CPU & Memory) | ||
* Improve security for potential production use | ||
|
||
Both feature requests and pull requests are welcome | ||
Both feature requests and pull requests are welcome. | ||
|
||
### Prior art | ||
|
||
* Heavily inspired by [Docker Swarm Visualiser](https://github.com/dockersamples/docker-swarm-visualizer) | ||
|
||
## Contributors | ||
|
||
* Viktor Charypar (owner, BDFL) - code, docs | ||
* Mohammad-Mohsen Aseman-Manzar (current maintainer) - code, docs | ||
* Viktor Charypar (previous repo owner) - code, docs | ||
* Clementine Brown - design |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ services: | |
# LEGO_RENEW_COMMAND_ARGS: "--accept-tos [email protected] --domains=example.com --dns cloudflare renew" | ||
# CLOUDFLARE_EMAIL: "[email protected]" | ||
# CLOUDFLARE_API_KEY: "yourprivatecloudflareapikey" | ||
NODE_EXPORTER_SERVICE_NAME_REGEX: "node-exporter" | ||
deploy: | ||
replicas: 1 | ||
update_config: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.