Skip to content

feat: setup tilt for easier local controller development #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: notebooks-v2
Choose a base branch
from

Conversation

Al-Pragliola
Copy link

@Al-Pragliola Al-Pragliola commented Feb 27, 2025

closes #41

This PR aims to add Tilt as a local development tool for the project, you can find an initial stub on how to try the PR locally here https://github.com/kubeflow/notebooks/blob/c38ac05c3dad7efd30a5935bbee8a6643baea817/devenv/README.md

@github-project-automation github-project-automation bot moved this to Needs Triage in Kubeflow Notebooks Feb 27, 2025
@Al-Pragliola Al-Pragliola changed the title feat(devend): Notebooks 2.0 // Controller // Update local development guide feat: Notebooks 2.0 // Controller // Update local development guide Feb 27, 2025
@Al-Pragliola Al-Pragliola marked this pull request as ready for review February 27, 2025 16:17
@ederign
Copy link
Member

ederign commented Feb 27, 2025

/assign @thesuperzapper @ederign

@thesuperzapper thesuperzapper changed the title feat: Notebooks 2.0 // Controller // Update local development guide feat: setup tilt for easier local controller development Mar 6, 2025
Copy link
Member

@thesuperzapper thesuperzapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Al-Pragliola thanks so much for your work on this!

So we can merge it, can you make the following changes:

  1. Lets scope all this within the workspaces/controller folder, rather than having things in the root of this repo.
  2. Lets create a DEVELOPMENT.md in the root of workspaces/controller which explains the steps required to run a dev version of the controller with tilt (on any cluster the user might have in their kubecontext, or with kind if they want a clean setup)

In a future PR, we can then have a development guide in the workspaces/backend folder which just points to the controller one as a "first step" before explaining how to use make run in that case (which does not need tilt, at least at this stage).

Comment on lines 6 to 21
helm_repo(
name="jetstack",
url="https://charts.jetstack.io",
resource_name="jetstack-repo",
labels=["common"]
)

