mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-27 15:41:41 +01:00
When an instance does not exist yet and needs to be started, its status is not assumed to be starting anymore. Instead, the statue will be retrieved from the provider. This changes one thing, it's that you may be able to start and access your services instantly because they'll be instantly seen as ready. With this change, you might want to make sure that your containers have a proper healthcheck used to determine when the application is able to process incoming requests. * refactor: add interface guards * refactor(providers): remove instance.State as a return value from Stop and Start * test(e2e): add healthcheck on nginx container Because now the container check is so fast, we need to add a delay on which the container is considered started and healthy to have a proper waiting page. * fix(tests): using acouvreur/whoami:v1.10.2 instead of containous/whoami:v1.5.0 This image simply retrieve the curl binary from curlimages/curl:8.8.0 to be able to add proper docker healthcheck commands. Once this is merged with traefik/whoami, I'll update back to the original image. See https://github.com/traefik/whoami/issues/33
159 lines
4.1 KiB
Markdown
159 lines
4.1 KiB
Markdown
# Traefik Sablier Plugin
|
|
|
|
The [Traefik Sablier Plugin](https://plugins.traefik.io/plugins/633b4658a4caa9ddeffda119/sablier) in the plugin catalog.
|
|
|
|
## Provider compatibility grid
|
|
|
|
| Provider | Dynamic | Blocking |
|
|
| --------------------------------------- | :-----: | :-----------------------------------------------------: |
|
|
| [Docker](../providers/docker) | ✅ | ✅ |
|
|
| [Docker Swarm](../providers/docker_swarm) | ✅ | ✅ |
|
|
| [Kubernetes](../providers/kubernetes) | ✅ | ✅ |
|
|
|
|
## Prerequisites
|
|
|
|
<!-- tabs:start -->
|
|
|
|
#### **Docker**
|
|
|
|
**Traefik will evict containers from its pool if they are stopped.**
|
|
|
|
Meaning labels attached to containers to autodiscover them is not possible with this plugin.
|
|
|
|
You have to use the dynamic config file provider instead.
|
|
|
|
**❌ You cannot do the following:**
|
|
|
|
```yaml
|
|
whoami:
|
|
image: acouvreur/whoami:v1.10.2
|
|
labels:
|
|
- traefik.enable
|
|
- traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)
|
|
- traefik.http.routers.whoami.middlewares=my-sablier@file
|
|
```
|
|
|
|
**✅ You should do the following instead:**
|
|
|
|
```yaml
|
|
http:
|
|
services:
|
|
whoami:
|
|
loadBalancer:
|
|
servers:
|
|
- url: "http://whoami:80"
|
|
|
|
routers:
|
|
whoami:
|
|
rule: PathPrefix(`/whoami`)
|
|
entryPoints:
|
|
- "http"
|
|
middlewares:
|
|
- my-sablier@file
|
|
service: "whoami"
|
|
```
|
|
*dynamic-config.yaml*
|
|
|
|
|
|
#### **Docker Swarm**
|
|
|
|
**Traefik will evict services from its pool if they have 0 replicas.**
|
|
|
|
In order to use service labels, you have to add the following option on top of each services that will use this plugin.
|
|
|
|
See also [`traefik.docker.lbswarm`](https://doc.traefik.io/traefik/routing/providers/docker/#traefikdockerlbswarm) label
|
|
|
|
```yaml
|
|
services:
|
|
whoami:
|
|
image: acouvreur/whoami:v1.10.2
|
|
deploy:
|
|
replicas: 0
|
|
labels:
|
|
- traefik.docker.lbswarm=true
|
|
```
|
|
|
|
Traefik also have [allowEmptyServices](https://doc.traefik.io/traefik/providers/docker/#allowemptyservices) option which can be used instead.
|
|
|
|
#### **Kubernetes**
|
|
|
|
**Traefik will evict deployments from its pool if they have 0 endpoints available.**
|
|
|
|
You must use [`allowEmptyServices`](https://doc.traefik.io/traefik/providers/kubernetes-ingress/#allowemptyservices)
|
|
|
|
The blocking strategy is supported by issuing redirect which force client to retry request. It might fail if client do not support redirections (e.g. `curl` without `-L`). The limitation is caused by Traefik architecture. Everytime the underlying configuration changes, the whole router is regenrated, thus changing the router during a request will still map to the old router. For more details, see [#62](https://github.com/acouvreur/sablier/issues/62).
|
|
|
|
<!-- tabs:end -->
|
|
|
|
## Install the plugin to Traefik
|
|
|
|
<!-- tabs:start -->
|
|
|
|
#### **File (YAML)**
|
|
|
|
```yaml
|
|
experimental:
|
|
plugins:
|
|
sablier:
|
|
moduleName: "github.com/acouvreur/sablier"
|
|
version: "v1.8.0-beta.8"
|
|
```
|
|
|
|
#### **CLI**
|
|
|
|
```bash
|
|
--experimental.plugins.sablier.modulename=github.com/acouvreur/sablier
|
|
--experimental.plugins.sablier.version=v1.8.0-beta.8
|
|
```
|
|
|
|
<!-- tabs:end -->
|
|
|
|
## Configure the plugin using the Dynamic Configuration
|
|
|
|
<!-- tabs:start -->
|
|
|
|
#### **File (YAML)**
|
|
|
|
```yaml
|
|
http:
|
|
middlewares:
|
|
my-sablier:
|
|
plugin:
|
|
sablier:
|
|
group: default
|
|
dynamic:
|
|
displayName: My Title
|
|
refreshFrequency: 5s
|
|
showDetails: "true"
|
|
theme: hacker-terminal
|
|
sablierUrl: http://sablier:10000
|
|
sessionDuration: 1m
|
|
```
|
|
|
|
#### **Kubernetes CRD**
|
|
|
|
```yaml
|
|
apiVersion: traefik.containo.us/v1alpha1
|
|
kind: Middleware
|
|
metadata:
|
|
name: my-sablier
|
|
namespace: my-namespace
|
|
spec:
|
|
plugin:
|
|
sablier:
|
|
group: default
|
|
dynamic:
|
|
displayName: My Title
|
|
refreshFrequency: 5s
|
|
showDetails: "true"
|
|
theme: hacker-terminal
|
|
sablierUrl: http://sablier:10000
|
|
sessionDuration: 1m
|
|
```
|
|
|
|
<!-- tabs:end -->
|
|
|
|
## Configuration reference
|
|
|
|
TODO
|