Skip to content

feat(ws): Properly containerize backend component #323 #386

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

liavweiss
Copy link

@liavweiss liavweiss commented May 26, 2025

closes: #323

In this pr I fixed the make docker-build + make docker-buildx.

NOTE: When you run "make docker-buildx" you will get this ERROR:
"ERROR: failed to solve: failed to push nbv2-backend:latest: push access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
make: [Makefile:135: docker-buildx] Error 1 (ignored)",
Because we didn't specify the right registry in the Makefile.

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 kimwnasptd 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

@liavweiss liavweiss force-pushed the backend_dockerfile/#323 branch from 0ffaa72 to a89a08e Compare May 27, 2025 14:14
@google-oss-prow google-oss-prow bot added size/S and removed size/M labels May 27, 2025
Comment on lines +13 to 16
RUN go mod edit -replace=github.com/kubeflow/notebooks/workspaces/controller=./controller

# Download dependencies
RUN go mod download

Choose a reason for hiding this comment

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

These back-to-back RUN commands can be more efficiently combined to reduce a spurious layer

RUN go mod edit -replace=github.com/kubeflow/notebooks/workspaces/controller=./controller && \
    go mod download

COPY backend/cmd/ cmd/
COPY backend/api/ api/
COPY backend/internal/ internal/
COPY backend/openapi/ openapi/

# Build the Go application
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o backend ./cmd/main.go

Choose a reason for hiding this comment

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

Unrelated to changes in this PR - but I'm confused by the use case of specifying TARGETARCH here...

Our Makefile never sets this build argument... so do we even need it? Under what circumstance would it need to be defined?

@@ -110,7 +111,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross

Choose a reason for hiding this comment

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

Again, unrelated to the changes in this PR - but I am confused as to why we have 2 separate expressions ( -e ) in this sed command...

Our Dockerfile has a comment on Line 1 - so (at least today) - the initial -e command will never pass. And since we are not relying on that initial command - unclear why we even attempt to support it (?)

Clearly the 2nd expression is "robust enough" - as we are relying on it today...

@andyatmiami
Copy link

andyatmiami commented May 30, 2025

In order to properly test this change - I wanted to get the container image running in k8s
to really "see" it work.

The following was my testing methodology:

  • Deploy KinD cluster and deploy controller and all necessary config (cert-manager, CRDs, etc)
  • gmake docker-build docker-push IMG=quay.io/rh-ee-astonebe/kubeflow-notebooks-v2:backend-containerize
  • kind load docker-image quay.io/rh-ee-astonebe/kubeflow-notebooks-v2:backend-containerize
  • crafted crude backend-rbac.yaml and backend-deployment.yaml to provide minimal scaffolding for container (see attached)
  • kubectl apply -f backend-rbac.yaml
  • kubectl apply -f backend-deployment.yaml
  • kubectl port-forward svc/backend 4000:4000
  • curl http://localhost:4000/api/v1/healthcheck
  • curl http://localhost:4000/api/v1/workspacekinds
  • curl http://localhost:4000/api/v1/workspaces
  • curl http://localhost:4000/api/v1/workspaces/default

All API calls tested above returned successfully with expected JSON payloads reflecting the state of my cluster!

backend-rbac.yaml.txt
backend-deployment.yaml.txt

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.

2 participants