notebooks/components/notebook-controller
Kimonas Sotirchos 1d24b75f57 notebooks: Fix endless restarts (kubeflow/kubeflow#6341)
* notebooks: Update notebook if timestamp changed

We don't want to be updating the spec of the notebook if the timestamp
hasn't changed, since this will lead to constant updates and
reconciliation loops.

Signed-off-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>

* notebooks: Use a deep-copy of the notebook spec

The controller should use a deep-copy of the notebook spec when
calculating the spec for the StatefulSet. If not then we could
update the notebook object without wanting it, since the spec could have
been changed when calculating the STS spec.

Signed-off-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>

* notebooks: Add prefix env var only if missing

The controller should be setting OR updating the NB_PREFIX env var.
Previously it would always blindly append it to the spec, which could
result in double entries for the same env var.

Signed-off-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>
2022-02-09 17:32:07 +00:00
..
api Notebook Controller: Consolidate manifests (kubeflow/kubeflow#5723) 2021-03-19 10:22:16 -07:00
config Update images for the 1.5 rc0 release (kubeflow/kubeflow#6319) 2022-01-27 14:16:10 +00:00
controllers notebooks: Fix endless restarts (kubeflow/kubeflow#6341) 2022-02-09 17:32:07 +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 notebooks: Fix endless restarts (kubeflow/kubeflow#6341) 2022-02-09 17:32:07 +00:00
third_party Add licensing info for Notebook Controller (kubeflow/kubeflow#4623) 2020-01-06 23:20:17 -08:00
.gitignore fix notebook controller manifests (kubeflow/kubeflow#5729) 2021-03-19 16:09:17 -07:00
Dockerfile Upgrading the `go` compiler version. (kubeflow/kubeflow#5394) 2021-01-12 04:10:25 -08:00
Makefile notebooks: Extend Notebook Controller to expose idleness for Jupyter (kubeflow/kubeflow#6297) 2022-02-07 15:19:17 +00:00
OWNERS Add thesuperzapper to notebook OWNERS (kubeflow/kubeflow#5363) 2020-10-27 08:24:00 -07:00
PROJECT Add Notebook Controller v1 spec (kubeflow/kubeflow#4649) 2020-01-13 19:43:08 -08:00
README.md notebooks: Extend Notebook Controller to expose idleness for Jupyter (kubeflow/kubeflow#6297) 2022-02-07 15:19:17 +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 Upgrading the `go` compiler version. (kubeflow/kubeflow#5394) 2021-01-12 04:10:25 -08:00
go.sum Implemented functional tests using ginkgo for notebook controller (kubeflow/kubeflow#5378) 2020-11-11 05:57:49 -08:00
main.go Fixes the default leader election ID (kubeflow/kubeflow#5374) 2020-11-02 23:22:17 -08:00
skaffold.yaml Fix docker builds of notebook and tensorboard controller (kubeflow/kubeflow#4664) 2020-01-21 17:54:34 -08:00

README.md

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.

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.

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.

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.

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
    

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.