Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions traefik/VALUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Kubernetes: `>=1.22.0-0`
| affinity | object | `{}` | on nodes where no other traefik pods are scheduled. It should be used when hostNetwork: true to prevent port conflicts |
| api.basePath | string | `""` | Configure API basePath |
| api.dashboard | bool | `true` | Enable the dashboard |
| api.debug | string | `nil` | Enable the debug API |
| api.insecure | string | `nil` | Enable the insecure API (HTTP) |
| autoscaling.behavior | object | `{}` | behavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). |
| autoscaling.enabled | bool | `false` | Create HorizontalPodAutoscaler object. See EXAMPLES.md for more details. |
| autoscaling.maxReplicas | string | `nil` | maxReplicas is the upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas. |
Expand Down
18 changes: 11 additions & 7 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,17 @@
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.api.dashboard }}
- "--api.dashboard=true"
{{- else if .Values.ingressRoute.dashboard.enabled }}
{{- fail "ERROR: Cannot create an IngressRoute for the dashboard without enabling api.dashboard" -}}
{{- end }}
{{- with .Values.api.basePath }}
- "--api.basePath={{ . }}"
{{- with .Values.api }}
{{- $apiConfig := . }}
{{- if eq $apiConfig.basePath "" }}
{{- $apiConfig = omit $apiConfig "basePath" }}
{{- end }}
{{- if hasKey $apiConfig "dashboard" }}
{{- if (and $.Values.ingressRoute.dashboard.enabled (not $apiConfig.dashboard)) }}
{{- fail "ERROR: Cannot create an IngressRoute for the dashboard without enabling api.dashboard" -}}
{{- end }}
{{- end }}
{{- include "traefik.yaml2CommandLineArgs" (dict "path" "api" "content" $apiConfig) | nindent 10 }}
{{- end }}
- "--ping=true"

Expand Down
68 changes: 68 additions & 0 deletions traefik/tests/api_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
suite: API configuration
templates:
- deployment.yaml
tests:
- it: should have default dashboard and ping argument
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: "--api.dashboard=true"
- contains:
path: spec.template.spec.containers[0].args
content: "--ping=true"
- notContains:
path: spec.template.spec.containers[0].args
content: "--api.basePath=/"

- it: should generate generic api arguments
set:
api:
insecure: true
debug: true
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: "--api.insecure=true"
- contains:
path: spec.template.spec.containers[0].args
content: "--api.debug=true"

- it: should not generate basePath flag when set to empty string
set:
api:
basePath: ""
asserts:
- notContains:
path: spec.template.spec.containers[0].args
content: "--api.basePath="

- it: should generate basePath flag when set to a value
set:
api:
basePath: "/foo"
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: "--api.basePath=/foo"

- it: should fail if ingressRoute.dashboard is enabled but api.dashboard is false
set:
api:
dashboard: false
ingressRoute:
dashboard:
enabled: true
asserts:
- failedTemplate:
errorMessage: "ERROR: Cannot create an IngressRoute for the dashboard without enabling api.dashboard"

- it: should fail on typo
set:
api:
dasboard: true
ingressRoute:
dashboard:
enabled: true
asserts:
- failedTemplate:
errorPattern: "values don't meet the specifications of the schema"
17 changes: 16 additions & 1 deletion traefik/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,23 @@
"dashboard": {
"description": "Enable the dashboard",
"type": "boolean"
},
"debug": {
"description": "Enable the debug API",
"type": [
"boolean",
"null"
]
},
"insecure": {
"description": "Enable the insecure API (HTTP)",
"type": [
"boolean",
"null"
]
}
}
},
"additionalProperties": false
},
"autoscaling": {
"type": "object",
Expand Down
6 changes: 5 additions & 1 deletion traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ gatewayClass: # @schema additionalProperties: false
# -- Additional gatewayClass labels (e.g. for filtering gateway objects by custom labels)
labels: {}

api:
api: # @schema additionalProperties: false
# -- Enable the dashboard
dashboard: true
# -- Enable the insecure API (HTTP)
insecure: # @schema type:[boolean, null]
# -- Enable the debug API
debug: # @schema type:[boolean, null]
# -- Configure API basePath
basePath: "" # @schema type:[string, null]; default: "/"

Expand Down