Commit Graph

9 Commits

Author SHA1 Message Date
apoger d2c76a0739 Implement a culling controller for Notebooks (kubeflow/kubeflow#6807)
* Implement a culling controller for notebooks

Changes:

 * Move the idleness/culling logic into a separate controller
   as part of the Notebooks Controller/Operator.

 * Introduce an "notebooks.kubeflow.org/last_activity_check_timestamp".
   annotation in each Notebook CR to keep the timestamp of the last
   performed idleness check

The controller can then compare this timestamp with the current time to
ensure that notebooks will get reconciled every IDLENESS_CHECK_PERIOD
minutes.

The culling-controller will:

* reconcile only notebooks CRs
* set/update culling annotations
  - 'notebooks.kubeflow.org/last_activity'
  - 'notebooks.kubeflow.org/last_activity_check_timestamp'
* perform idleness checks every 'IDLENESS_CHECK_PERIOD' minutes
  and set the 'kubeflow-resource-stopped' annotation, if a notebook
  needs to be culled.

Refs: kubeflow/kubeflow#6767

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>

* review: Remove culling annotations when Pod is not found

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>

* review: Improve logs

Add a log message at the beginning of the reconciliation loop
to make it clear that a Reconcile was called for a notebook.

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>

* Run the controller locally

* Introduce make rule for running the controller locally with
  culling enabled

* Introduce a dev_culling_authorization_policy which must be
  applied when testing the culling-controller locally

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>

* Update README instructions

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>
2023-01-26 13:32:10 +00:00
apoger 939e1e22ca Introduce a mechanism to build all Kubeflow images (kubeflow/kubeflow#6555)
* build: Update components makefiles for building

We'll create a top-level Makefile under components/ dir
that has the following rules:

* build-all:
  To build all images locally

* push-all:
  * We can use a specific REGISTRY and retag the images
  * Push all the images

This top-level Makefile will run the sub-Makefiles that every
component has for building and pushing the images.

We modified every sub-Makefile as follows:
* We don't use a registry in images by default
* Removed unused rules and vars
* Use the --dirty flag of git describe in TAG

        --dirty[=<mark>]
               Describe the working tree. It means describe HEAD and
               appends <mark> (-dirty by default) if the working tree
               is dirty.

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Create makefiles for notebook servers

The common starting point of building the notebook-server
images are the following 4 *base* images:
- base
- codeserver
- jupyter
- rstudio

All other server images need to build on top of them. We'll
dynamically pass the base images in every Dockerfile by
using an ARG IMG. We can set the value of this ARG during
docker build with the --build-arg CLI argument.

This way we build both the base images with a tag locally,
and then we pass that image as arg via the Makefile and build the rest

So we modified our building procedure as follows:
1. Build the base image since everything starts from there

2. Pass the base image as an ARG in the Dockerfiles of
jupyter, codeserver, rstudio images and build on top

3. Pass the base images in all other server images and build
on top

For that we will:

1. Create a Makefile for each of the notebook servers, in each folder
   a. Each makefile will be responsible for building the bases and use args for passing them on

2. Use the central Makefile to call each Makefile from above

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* cherry-pick: Notebook server upstream fixes

Relevant upstream PR: https://github.com/kubeflow/kubeflow/pull/6466/files

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Fix Makefiles

- Remove build-gcp and build-gcr rules as we don't use them anywhere in
the project
- Fix code conficts

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Fix Dockerfiles for notbook-server images

We remove the previous logic of using already built images as bases.
The users must use only the Makefiles to pass the appropriate BASE_IMG
and build the images correctly.

Thus, we have Makefiles everywhere that:

- Can build any base image
- If an image requires another notebook base, then we first build that one using its makefile,
  and then use it as docker ARG for building the next one

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Fix notebook-controller Makefile

Removed a misplaced "|" char that breaks the Makefile

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Update GH action workflows

* Update workflow for notebook-server images:
  - Add a step for building all images by using the
  central-Makefile under components/example-notebook-servers/ dir.
  - Add a step for pushing all images by using the
  central-Makefile under components/example-notebook-servers/ dir.

* Update workflow for all Kubeflow images:
  - Add a step for building & pushing all images by using the
  top-level Makefile under components/ dir.

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Remove completely ECR references from images

Replace everywhere the "public.ecr.aws/j1r0q0g6/notebooks/notebook-servers"
prefix with "kubeflownotebookswg"

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>

* build: Fix GH actions for Kubeflow components

Fix GH actions to use the updated make rules
when building the Kubeflow component images.

Remove the "docker.io" prefix when building with
GH action workflows

Signed-off-by: Apotolos Gerakaris <apoger@arrikto.com>
2022-07-01 17:54:06 +00:00
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
Athanasios Markou fbf5110f01 notebooks: Extend Notebook Controller to expose idleness for Jupyter (kubeflow/kubeflow#6297)
* notebooks: Update image's tag in make

Modify Makefile to update properly the TAG
based on the git TAG.

Signed-off-by: Athanasios Markou <athamark@arrikto.com>
Reviewed-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>

* notebooks: Expose last-activity

Extend the notebook-controller to:
* cull idle Notebook Servers based on their new `last-activity`
  annotation
* expose the last activity of each Notebook Server as an annotation
  on the metadata of the corresponding CR object

Modify notebook_controller.go to:
* update the Last Activity of each Notebook Server that has a
  Running pod
* delete the Last Activity Annotation for every Notebook Server
  that does not have a Running pod

Extend culler.go to:
* perform culling based on the new `last-activity` annotation and
  not based on the `/api/status` endpoint.
* update the last activity of a Notebook Server, based on the
  kernels' execution states.

Signed-off-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>
Reviewed-by: Athanasios Markou <athamark@arrikto.com>

* notebooks: Introduce a DEV env var

We introduce a DEV ENV var to allow admins
develop and test on their local machine their
custom Notebook Controller.
We provide information and instructions inside
the components/notebook-controller/README.md.

Signed-off-by: Athanasios Markou <athamark@arrikto.com>
Reviewed-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>

* notebooks: Add unit tests for last-activity

* Introduce new tests for allKernelsAreIdle()
* Extend the tests for NotebookIsIdle() and for
  NotebookNeedsCulling().

Signed-off-by: Athanasios Markou <athamark@arrikto.com>
Reviewed-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>

* review: UpdateNotebookLastActivityAnnotation()

Ensure that UpdateNotebookLastActivityAnnotation() does not return
"true". This function should not return any value.

Signed-off-by: Athanasios Markou <athamark@arrikto.com>
2022-02-07 15:19:17 +00:00
Naveen e2555c4797 Upgrading the `go` compiler version. (kubeflow/kubeflow#5394)
Upgrade go version of the notebook-controller to 1.15, across the
Dockerfile, Makefile and README. We used the same Golang version as our Kubernetes
dependency, after @Jeffwan's suggestion.
2021-01-12 04:10:25 -08:00
Naveen a75404d6d8 Included the instructions to contribute notebook-controller. (kubeflow/kubeflow#5383)
* Instructions to contribute.

* Update based on feedback.
2020-11-09 01:52:25 -08:00
Chad Roberts 25bf002c34 Adding env var to suppress automatic additon of fsGroup in notebook pod (kubeflow/kubeflow#4713) (kubeflow/kubeflow#4782)
* Allowing for an env var ADD_FSGROUP to be set to false to suppress the automatic addition of fsGroup: 100 in the pod's security context.
This addresses issue #4617.

* Adding note in README regarding ADD_FSGROUP.
2020-02-19 09:08:25 -08:00
Lun-Kai Hsu 8cad496a13 Migrate notebook CR to kubebuilder V2 (kubeflow/kubeflow#4013)
* wip

* can build

* tested: able to control notebook

* fix
2019-09-04 17:06:22 -07:00
Lun-Kai Hsu fa3b0b3b0b Golang notebook controller (kubeflow/kubeflow#2336)
* kubebuilder init

* replae dep with modules

* add notebook api

* notebook controller impl

* remove test

* fix dockerfile

* fix svc reconcile

* notebook controller ksonnet

* update generated crd

* add sample

* remove TODO

* make golang version an arg

* rename

* fix path

* add README

* Add todo in readme

* remove arg default
2019-02-05 16:43:39 -08:00