notebooks/components/notebook-controller
Samu 0215857aa9 Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374)
Fix https://github.com/kubeflow/kubeflow/issues/6366

Migrating to Kubebuilder v3 leads to the following changes:
- Add .dockerignore file.
- Upgrade Go version from v1.15 to v1.17.
- Adapt Makefile.
- Add image (build + push) target to makefile.
- Upgrade EnvTest to use K8s v1.22.
- Update PROJECT template.
- Migrate CRD apiVersion from v1beta to v1.
- Add livenessProbe and readinessProbe to controller manager.
- Upgrade controller-runtime from v0.2.0 to v0.11.0.

Other changes:
- Build image using public.ecr.aws registry instead of gcr.io.
- Update README.md documentation.
- Update 3rd party licences.
- Fix notebook.spec description.
- Add 3 sample notebooks (v1, v1alpha1 and v1beta1).

Signed-off-by: Samuel Veloso <svelosol@redhat.com>
2022-05-03 15:49:01 +00:00
..
api Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
config Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
controllers Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
hack Migrate notebook CR to kubebuilder V2 (kubeflow/kubeflow#4013) 2019-09-04 17:06:22 -07:00
loadtest add loadtest for notebook controller (kubeflow/kubeflow#4779) 2020-02-18 21:00:25 -08:00
pkg Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
third_party Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
.dockerignore Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
.gitignore fix notebook controller manifests (kubeflow/kubeflow#5729) 2021-03-19 16:09:17 -07:00
Dockerfile Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
Makefile Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
OWNERS Add thesuperzapper to notebook OWNERS (kubeflow/kubeflow#5363) 2020-10-27 08:24:00 -07:00
PROJECT Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
README.md Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
developer_guide.md Fix docker builds of notebook and tensorboard controller (kubeflow/kubeflow#4664) 2020-01-21 17:54:34 -08:00
go.mod Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
go.sum Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
main.go Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00
skaffold.yaml Support K8s 1.22 in notebook controller (kubeflow/kubeflow#6374) 2022-05-03 15:49:01 +00:00

README.md

Notebook Controller

The controller allows users to create a custom resource "Notebook" (jupyter notebook).

It has been developed using Golang and Kubebuilder.

Spec

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

apiVersion: kubeflow.org/v1
kind: Notebook
metadata:
  name: my-notebook
spec:
  template:
    spec:
      containers:
        - name: my-notebook
          image: public.ecr.aws/j1r0q0g6/notebooks/notebook-servers/jupyter:master
          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",
            ]

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.

Environment parameters

Parameter Description
ADD_FSGROUP If the value is true or unset, fsGroup: 100 will be included in the pod's security context. If this value is present and set to false, it will suppress the automatic addition of fsGroup: 100 to the security context of the pod.
DEV If the value is false or unset, then the default implementation of the Notebook Controller will be used. If the admins want to use a custom implementation from their local machine, they should set this value to true.

Commandline parameters

metrics-addr: The address the metric endpoint binds to. The default value is :8080.

probe-addr: The address the health endpoint binds to. The default value is :8081.

enable-leader-election: Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager. The default value is false.

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.

Deployment

Install the notebooks.kubeflow.org CRD:

make install

Deploy the notebook controller manager:

make deploy

Verify that the controller is running in the notebook-controller-system namespace:

$ kubectl get pods -l app=notebook-controller -n notebook-controller-system
NAME                                             READY   STATUS    RESTARTS   AGE
notebook-controller-deployment-564d76877-mqsm8   1/1     Running   0          16s

Clean-up

Uninstall the notebook controller manager:

make undeploy

Uninstall the notebooks.kubeflow.org CRD:

make uninstall

Contributing

https://www.kubeflow.org/docs/about/contributing/

Development Environment

To develop on notebook-controller, your environment must have the following:

In order for the custom Notebook Controller to be functional from your local machine, the admins must:

  1. Set the number of replicas to zero:
    kubectl edit deployment notebook-controller-deployment -n=kubeflow
    
  2. Allow the controller to proxy the traffic to the Notebook Services by executing on your local machine:
    kubectl proxy
    
  3. Start the manager locally in developer mode:
    export DEV="true"
    make run
    

Testing

Make sure all the tests are passing after you add a new feature:

make test

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.
  • Istio integration (controller will generate istio resources to secure each user's notebook)
  • CRD validation
  • ttlSecondsAfterFinished: This is in the original jsonnet controller spec, but not being used yet. I think we want to cleanup the notebook after idle?
  • Add more instructions on contributing like build,deploy and test locally.
  • A script for installing all deps.