Skip to content

feat(ws): Notebooks 2.0 // Backend // Create mocked resources #345

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 1 commit into
base: notebooks-v2
Choose a base branch
from

Conversation

yehudit1987
Copy link

This PR solve Issue #342

  • Created new targets at the existing Makefile:
  1. For workspacekinds and workspaces creation.
  2. For clean those resources.

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 assign thesuperzapper for approval. 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

@yehudit1987 yehudit1987 force-pushed the create-mocked-resources branch from 6a1933b to 4261b5a Compare May 15, 2025 13:00
Comment on lines +169 to +173
YQ_VERSION = v4.30.6
YQ_BINARY = /usr/local/bin/yq
KUBECTL_VERSION = v1.27.3
KUBECTL_BINARY = /usr/local/bin/kubectl

Choose a reason for hiding this comment

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

Can we move this section to be declared up with other dependencies here:

Additionally - we already have a KUBECTL Makefile var:

We should either continue to use that... or remove that.. but I think its too confusing having all these defined:

  • KUBECTL
  • KUBECTL_VERSION
  • KUBECTL_BINARY

Comment on lines +175 to +178
WORKSPACEKIND_FILES = data_setup/workspacekinds/jupyterlab_v1beta1_workspacekind.yaml \
data_setup/workspacekinds/codeserver_v1beta1_workspacekind.yaml \
data_setup/workspacekinds/rstudio_v1beta1_workspacekind.yaml

Choose a reason for hiding this comment

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

Might be nice to use a file glob pattern here instead of explicitly listing the files - so that in the future if/when we want to add more "test data" (or remove data) - it would just automatically work ...

install-yq:
$(call install-if-missing,yq,\
sudo wget -q "https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_linux_amd64" -O $(YQ_BINARY) && sudo chmod +x $(YQ_BINARY))
Copy link

@andyatmiami andyatmiami May 15, 2025

Choose a reason for hiding this comment

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

we probably want this to be smarter to detect the OS and form the URL appropriately so other (at least MacOS/arm) platforms are supported

install-kubectl:
$(call install-if-missing,kubectl,\
sudo curl -LO "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl" && sudo chmod +x kubectl && sudo mv kubectl $(KUBECTL_BINARY))

Choose a reason for hiding this comment

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

we probably want this to be smarter to detect the OS and form the URL appropriately so other (at least MacOS/arms) platforms are supported

endef

.PHONY: install-yq install-kubectl create-workspacekinds create-workspaces setup-all clean

Choose a reason for hiding this comment

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

For consistency - I'd follow the convention present in this file to declare a .PHONY directly preceding each Makefile target...

volumeMounts:

## the path to mount the home PVC (NOT MUTABLE)
home: "/home/jovyan"

Choose a reason for hiding this comment

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

while admittedly it DOES NOT MATTER - /home/jovyan is a JupyterLab thing

If there is a more appropriate RStudio home directory value.. we should use it... but offhand I'm not clear what that value would be... 🤔

volumeMounts:

## the path to mount the home PVC (NOT MUTABLE)
home: "/home/jovyan"

Choose a reason for hiding this comment

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

while admittedly it DOES NOT MATTER - /home/jovyan is a JupyterLab thing

If there is a more appropriate codeserver home directory value.. we should use it... but offhand I'm not clear what that value would be... 🤔

Comment on lines +214 to +228
@for id in $(WORKSPACE_IDS); do \
echo "Creating workspace workspace-$$id..."; \
eval "case $$id in \
1|2|3) workspace_kind_file=data_setup/workspacekinds/jupyterlab_v1beta1_workspacekind.yaml;; \
4|5|6) workspace_kind_file=data_setup/workspacekinds/codeserver_v1beta1_workspacekind.yaml;; \
*) workspace_kind_file=data_setup/workspacekinds/rstudio_v1beta1_workspacekind.yaml;; \
esac"; \
workspace_kind_name=$$(yq '.metadata.name' "$$workspace_kind_file"); \
image_config_id=$$(yq '.spec.podTemplate.options.imageConfig.spawner.default' "$$workspace_kind_file" | sed 's|"||g'); \
pod_config_id=$$(yq '.spec.podTemplate.options.podConfig.spawner.default' "$$workspace_kind_file"); \
sed "s/{workspace_id}/$$id/g; s/{WorkspaceKind}/$$workspace_kind_name/g; s/{imageConfig_id}/$$image_config_id/g; s/{podConfig_id}/$$pod_config_id/g" $(WORKSPACE_TEMPLATE_FILE) | \
sed '/^spec:/a \ paused: true' | \
kubectl apply -f -; \
done

Choose a reason for hiding this comment

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

FOR DISCUSSION (not necessarily suggesting a change)

I feel like leveraging kustomize here might be a more natural fit and still gives us the "templating" behavior...

While your solution certainly yields less overall lines of code - kustomize might be "more familiar" to developers

@ederign
Copy link
Member

ederign commented May 17, 2025

/label hold

Copy link

@ederign: The label(s) /label hold cannot be applied. These labels are supported: tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, lifecycle/needs-triage. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to this:

/label hold

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.

3 participants