Skip to content

Commit 34e6fd2

Browse files
helm-chart: add traefik.installTraefik config to opt-out when traefik is installed separately (#857)
* feat: Make traefik installation optional This makes traefik installation optional. Installation of CRDs happens if traefik is set to not be installed as well. Helm has built in functionality for not installing CRDs with --skip-crds, however for this project that is suboptimal, because it also blocks the install of `daskclusters.gateway.dask.org` CRD. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * skip CRDs in tests when testing without traefik * add description on how to install daskclusters crd manually * docs: update docs with information about how to install without traefik * fix docs layout --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 074730c commit 34e6fd2

File tree

8 files changed

+133
-0
lines changed

8 files changed

+133
-0
lines changed

.github/workflows/test.yaml

+88
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,94 @@ jobs:
268268
deploy/controller-test-dask-gateway
269269
deploy/traefik-test-dask-gateway
270270
271+
272+
kubernetes-optional-traefik-test:
273+
name: Test k8s backend & chart with traefik installed
274+
runs-on: ubuntu-24.04
275+
timeout-minutes: 15
276+
277+
strategy:
278+
fail-fast: false
279+
280+
steps:
281+
- uses: actions/checkout@v4
282+
with:
283+
# chartpress requires git history to set chart version and image tags
284+
# correctly
285+
fetch-depth: 0
286+
- uses: actions/setup-python@v5
287+
with:
288+
python-version: "3.13"
289+
290+
# Starts a k8s cluster with NetworkPolicy enforcement and installs both
291+
# kubectl and helm
292+
#
293+
# ref: https://github.com/jupyterhub/action-k3s-helm/
294+
#
295+
- uses: jupyterhub/action-k3s-helm@v4
296+
with:
297+
k3s-channel: v1.31
298+
metrics-enabled: false
299+
traefik-enabled: false
300+
docker-enabled: true
301+
302+
- name: Install Python test requirements
303+
run: |
304+
DASK_GATEWAY_SERVER__NO_PROXY=true pip install -r tests/requirements.txt
305+
pip list
306+
307+
- name: Generate values.schema.json from YAML equivalent
308+
run: resources/helm/tools/generate-json-schema.py
309+
310+
- working-directory: resources/helm
311+
env:
312+
# DOCKER_BUILDKIT is required for building images with --mount flags,
313+
# as used in dask-gateway/Dockerfile.
314+
DOCKER_BUILDKIT: "1"
315+
run: chartpress
316+
317+
- name: Install traefik
318+
run: |
319+
helm repo add traefik https://helm.traefik.io/traefik
320+
helm install traefik traefik/traefik \
321+
--namespace traefik \
322+
--create-namespace \
323+
--set ports.web.nodePort=30200
324+
325+
- name: install dask gateway crd
326+
run: |
327+
kubectl apply -f resources/helm/dask-gateway/crds/daskclusters.yaml
328+
329+
- name: helm install
330+
run: |
331+
helm install \
332+
test-dask-gateway \
333+
resources/helm/dask-gateway \
334+
--values=resources/helm/testing/chart-install-values.yaml \
335+
--set traefik.installTraefik=false \
336+
--set gateway.backend.namespace=default \
337+
--skip-crds \
338+
--wait \
339+
--timeout 1m0s
340+
341+
- name: pytest
342+
run: |
343+
TEST_DASK_GATEWAY_KUBE=true \
344+
TEST_DASK_GATEWAY_KUBE_ADDRESS=http://localhost:30200/services/dask-gateway/ \
345+
TEST_DASK_GATEWAY_KUBE_NAMESPACE=default \
346+
pytest -v tests/kubernetes
347+
348+
# ref: https://github.com/jupyterhub/action-k8s-namespace-report
349+
- name: Kubernetes namespace report
350+
uses: jupyterhub/action-k8s-namespace-report@v1
351+
if: always()
352+
with:
353+
important-workloads: >-
354+
deploy/api-test-dask-gateway
355+
deploy/controller-test-dask-gateway
356+
deploy/traefik-test-dask-gateway
357+
358+
271359
# These tests starts a container with a specific backend (that can start
272360
# schedulers/workers somehow), and installing test dependencies and running
273361
# tests from within the container.

docs/source/install-kube.rst

+25
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,31 @@ dask-gateway client to authenticate with JupyterHub.
390390
)
391391
392392
393+
Opting out of traefik install
394+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395+
396+
If traefik is already installed in your cluster, you can opt out of installing it.
397+
This can be done by setting the ``traefik.installTraefik`` value to ``false`` in your
398+
``values.yaml`` file.
399+
400+
.. code-block:: yaml
401+
402+
traefik:
403+
installTraefik: false
404+
405+
This will prevent the traefik service from being installed when you run the helm chart.
406+
When running helm you might want to not install the CRDs for traefik as well.
407+
This can be done by supplying the ``--skip-crds`` flag to the helm command.
408+
However this prevents the daskclusters crd from being installed.
409+
This needs to be installed manually.
410+
411+
Replace 2024.1.0 with the version of dask-gateway you are using.
412+
413+
.. code-block:: shell
414+
415+
kubectl apply \
416+
-f https://raw.githubusercontent.com/dask/dask-gateway/2024.1.0/resources/helm/dask-gateway/crds/daskclusters.yaml
417+
393418
.. _helm-chart-reference:
394419

