Skip to content

feat: Add Tilt setup for kubeflow-notebook backend #422

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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions workspaces/backend/Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("ext://restart_process", "docker_build_with_restart")

local_resource(
"backend-bin",
"CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ../bin/backend cmd/main.go",
deps=["cmd", "internal", "go.mod", "go.sum"],
)


docker_build_with_restart(
"backend",
context="..", # this is where dev.Dockerfile lives
dockerfile="devenv/dev.Dockerfile",
entrypoint=["/backend"],
only=["bin/backend"],
live_update=[
sync("../bin/backend", "/backend"),
],
)

k8s_yaml("devenv/backend.yaml")

k8s_resource("backend", port_forwards=4000)
75 changes: 75 additions & 0 deletions workspaces/backend/devenv/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: 1
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
serviceAccountName: backend-svc # custom service account
containers:
- name: backend
image: backend
ports:
- containerPort: 4000

---
# Service
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 80
targetPort: 4000

---
# ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
name: backend-svc
namespace: default

---
# ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: backend-role
rules:
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
- apiGroups: ["kubeflow.org"]
resources: ["workspacekinds"]
verbs: ["get", "list", "watch","create","update","delete"] # ["get", "list", "watch", "create", "update", "delete"]
- apiGroups: ["kubeflow.org"]
resources: ["workspaces"]
verbs: ["get", "list", "watch", "create", "update", "delete"]

---
# ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: backend-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: backend-role
subjects:
- kind: ServiceAccount
name: backend-svc
namespace: default
7 changes: 7 additions & 0 deletions workspaces/backend/devenv/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.18

WORKDIR /app

COPY bin/backend /backend

ENTRYPOINT ["/backend"]
Loading