Skip to content

Commit

Permalink
feat: set runtimeClassName on pod spec
Browse files Browse the repository at this point in the history
  • Loading branch information
eddykaya authored Feb 16, 2024
1 parent 843d1d7 commit c07d55c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions traefik/VALUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Kubernetes: `>=1.16.0-0`
| deployment.podAnnotations | object | `{}` | Additional pod annotations (e.g. for mesh injection or prometheus scraping) It supports templating. One can set it with values like traefik/name: '{{ template "traefik.name" . }}' |
| deployment.podLabels | object | `{}` | Additional Pod labels (e.g. for filtering Pod by custom labels) |
| deployment.replicas | int | `1` | Number of pods of the deployment (only applies when kind == Deployment) |
| deployment.runtimeClassName | string | null | Set a runtimeClassName for created pods |
| deployment.shareProcessNamespace | bool | `false` | Use process namespace sharing |
| deployment.terminationGracePeriodSeconds | int | `60` | Amount of time (in seconds) before Kubernetes will send the SIGKILL signal if Traefik does not shut down |
| 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 |
Expand Down
3 changes: 3 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
- image: {{ template "traefik.image-name" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
name: {{ template "traefik.fullname" . }}
{{- with .Values.deployment.runtimeClassName }}
runtimeClassName: {{ . }}
{{- end }}
resources:
{{- with .Values.resources }}
{{- toYaml . | nindent 10 }}
Expand Down
27 changes: 19 additions & 8 deletions traefik/tests/pod-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,16 @@ tests:
asserts:
- contains:
path: spec.template.spec.containers[0].args
content:
"--certificatesresolvers.myAcmeResolver.acme.email=email@example.com"
content: "--certificatesresolvers.myAcmeResolver.acme.email=email@example.com"
- contains:
path: spec.template.spec.containers[0].args
content:
"--certificatesresolvers.myAcmeResolver.acme.dnsChallenge.provider=myProvider"
content: "--certificatesresolvers.myAcmeResolver.acme.dnsChallenge.provider=myProvider"
- contains:
path: spec.template.spec.containers[0].args
content:
"--certificatesresolvers.myAcmeResolver.acme.dnsChallenge.resolvers=1.1.1.1,8.8.8.8"
content: "--certificatesresolvers.myAcmeResolver.acme.dnsChallenge.resolvers=1.1.1.1,8.8.8.8"
- contains:
path: spec.template.spec.containers[0].args
content:
"--certificatesresolvers.myAcmeResolver.acme.tlsChallenge=true"
content: "--certificatesresolvers.myAcmeResolver.acme.tlsChallenge=true"
- it: should have prometheus annotations with specified values
set:
ports:
Expand Down Expand Up @@ -624,3 +620,18 @@ tests:
asserts:
- isNull:
path: spec.template.metadata.annotations.prometheus.io/scrape
- it: should set runtimeClassName when configured
set:
deployment:
runtimeClassName: ArbitraryRuntimeClass
asserts:
- equal:
path: spec.template.spec.containers[0].runtimeClassName
value: ArbitraryRuntimeClass
- it: should not set runtimeClassName when configured
set:
deployment:
runtimeClassName:
asserts:
- isNull:
path: spec.template.spec.containers[0].runtimeClassName
2 changes: 2 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ deployment:
# port: 9000
# host: localhost
# scheme: HTTP
# -- Set a runtimeClassName on pod
runtimeClassName:

# -- Pod disruption budget
podDisruptionBudget:
Expand Down

0 comments on commit c07d55c

Please sign in to comment.