395420
Helm chart reference

resources/helm/dask-gateway/templates/traefik/dashboard.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{- if .Values.traefik.dashboard -}}
2+
{{- if .Values.traefik.installTraefik -}}
23
apiVersion: traefik.io/v1alpha1
34
kind: IngressRoute
45
metadata:
@@ -15,3 +16,4 @@ spec:
1516
- name: api@internal
1617
kind: TraefikService
1718
{{- end }}
19+
{{- end }}

resources/helm/dask-gateway/templates/traefik/deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.traefik.installTraefik -}}
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
@@ -107,3 +108,4 @@ spec:
107108
imagePullSecrets:
108109
{{- . | toYaml | nindent 8 }}
109110
{{- end }}
111+
{{- end }}

resources/helm/dask-gateway/templates/traefik/rbac.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{- if .Values.rbac.enabled -}}
2+
{{- if .Values.traefik.installTraefik -}}
23
{{- if not .Values.rbac.traefik.serviceAccountName -}}
34
kind: ServiceAccount
45
apiVersion: v1
@@ -77,3 +78,4 @@ subjects:
7778
namespace: {{ .Release.Namespace }}
7879
{{- end }}
7980
{{- end }}
81+
{{- end }}

resources/helm/dask-gateway/templates/traefik/service.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.traefik.installTraefik -}}
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -36,3 +37,4 @@ spec:
3637
targetPort: 9000
3738
port: 9000
3839
{{- end }}
40+
{{- end }}

resources/helm/dask-gateway/values.schema.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ properties:
478478
- loglevel
479479
- dashboard
480480
- service
481+
- installTraefik
481482
description: |
482483
`traefik` nested config relates to the `traefik` Pod and Traefik running
483484
within it that is acting as a proxy for traffic towards the gateway or
@@ -493,6 +494,11 @@ properties:
493494
running in the `traefik` pod.
494495
properties: *image-properties
495496
imagePullSecrets: *imagePullSecrets-spec
497+
installTraefik:
498+
type: boolean
499+
description: |
500+
If traefik is already installed in the cluster, we do not need to
501+
install traefik.
496502
annotations: *labels-and-annotations-spec
497503
resources: *resources-spec
498504
nodeSelector: *nodeSelector-spec

resources/helm/dask-gateway/values.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ controller:
234234
# that is acting as a proxy for traffic towards the gateway or user created
235235
# DaskCluster resources.
236236
traefik:
237+
# If traefik is already installed in the cluster, we do not need to install traefik
238+
# To not install CRDs use --skip-crds flag with helm install, the daskclusters crd then
239+
# needs to be installed manually.
240+
# `kubectl apply -f https://raw.githubusercontent.com/dask/dask-gateway/main/resources/helm/dask-gateway/crds/daskclusters.yaml`
241+
installTraefik: true
242+
237243
# Number of instances of the proxy to run
238244
replicas: 1
239245

0 commit comments

Comments
 (0)