Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d1a9ef8
feat(di-trainer/di-jobmonitor/di-lcm/di-cli):
renzhe-li Apr 6, 2022
7ef0b56
feat(appconns/dss-mlflow-appconn): Add MLFlow Appconn
James23Wang Apr 6, 2022
5898faf
"feat(appconns/dss-mlss-appconn): Add MLSS Appconn
hexudong111 Apr 6, 2022
cc5aa2a
feat(mf): Add Model Factory Module
bleachzk Apr 6, 2022
4ebbe3d
feat(isntall): Update install file
alexzyWu Apr 6, 2022
3e9746c
feat(isntall): Update install file
alexzyWu Apr 6, 2022
bd8b620
Merge pull request #46 from alexzyWu/master
alexzyWu Apr 6, 2022
c0b7652
docs(docs): Update docs module
alexzyWu Apr 6, 2022
444d2ce
feat(mllabis): Add resource modification and release
alexzyWu Apr 6, 2022
d691742
1.add
uuarttt Apr 6, 2022
e07d105
Merge pull request #48 from hanwutian/master
alexzyWu Apr 6, 2022
33b87f6
Merge pull request #47 from alexzyWu/mllabis-resource-control-feature
alexzyWu Apr 6, 2022
268f286
Merge pull request #45 from bleachzk/master
alexzyWu Apr 6, 2022
3119e8c
Merge pull request #44 from hexudong111/master
alexzyWu Apr 6, 2022
d42fd7e
Merge pull request #42 from James23Wang/dev
alexzyWu Apr 6, 2022
d0f5db6
Merge pull request #43 from renzhe-li/dev
alexzyWu Apr 6, 2022
f8ef67e
Merge branch 'WeBankFinTech:dev-0.3.0' into dev-0.3.0
alexzyWu Apr 7, 2022
a218e8c
fix(mllabis): Remove parameter limit in notebook creation
alexzyWu Apr 7, 2022
191b003
Merge pull request #50 from alexzyWu/mllabis-parameter-limit
alexzyWu Apr 7, 2022
f61b3e8
fix(ui): update ui
alexzyWu Apr 7, 2022
9263079
fix(ui): Remove output in UI
alexzyWu Apr 7, 2022
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
Prev Previous commit
Next Next commit
feat(mllabis): Add resource modification and release
1、Add resource modification and resource release in notebook server.
2、Optimize log and status viewing function.
3、Add notebook controller(From Kubeflow Controller).
  • Loading branch information
alexzyWu committed Apr 6, 2022
commit 444d2cee1d6d61da5f4389a06ece5aba5d90156b
26 changes: 26 additions & 0 deletions mllabis/notebook-controller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~

