Browse Source

+ swarm config & heplers

master
david 3 years ago
parent
commit
66398998f6
  1. 1
      .gitignore
  2. 2
      README.md
  3. 2
      swarm/.env.netmon
  4. 9
      swarm/README.md
  5. 34
      swarm/docker-compose.netmon.yml
  6. 8
      swarm/netmonDeploy.bash
  7. 2
      swarm/netmonLogs.bash
  8. 2
      swarm/netmonRemove.bash
  9. 3
      swarm/netmonRestart.bash
  10. 2
      swarm/netmonStatus.bash

1
.gitignore vendored

@ -3,3 +3,4 @@ rubbish/
db.sqlite3
data.csv
public/styles/style.css
swarm/.env.deploy

2
README.md

@ -13,6 +13,8 @@ docker run --rm -d \
daveplsno/netmon:latest
```
or for a much more painful but more premium way to run, check the files in the swarm folder
bunch of misc cmds used along the way
```

2
swarm/.env.netmon

@ -0,0 +1,2 @@
dstHost=1.1.1.1
dstPort=53

9
swarm/README.md

@ -0,0 +1,9 @@
# swarm stuff
the env file is like
```
netmonTraefikGrp=thenameoftheswarmservice
netmonTraefikUrl=the.domain.name.yourapp.will.be.available.on
netmonNode=theswarmnodeyouwannadeployto
```

34
swarm/docker-compose.netmon.yml

@ -0,0 +1,34 @@
---
version: '3.8'
networks:
swarmnet-public:
external: true
volumes:
netmon-data:
services:
app:
image: daveplsno/netmon:latest
hostname: netmon
env_file: .env.netmon
volumes:
- netmon-data:/app
networks:
- swarmnet-public
deploy:
restart_policy:
condition: on-failure
placement:
constraints:
- node.labels.${netmonNode? Variable not set} == true
labels:
- traefik.enable=true
- traefik.docker.network=swarmnet-public
- traefik.constraint-label=swarmnet-public
- traefik.http.routers.${netmonTraefikGrp? Variable not set}.rule=Host(`${netmonTraefikUrl? Variable not set}`)
- traefik.http.routers.${netmonTraefikGrp? Variable not set}.entrypoints=websecure
- traefik.http.routers.${netmonTraefikGrp? Variable not set}.tls=true
- traefik.http.routers.${netmonTraefikGrp? Variable not set}.tls.certresolver=le
- traefik.http.services.${netmonTraefikGrp? Variable not set}.loadbalancer.server.port=3000

8
swarm/netmonDeploy.bash

@ -0,0 +1,8 @@
# export vars
export $(cat .env.deploy)
# deploy to swarm
docker stack deploy -c docker-compose.netmon.yml netmon
# unset the env vars
unset $(cat .env.deploy | cut -f 1 -d '=' $1)

2
swarm/netmonLogs.bash

@ -0,0 +1,2 @@
#!/bin/bash
docker service logs netmon_app -f

2
swarm/netmonRemove.bash

@ -0,0 +1,2 @@
#!/bin/bash
docker service rm netmon_app

3
swarm/netmonRestart.bash

@ -0,0 +1,3 @@
#!/bin/bash
docker service scale netmon_app=0
docker service scale netmon_app=1

2
swarm/netmonStatus.bash

@ -0,0 +1,2 @@
#!/bin/bash
docker service ps netmon_app
Loading…
Cancel
Save