Switch plugin traefik-on-demand by sablier

This commit is contained in:
Adrien Reslinger 2024-09-09 00:07:23 +02:00
parent 48c523ec9a
commit 62961f7e06
Signed by: adrien
GPG key ID: DA7B27055C66D6DE
4 changed files with 79 additions and 36 deletions

View file

@ -70,13 +70,17 @@ data:
kubernetesCRD: kubernetesCRD:
# ingressClass: "traefik" # ingressClass: "traefik"
throttleDuration: 2s throttleDuration: 2s
{% if traefik_ondemand is defined %}
allowEmptyServices: true allowEmptyServices: true
{% endif%}
kubernetesIngress: kubernetesIngress:
ingressClass: "traefik" ingressClass: "traefik"
{% if traefik_hub_token is defined %} {% if traefik_hub_token is defined %}
allowExternalNameServices: true allowExternalNameServices: true
{% endif%} {% endif%}
{% if traefik_ondemand is defined %}
allowEmptyServices: true allowEmptyServices: true
{% endif%}
file: file:
directory: /etc/traefik/file/ directory: /etc/traefik/file/
watch: true watch: true
@ -113,8 +117,8 @@ data:
{% endif %} {% endif %}
{% if traefik_ondemand is defined %} {% if traefik_ondemand is defined %}
plugins: plugins:
traefik-ondemand-plugin: sablier:
moduleName: github.com/acouvreur/traefik-ondemand-plugin moduleName: github.com/acouvreur/sablier
version: v1.2.0 version: v1.7.0
{% endif %} {% endif %}
{% endif %} {% endif %}

View file

@ -58,6 +58,19 @@ data:
- {{ acl_whitelist }} - {{ acl_whitelist }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if traefik_ondemand is defined %}
ondemand:
plugin:
sablier:
#group: default
dynamic:
displayName: Application is starting
refreshFrequency: 5s
showDetails: "true"
theme: hacker-terminal
sablierUrl: http://sablier:10000
sessionDuration: 1m
{% endif %}
{% if basic_auth|bool %} {% if basic_auth|bool %}
basic-auth: basic-auth:
basicAuth: basicAuth:

View file

@ -144,6 +144,11 @@ metrics:
experimental: experimental:
plugins: plugins:
enabled: true enabled: true
{% if traefik_ondemand is defined %}
sablier:
moduleName: "github.com/acouvreur/sablier"
version: "v1.7.0"
{% endif %}
kubernetesGateway: kubernetesGateway:
enabled: false enabled: false
{% if traefik_hub_token is defined %} {% if traefik_hub_token is defined %}

View file

@ -1,35 +1,35 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: traefik-ondemand-service name: sablier
labels: labels:
app: traefik-ondemand-service app: sablier
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app: traefik-ondemand-service app: sablier
template: template:
metadata: metadata:
labels: labels:
app: traefik-ondemand-service app: sablier
spec: spec:
serviceAccountName: traefik-ondemand-service serviceAccountName: sablier
serviceAccount: traefik-ondemand-service serviceAccount: sablier
containers: containers:
- name: traefik-ondemand-service - name: sablier
image: ghcr.io/acouvreur/traefik-ondemand-service:1 image: acouvreur/sablier:1.7.0
args: ["--swarmMode=false", "--kubernetesMode=true"] args: ["start", "--provider.name=kubernetes"]
ports: ports:
- containerPort: 10000 - containerPort: 10000
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: traefik-ondemand-service name: sablier
spec: spec:
selector: selector:
app: traefik-ondemand-service app: sablier
ports: ports:
- protocol: TCP - protocol: TCP
port: 10000 port: 10000
@ -38,44 +38,65 @@ spec:
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: traefik-ondemand-service name: sablier
namespace: {{ traefik_namespace }}
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
name: traefik-ondemand-service name: sablier
namespace: {{ traefik_namespace }} # namespace: {{ traefik_namespace }}
rules: rules:
- apiGroups: - apiGroups:
- apps - apps
- ""
resources: resources:
- deployments - deployments
- deployments/scale # - deployments/scale
- statefulsets
# - statefulsets/scale
verbs: verbs:
- patch - patch # Scale up and down
- get - get # Retrieve info about specific dep
- update - update # Scale up and down
--- - list # Events
- watch # Events
- apiGroups:
- apps
- ""
resources:
- deployments/scale
- statefulsets/scale
verbs:
- patch # Scale up and down
- update # Scale up and down
- get # Retrieve info about specific dep
- list # Events
- watch # Events---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: traefik-ondemand-service name: sablier
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: ClusterRole kind: ClusterRole
name: traefik-ondemand-service name: sablier
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: traefik-ondemand-service name: sablier
namespace: {{ traefik_namespace }} namespace: {{ traefik_namespace }}
--- #---
apiVersion: traefik.containo.us/v1alpha1 #apiVersion: traefik.containo.us/v1alpha1
kind: Middleware #kind: Middleware
metadata: #metadata:
name: ondemand # name: ondemand
spec: #spec:
plugin: # plugin:
traefik-ondemand-plugin: # group: default
name: traefik_ondemand_plugin # dynamic:
serviceUrl: 'http://traefik-ondemand-service.{{ traefik_namespace }}:10000' # displayName: My Title
timeout: 1m # refreshFrequency: 5s
# showDetails: "true"
# theme: hacker-terminal
# sablierUrl: http://sablier.{{ traefik_namespace }}:10000
# sessionDuration: 1m