gcb_build/**
6 changes: 6 additions & 0 deletions mllabis/notebook-controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Build the manager binary
# Copy the controller-manager into a thin image
FROM ubuntu:latest
WORKDIR /
COPY ./manager .
ENTRYPOINT ["/manager"]
20 changes: 20 additions & 0 deletions mllabis/notebook-controller/Dockerfile_bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Build the manager binary
ARG GOLANG_VERSION=1.11.2
FROM golang:${GOLANG_VERSION} as builder

# Copy in the go src
WORKDIR /go/src/github.com/kubeflow/kubeflow/components/notebook-controller
COPY pkg/ pkg/
COPY cmd/ cmd/
COPY go.mod .

ENV GO111MODULE=on

# Build
RUN go build -gcflags 'all=-N -l' -o manager cmd/manager/main.go

# Copy the controller-manager into a thin image
FROM ubuntu:latest
WORKDIR /
COPY --from=builder /go/src/github.com/kubeflow/kubeflow/components/notebook-controller/manager .
ENTRYPOINT ["/manager"]
82 changes: 82 additions & 0 deletions mllabis/notebook-controller/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

# Image URL to use all building/pushing image targets
IMG ?= gcr.io/kubeflow-images-public/notebook-controller
TAG ?= $(eval TAG := $(shell date +v%Y%m%d)-$(shell git describe --tags --always --dirty)-$(shell git diff | shasum -a256 | cut -c -6))$(TAG)
GOLANG_VERSION ?= 1.11.2

# Whether to use cached images with GCB
USE_IMAGE_CACHE ?= true

all: test manager

# Run tests
test: generate fmt vet manifests
go test ./pkg/... ./cmd/... -coverprofile cover.out

# Build manager binary
manager: generate fmt vet
go build -o bin/manager github.com/kubeflow/kubeflow/components/notebook-controller/cmd/manager

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
go run ./cmd/manager/main.go

# Install CRDs into a cluster
install: manifests
kubectl apply -f config/crds

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all

# Run go fmt against code
fmt:
go fmt ./pkg/... ./cmd/...

# Run go vet against code
vet:
go vet ./pkg/... ./cmd/...

# Generate code
generate:
go generate ./pkg/... ./cmd/...

# Build the docker image
docker-build: test
docker build . -t ${IMG} --build-arg GOLANG_VERSION=$(GOLANG_VERSION)
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

# Push the docker image
docker-push:
docker push ${IMG}

build-gcr: test
docker build -t $(IMG):$(TAG) .
@echo Built $(IMG):$(TAG)

push-gcr: build-gcr
docker push $(IMG):$(TAG)
@echo Pushed $(IMG):$(TAG)

# Build the GCB workflow
build-gcb-spec:
rm -rf ./gcb_build
mkdir -p gcb_build
jsonnet ./gcb_build.jsonnet --ext-str imageBase=$(IMG) \
--ext-str gitVersion=$(GIT_VERSION) --ext-str tag=$(TAG) \
--ext-str useImageCache=$(USE_IMAGE_CACHE) \
> ./gcb_build/image_build.json

# Build using GCB. This is useful if we are on a slow internet connection
# and don't want to pull images locally.
# Its also used to build from our CI system.
build-gcb: build-gcb-spec
gcloud builds submit --machine-type=n1-highcpu-32 --project=kubeflow-ci \
--config=./gcb_build/image_build.json \
--timeout=3600 .
3 changes: 3 additions & 0 deletions mllabis/notebook-controller/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
approvers:
- lluunn
reviewers:
3 changes: 3 additions & 0 deletions mllabis/notebook-controller/PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: "1"
domain: kubeflow.org
repo: github.com/kubeflow/kubeflow/components/notebook-controller
47 changes: 47 additions & 0 deletions mllabis/notebook-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Notebook Controller

The controller allows users to create a custom resource "Notebook" (jupyter notebook).
We originally wrote the controller using jsonnet and metacontroller, but are migrating to golang and
Kubebuilder here. See [discussion](https://github.com/kubeflow/kubeflow/issues/2269).

## Spec

The user needs to specify the PodSpec for the jupyter notebook.
For example:

```
apiVersion: kubeflow.org/v1alpha1
kind: Notebook
metadata:
name: my-notebook
namespace: test
spec:
template:
spec: # Your PodSpec here
containers:
- image: gcr.io/kubeflow-images-public/tensorflow-1.10.1-notebook-cpu:v0.3.0
args: ["start.sh", "lab", "--LabApp.token=''", "--LabApp.allow_remote_access='True'",
"--LabApp.allow_root='True'", "--LabApp.ip='*'",
"--LabApp.base_url=/test/my-notebook/",
"--port=8888", "--no-browser"]
name: notebook
...
```

The required fields are `containers[0].image` and (`containers[0].command` and/or `containers[0].args`).
That is, the user should specify what and how to run.

All other fields will be filled in with default value if not specified.

## Implementation detail

This part is WIP as we are still developing.

Under the hood, the controller creates a StatefulSet to run the notebook instance, and a Service for it.

### TODO
- e2e test (we have one testing the jsonnet-metacontroller one, we should make it run on this one)
- `status` field should reflect the error if there is any. See [#2269](https://github.com/kubeflow/kubeflow/issues/2269).
- Istio integration (controller will generate istio resources to secure each user's notebook)
- CRD [validation](https://github.com/kubeflow/kubeflow/blob/master/kubeflow/jupyter/notebooks.schema)
- `ttlSecondsAfterFinished`: This is in the original jsonnet controller spec, but not being used yet. I think we want to cleanup the notebook after idle?
68 changes: 68 additions & 0 deletions mllabis/notebook-controller/cmd/manager/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package main

import (
"flag"
"os"

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
"webank/AIDE/notebook-controller/pkg/apis"
"webank/AIDE/notebook-controller/pkg/controller"
"webank/AIDE/notebook-controller/pkg/webhook"
)

func main() {
var metricsAddr string
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.Parse()
logf.SetLogger(logf.ZapLogger(false))
log := logf.Log.WithName("entrypoint")

// Get a config to talk to the apiserver
log.Info("setting up client for manager")
cfg, err := config.GetConfig()
if err != nil {
log.Error(err, "unable to set up client config")
os.Exit(1)
}

// Create a new Cmd to provide shared dependencies and start components
log.Info("setting up manager")
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: metricsAddr})
if err != nil {
log.Error(err, "unable to set up overall controller manager")
os.Exit(1)
}

log.Info("Registering Components.")

// Setup Scheme for all resources
log.Info("setting up scheme")
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
log.Error(err, "unable add APIs to scheme")
os.Exit(1)
}

// Setup all Controllers
log.Info("Setting up controller")
if err := controller.AddToManager(mgr); err != nil {
log.Error(err, "unable to register controllers to the manager")
os.Exit(1)
}

log.Info("setting up webhooks")
if err := webhook.AddToManager(mgr); err != nil {
log.Error(err, "unable to register webhooks to the manager")
os.Exit(1)
}

// Start the Cmd
log.Info("Starting the Cmd.")
if err := mgr.Start(signals.SetupSignalHandler()); err != nil {
log.Error(err, "unable to run the manager")
os.Exit(1)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: notebooks.notebook.kubeflow.org
spec:
group: notebook.kubeflow.org
names:
kind: Notebook
plural: notebooks
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
template:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file'
properties:
spec:
type: object
type: object
type: object
status:
properties:
conditions:
description: Conditions is an array of current conditions
items:
properties:
type:
description: Type of the confition/
type: string
required:
- type
type: object
type: array
required:
- conditions
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
39 changes: 39 additions & 0 deletions mllabis/notebook-controller/config/crds/v1alpha1_notebook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: notebooks.kubeflow.org
spec:
group: kubeflow.org
names:
kind: Notebook
plural: notebooks
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
type: object
status:
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading