Skip to content

Commit

Permalink
fix: 🐛 support specifying plugins storage
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 authored Nov 13, 2024
1 parent 9a5b396 commit ae13d4b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
18 changes: 14 additions & 4 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,28 @@ experimental:
version: v1.3.5
```

When persistence is needed, this `emptyDir` can be replaced with a PVC:
When persistence is needed, this `emptyDir` can be replaced with a PVC by adding:

```yaml
deployment:
additionalVolumes:
- name: plugins
persistentVolumeClaim:
claimName: my-plugins-vol
additionalVolumeMounts:
- name: plugins
mountPath: /plugins-storage
additionalArguments:
- "--experimental.plugins.bouncer.moduleName=github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin"
- "--experimental.plugins.bouncer.version=v1.3.5"
extraObjects:
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: my-plugins-vol
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
```

# Use Traefik native Let's Encrypt integration, without cert-manager
Expand Down
10 changes: 10 additions & 0 deletions traefik/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,13 @@ Key: {{ $cert.Key | b64enc }}
{{ printf "- \"%s\"\n" . }}
{{- end -}}
{{- end -}}

{{- define "traefik.hasPluginsVolume" -}}
{{- $found := false -}}
{{- range . -}}
{{- if eq .name "plugins" -}}
{{ $found = true }}
{{- end -}}
{{- end -}}
{{- $found -}}
{{- end -}}
4 changes: 2 additions & 2 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
mountPath: {{ .mountPath }}
readOnly: true
{{- end }}
{{- if gt (len .Values.experimental.plugins) 0 }}
{{- if and (gt (len .Values.experimental.plugins) 0) (ne (include "traefik.hasPluginsVolume" .Values.deployment.additionalVolumes) "true") }}
- name: plugins
mountPath: "/plugins-storage"
{{- end }}
Expand Down Expand Up @@ -812,7 +812,7 @@
{{- if .Values.deployment.additionalVolumes }}
{{- toYaml .Values.deployment.additionalVolumes | nindent 8 }}
{{- end }}
{{- if gt (len .Values.experimental.plugins) 0 }}
{{- if and (gt (len .Values.experimental.plugins) 0) (ne (include "traefik.hasPluginsVolume" .Values.deployment.additionalVolumes) "true") }}
- name: plugins
emptyDir: {}
{{- end }}
Expand Down
35 changes: 35 additions & 0 deletions traefik/tests/traefik-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,41 @@ tests:
path: spec.template.spec.containers[0].args
content: "--experimental.plugins.demo.version=v0.2.1"

- it: should be possible to configure a customized plugin storage
set:
experimental:
plugins:
demo:
moduleName: github.com/traefik/plugindemo
version: v0.2.1
deployment:
additionalVolumes:
- name: plugins
hostPath:
path: /data/
type: Directory
additionalVolumeMounts:
- name: plugins
mountPath: /plugins-storage
asserts:
- equal:
path: spec.template.spec.volumes[2]
value:
hostPath:
path: /data/
type: Directory
name: plugins
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: plugins
mountPath: "/plugins-storage"
- contains:
path: spec.template.spec.containers[0].args
content: "--experimental.plugins.demo.moduleName=github.com/traefik/plugindemo"
- contains:
path: spec.template.spec.containers[0].args
content: "--experimental.plugins.demo.version=v0.2.1"
- it: should fail gracefully when using old syntax
set:
experimental:
Expand Down

0 comments on commit ae13d4b

Please sign in to comment.