feat: add persistent storage (#30)

* refactor: remove unused default timeout

* feat: add persistent storage

Allows you to save the state to a file and load it upon restarting the app to restore the previous state.

* chore: upgrade to go 1.18

* use tinykv with generics

* build: add "-buildvcs=false" flag

Git is not available in golang:1.18-alpine image
This commit is contained in:
Alexis Couvreur
2022-05-09 22:55:32 +02:00
parent 4eb086f9d5
commit 3eb7d480da
9 changed files with 397 additions and 647 deletions

View File

@@ -30,24 +30,25 @@
- Dynamic loading page (cloudflare or grafana cloud style)
- Automatic scale to zero after configured timeout upon last request the service received
- Support container/service healthcheck and will not redirect until service is healthy
## Usage
### CLI
`./traefik-ondemand-service --swarmMode=true --kubernetesMode=false`
| Argument | Value | Description |
| ----------- | ----------------- | ----------------------------------------------------------------------- |
| `swarmMode` | true,false (default true) | Enable/Disable swarm mode. Used to determine the scaler implementation. |
| `kubernetesMode` | true,false (default false) | Enable/Disable Kubernetes mode. Used to determine the scaler implementation. |
| Argument | Value | Description |
| ---------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `swarmMode` | true,false (default true) | Enable/Disable swarm mode. Used to determine the scaler implementation. |
| `kubernetesMode` | true,false (default false) | Enable/Disable Kubernetes mode. Used to determine the scaler implementation. |
| `storagePath` | path/to/storage/file (default nil) | Enables persistent storage, file will be used to load previous state upon starting and will sync the current content to memory into the file every 5 seconds |
### Docker
- Docker Hub `acouvreur/traefik-ondemand-service`
- Ghcr `ghcr.io/acouvreur/traefik-ondemand-service`
`docker run -v /var/run/docker.sock:/var/run/docker.sock -p 10000:10000
ghcr.io/acouvreur/traefik-ondemand-service:latest --swarmode=true`
`docker run -v /var/run/docker.sock:/var/run/docker.sock -p 10000:10000 ghcr.io/acouvreur/traefik-ondemand-service:latest --swarmode=true`
### Kubernetes