Skip to content

Commit

Permalink
feat: 💥 unify plugin import between traefik and this chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mysiki authored Dec 1, 2023
1 parent 6a6efc1 commit cbddacb
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 10 deletions.
7 changes: 5 additions & 2 deletions traefik/VALUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ Kubernetes: `>=1.16.0-0`
| env | list | `[{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"POD_NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}}]` | Environment variables to be passed to Traefik's binary |
| envFrom | list | `[]` | Environment variables to be passed to Traefik's binary from configMaps or secrets |
| experimental.kubernetesGateway.enabled | bool | `false` | Enable traefik experimental GatewayClass CRD |
| experimental.plugins | object | `{"enabled":false}` | Enable traefik version 3 enabled: false |
| experimental.plugins.enabled | bool | `false` | Enable traefik experimental plugins |
| experimental.plugins | object | `{}` | Enable traefik experimental plugins |
| extraObjects | list | `[]` | Extra objects to deploy (value evaluated as a template) In some cases, it can avoid the need for additional, extended or adhoc deployments. See #595 for more details and traefik/tests/values/extra.yaml for example. |
| globalArguments | list | `["--global.checknewversion","--global.sendanonymoususage"]` | Global command arguments to be passed to all traefik's pods |
| hostNetwork | bool | `false` | If hostNetwork is true, runs traefik in the host network namespace To prevent unschedulabel pods due to port collisions, if hostNetwork=true and replicas>1, a pod anti-affinity is recommended and will be set if the affinity is left as default. |
Expand Down Expand Up @@ -127,6 +126,9 @@ Kubernetes: `>=1.16.0-0`
| ports.websecure.tls.enabled | bool | `true` | |
| ports.websecure.tls.options | string | `""` | |
| priorityClassName | string | `""` | Priority indicates the importance of a Pod relative to other Pods. |
| providers.file.content | string | `""` | File content (YAML format, go template supported) (see https://doc.traefik.io/traefik/providers/file/) |
| providers.file.enabled | bool | `false` | Create a file provider |
| providers.file.watch | bool | `true` | Allows Traefik to automatically watch for file changes |
| providers.kubernetesCRD.allowCrossNamespace | bool | `false` | Allows IngressRoute to reference resources in namespace other than theirs |
| providers.kubernetesCRD.allowEmptyServices | bool | `false` | Allows to return 503 when there is no endpoints available |
| providers.kubernetesCRD.allowExternalNameServices | bool | `false` | Allows to reference ExternalName services in IngressRoute |
Expand Down Expand Up @@ -157,6 +159,7 @@ Kubernetes: `>=1.16.0-0`
| service.type | string | `"LoadBalancer"` | |
| serviceAccount | object | `{"name":""}` | The service account the pods will use to interact with the Kubernetes API |
| serviceAccountAnnotations | object | `{}` | Additional serviceAccount annotations (e.g. for oidc authentication) |
| startupProbe | string | `nil` | Define Startup Probe for container: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes eg. `startupProbe: exec: command: - mycommand - foo initialDelaySeconds: 5 periodSeconds: 5` |
| tlsOptions | object | `{}` | TLS Options are created as TLSOption CRDs https://doc.traefik.io/traefik/https/tls/#tls-options When using `labelSelector`, you'll need to set labels on tlsOption accordingly. Example: tlsOptions: default: labels: {} sniStrict: true preferServerCipherSuites: true customOptions: labels: {} curvePreferences: - CurveP521 - CurveP384 |
| tlsStore | object | `{}` | TLS Store are created as TLSStore CRDs. This is useful if you want to set a default certificate https://doc.traefik.io/traefik/https/tls/#default-certificate Example: tlsStore: default: defaultCertificate: secretName: tls-cert |
| tolerations | list | `[]` | Tolerations allow the scheduler to schedule pods with matching taints. |
Expand Down
11 changes: 9 additions & 2 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
mountPath: {{ .mountPath }}
readOnly: true
{{- end }}
{{- if .Values.experimental.plugins.enabled }}
{{- if gt (len .Values.experimental.plugins) 0 }}
- name: plugins
mountPath: "/plugins-storage"
{{- end }}
Expand Down Expand Up @@ -517,6 +517,13 @@
{{- end }}
{{- end }}
{{- end }}
{{- range $pluginName, $plugin := .Values.experimental.plugins }}
{{- if or (ne (typeOf $plugin) "map[string]interface {}") (not (hasKey $plugin "moduleName")) (not (hasKey $plugin "version")) }}
{{- fail (printf "ERROR: plugin %s is missing moduleName/version keys !" $pluginName) }}
{{- end }}
- --experimental.plugins.{{ $pluginName }}.moduleName={{ $plugin.moduleName }}
- --experimental.plugins.{{ $pluginName }}.version={{ $plugin.version }}
{{- end }}
{{- if .Values.providers.kubernetesCRD.enabled }}
- "--providers.kubernetescrd"
{{- if .Values.providers.kubernetesCRD.labelSelector }}
Expand Down Expand Up @@ -735,7 +742,7 @@
{{- if .Values.deployment.additionalVolumes }}
{{- toYaml .Values.deployment.additionalVolumes | nindent 8 }}
{{- end }}
{{- if .Values.experimental.plugins.enabled }}
{{- if gt (len .Values.experimental.plugins) 0 }}
- name: plugins
emptyDir: {}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions traefik/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
{{- fail "\n\n ERROR: latest tag should not be used" }}
{{- end }}

{{- if ne (typeOf .Values.experimental.plugins) "map[string]interface {}" }}
{{- fail (printf "ERROR: .Values.experimental.plugins should be a map (%s provided) !" (typeOf .Values.experimental.plugins)) }}
{{- end }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down
39 changes: 37 additions & 2 deletions traefik/tests/traefik-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ tests:
path: spec.template.spec.containers[0].args
content: "--providers.kubernetesingress.ingressClass=foo"

- it: should have a plugin storage if the experimental feature is enabled
- it: should have a plugin storage and args if the experimental feature is enabled
set:
experimental:
plugins:
enabled: true
demo:
moduleName: github.com/traefik/plugindemo
version: v0.2.1
asserts:
- equal:
path: spec.template.spec.volumes[2]
Expand All @@ -184,6 +186,39 @@ tests:
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:
plugins:
enabled: true
asserts:
- failedTemplate:
errorMessage: "ERROR: plugin enabled is missing moduleName/version keys !"

- it: should fail gracefully on missing plugins information
set:
experimental:
plugins:
demo:
moduleName: github.com/traefik/plugindemo
asserts:
- failedTemplate:
errorMessage: "ERROR: plugin demo is missing moduleName/version keys !"

- it: should fail gracefully on bad structure
set:
experimental:
plugins: true
asserts:
- failedTemplate:
errorMessage: "ERROR: .Values.experimental.plugins should be a map (bool provided) !"

- it: should have tls configuration args when specified in values.yaml for port
set:
Expand Down
10 changes: 6 additions & 4 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ experimental:
# This value is no longer used, set the image.tag to a semver higher than 3.0, e.g. "v3.0.0-beta3"
# v3:
# -- Enable traefik version 3
# enabled: false
plugins:
# -- Enable traefik experimental plugins
enabled: false

# -- Enable traefik experimental plugins
plugins: {}
# demo:
# moduleName: github.com/traefik/plugindemo
# version: v0.2.1
kubernetesGateway:
# -- Enable traefik experimental GatewayClass CRD
enabled: false
Expand Down

0 comments on commit cbddacb

Please sign in to comment.