fix: make k3d local dev cluster commands work on Windows - #887
fix: make k3d local dev cluster commands work on Windows#887cordeirops wants to merge 3 commits into
Conversation
- Port scripts/kfp-dev-setup.sh to Python (kfp-dev-setup.py); bash-only syntax (kill, pkill, background jobs) doesn't run under Windows cmd.exe without WSL/git-bash. - Fix kubeconfig host.docker.internal -> 127.0.0.1 rewrite so kubectl on Windows can reach the k3d API server. - Add Windows branches to check-uv/dev Makefile targets (uv install, PATH fallback, labextension junction instead of symlink) so the full `make dev && make jupyter` flow works cross-platform. Signed-off-by: Pedro Sbaraini Cordeiro <pedro.sbarainicordeiro@gmail.com>
ederign
left a comment
There was a problem hiding this comment.
See my comments iunline. We mostly need to guard the kubeconfig fix behind sys.platform == "win32" and scope it to the specific cluster context.
… Windows only Address review feedback on PR kubeflow#887 from @ederign: - fix_kubeconfig_host_docker_internal() now guards on sys.platform == "win32" (the DNS resolution issue it works around is Windows-only) and rewrites only the k3d-<cluster_name> cluster entry via `kubectl config set-cluster`, instead of blindly replacing every occurrence of host.docker.internal anywhere in the kubeconfig file. Verified this no longer touches unrelated contexts (e.g. docker-desktop) that happen to also use host.docker.internal. - Makefile: replaced the hardcoded `.venv` path in the labextension junction step with a `VENV_DIR ?= .venv` variable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Pedro Sbaraini Cordeiro <pedro.sbarainicordeiro@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@cordeirops shell script is so much fun! :) The two things I asked for are both correctly addressed. I checked the branch out locally and hit two new problems, both on the Linux/macOS side. That matches the one unchecked box in your test plan. CI is green but doesn't cover either, so there was no way for you to have seen them from Windows. 1.
|
Address remaining feedback from @ederign on kfp-dev-* Windows compat: - Makefile: the pre-commit fallback message had a literal comma inside a $(if ...) call, which GNU make parses as the true/false-branch separator. This silently truncated the Windows branch and merged the Unix branch's leading text into it, turning `run:` into the command name and swallowing `uv run pre-commit install` entirely (masked by the existing 2>nul). Verified with `make -n dev` that both branches now resolve to the intended single command. - Makefile: kfp-dev-* targets called bare `python`, which doesn't exist on stock macOS (removed in 12.3) or Debian/Ubuntu without python-is-python3. Added a PYTHON variable (python3 by default, python on Windows, since python3 there resolves to the Microsoft Store app-execution alias) and used it in all six targets. Verified with `make -n kfp-dev-setup OS=` that the Unix branch now resolves to `python3`. - kfp-dev-setup.py: the Windows port-forward cleanup filter matched any kubectl port-forward for ml-pipeline-ui, unlike the Unix pkill pattern which scopes by port. Added the port to the WMI filter so it only kills the port-forward this script owns. - kfp-dev-setup.py: status_cluster's `except Exception` after a subprocess.run() call without check=True was unreachable dead code (subprocess.run doesn't raise on non-zero exit by default), so an unreachable cluster fell through to kubectl's raw error instead of the friendly message. Added check=True so the except actually fires. - kfp-dev-setup.py: wrapped the main() entry point in a single try/except CalledProcessError so failed kubectl/k3d commands (e.g. in create_cluster/apply_kfp_manifests) print a clean error via die() instead of a raw Python traceback, matching the old bash script's `set -e` behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Pedro Sbaraini Cordeiro <pedro.sbarainicordeiro@gmail.com>
|
Hi @ederign, thanks for the thorough second pass! All four items fixed in 6729330:
I do not have a real Linux/macOS box to test on, so I have only confirmed the Windows side directly and the Unix branch via |
Hi all, could someone take a look at this? I ran into a few issues getting the k3d local dev cluster working on Windows and put together fixes for them.
Summary
Follow-up to #753. The
kfp-dev-*Make targets (and thedev/jupytertargets they sit alongside) only worked on Linux/macOS — running them on a
native Windows shell (cmd.exe, no WSL/git-bash) failed at multiple points.
This fixes that while keeping Linux/macOS behavior unchanged, and documents
the k3d workflow in CONTRIBUTING.md (it was never documented in #753).
Changes
scripts/kfp-dev-setup.sh→scripts/kfp-dev-setup.py: ported thecluster setup/start/stop/delete/status/upgrade script to Python. The bash
script relied on
kill,pkill, background jobs (&), andset -euo pipefail, none of which are available on native Windows withoutWSL or git-bash.
host.docker.internalkubeconfig entry that k3d writes but thatkubectlcan't resolve/reach from native Windows, rewriting it to127.0.0.1after cluster creation/context switch.taskkill /Fon Windows whenos.killisn'tenough.
Makefile:kfp-dev-*targets now callpython scripts/kfp-dev-setup.pyinstead ofbash scripts/kfp-dev-setup.sh.UVnow falls back to%USERPROFILE%\.local\bin\uv.exeon Windows whenuvisn't found onPATH— a freshly-installeduvdoesn't show up inan already-open terminal's
PATHuntil the terminal is restarted.check-uvanddevgained Windows branches for the lines that usedbash-only syntax (
printf, inlineVAR=val cmd,command -v,{ }grouping) — cmd.exe doesn't understand any of it.
dev's labextension link step creates a directory junction (mklink /J)directly on Windows instead of calling
jupyter labextension develop --overwrite ., which fails there withOSError: Cannot call rmtree on a symbolic link(Python'sshutil.rmtreerefuses to remove a Windowsdirectory symlink/junction).
CONTRIBUTING.md/docs/source/contributing.md: document the k3dlocal dev cluster workflow (
make kfp-dev-setup→kfp-dev-start→dev/jupyter), which had no documentation since feat(dev): add lightweight KFP local dev cluster via k3d #753.No change to Linux/macOS code paths — every Windows branch is gated behind
$(OS) == Windows_NT/sys.platform == 'win32'.Test plan
make kfp-dev-setup— cluster create, KFP deploy, port-forward — onWindows (cmd.exe)
make dev— uv sync, labextension build + link, pre-commit — onWindows (cmd.exe)
run before merge)