helm_resource(
name="cert-manager",
chart="jetstack/cert-manager",
release_name="cert-manager",
namespace="cert-manager",
flags=["--version=v1.17.0", "--set", "crds.enabled=true"],
deps=["namespaces", "cert-manager"],
labels=["common"]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not automatically install cert-manager (or other deps), and instead tell the user to install them with specific commands (if they are not already installed on the cluster they are using).

That way we avoid people accidentally breaking prod clusters.

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from thesuperzapper. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Al-Pragliola
Copy link
Author

Al-Pragliola commented Mar 11, 2025

@Al-Pragliola thanks so much for your work on this!

So we can merge it, can you make the following changes:

1. Lets scope all this within the `workspaces/controller` folder, rather than having things in the root of this repo.

2. Lets create a `DEVELOPMENT.md` in the root of `workspaces/controller` which explains the steps required to run a dev version of the controller with tilt (on any cluster the user might have in their kubecontext, or with kind if they want a clean setup)

In a future PR, we can then have a development guide in the workspaces/backend folder which just points to the controller one as a "first step" before explaining how to use make run in that case (which does not need tilt, at least at this stage).

Thanks for the feedback @thesuperzapper , in the latest commits:

  1. Moved everything under the workspaces/controller folder
  2. Removed the installation of cert-manager, added a check in the make tilt-up target to see if cert-manager is installed in the current cluster
  3. Added a DEVELOPMENT.md file with instructions on how to spin up the development environment in the workspaces/controller folder

let me know wdyt 🙏🏼


- Go >= 1.22
- Kubectl >= 1.22
- A Kubernetes cluster (e.g. [kind](https://kind.sigs.k8s.io/))

This comment was marked as resolved.


## Getting Started

This project uses [Tilt](https://tilt.dev/) to manage the development environment. Tilt will watch for changes in the project and automatically rebuild the Docker image and redeploy the application in the **current Kubernetes context**.

This comment was marked as resolved.

2. Run the following command to start Tilt:

```bash
make -C devenv tilt-up

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed following the comment #220 (comment)

Comment on lines 50 to 56
2. Run the following command to start Tilt:

```bash
make -C devenv tilt-up
```

3. Hit `space` to open the Tilt dashboard in your browser and here you can see the logs and status of every resource deployed.

This comment was marked as resolved.


## Requirements

CERT_MANAGER_VERSION := 1.17.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really wanna hard-code the version of CM here? If so, we probably need additional guidance on the CM install above... as directing users to the general Cert Manager install doc is going to end up with them installing whatever the latest version is...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, let's tune down tech debt I have updated the message to

Verifying cert-manager installation...
cert-manager is either not installed or not ready. Please install cert-manager or wait until it becomes ready.
Installation instructions can be found here: https://cert-manager.io/docs/installation/

wdyt?

$(TILT): $(LOCALBIN)
test -s $(LOCALBIN)/tilt || curl -fsSL https://github.com/tilt-dev/tilt/releases/download/v$(TILT_VERSION)/tilt.$(TILT_VERSION).$(detected_OS).$(arch).tar.gz | tar -xz -C $(LOCALBIN) tilt

tilt-up: tilt check-cert-manager

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for checking this PR, yes the Makefile had a bug in line 25, cmctl was meant to be in line 26, I fixed it in the latest commit eda5804

.PHONY: $(CMCTL)
cmctl: $(CMCTL)
$(CMCTL): $(LOCALBIN)
test -s $(LOCALBIN)/cmctl || curl -fsSL https://github.com/cert-manager/cmctl/releases/download/v$(CMCTL_VERSION)/cmctl_$(detected_OS)_$(goarch).tar.gz | tar -xz -C $(LOCALBIN) cmctl

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed thanks

Copy link

@andyatmiami andyatmiami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good news is I was finally able to get tilt-up to work - thanks for those changes...

I am now facing this error displayed in tilt dashboard:
image

The controller error seems to be the real error - so we should investigate that... possibly due to me being on arm64 machine?

I am also confused why the cert-manager-req check has a red X as its status 🤔

Please advise on both points - thanks!

Comment on lines +14 to +21
objects = decode_yaml_stream(manifests)

for o in objects:
if o["kind"] == "Deployment" and o.get("metadata").get("name") in ["workspace-controller-controller-manager"]:
o["spec"]["template"]["spec"]["securityContext"] = {"runAsNonRoot": False, "readOnlyRootFilesystem": False}
o["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "Always"

overridden_manifests = encode_yaml_stream(objects)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we are programmatically modifying manifests here... instead of using kustomize overlays?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to create an overlay for local development, but I am open to do it if the community agrees

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thesuperzapper what are your thoughts on a kustomize local development overlay vs. this programmatic approach?

@Al-Pragliola Al-Pragliola force-pushed the al-pragliola-tilt-integration branch from 8e6fc0b to 32585fc Compare April 2, 2025 20:32
@Al-Pragliola Al-Pragliola force-pushed the al-pragliola-tilt-integration branch from 32585fc to efb3377 Compare April 2, 2025 20:35
@Al-Pragliola Al-Pragliola requested a review from andyatmiami April 2, 2025 20:38
@@ -0,0 +1,71 @@
# Development Guide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Al-Pragliola can we please add something about running the the tests locally before raising a PR:

  • make lint
  • make test (for unit tests without a local kube/kind)
  • make test-e2e (run intergration tests on a local kube)

As people wont know they need to do this otherwise

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrote a small section in 7879d29

Comment on lines 25 to 34
local_resource(
"cert-manager-req-check",
serve_cmd="sleep infinity",
labels="requirements",
readiness_probe=probe(
exec=exec_action(
command=["/bin/sh", "-c", "./bin/cmctl check api"]
), initial_delay_secs=5, timeout_secs=60
)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Al-Pragliola - I'm confused by this config block (and it has a portability issue)

(1) sleep infinity fails for me - locally I changed this to: serve_cmd="while true; do sleep 3600; done",

(2) however, I'm not sure of the purpose of this block to begin with... if I understand correctly... local_resource does not support a readiness_probe attribute... so this entire section seems to ONLY then issue a perpetual sleep command ... The cert-manager check is also being done as part of the Makefile commands - so can we remove this block from Tilefilt?

Please advise.

Copy link
Author

@Al-Pragliola Al-Pragliola Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyatmiami

(1) ok I'll change it to make it compatible with macos users
(2) local_resource has the readiness_probe attribute https://docs.tilt.dev/api.html#api.local_resource , so this resource was needed to trigger the deployment of the controller when cert-manager was ready. I would like to not remove the check from Tilt because if someone does not use the makefile target and just runs tilt up, it would skip the check and fail to deploy the controller

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) addressed in 2c096e2

@andyatmiami
Copy link

/lgtm

been working off this branch for the past couple days and find it operates as desired and improves development experience

Copy link

@andyatmiami: changing LGTM is restricted to collaborators

In response to this:

/lgtm

been working off this branch for the past couple days and find it operates as desired and improves development experience

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

4 participants