Configure Culling for Notebooks

Automatically stop your notebooks based on idleness

The culling feature allows you to stop a Notebook Server based on its Last Activity. The Notebook Controller updates the respective notebooks.kubeflow.org/last-activity annotation of each Notebook resource according to the execution state of the kernels. When this feature is enabled, the notebook instances will be “culled” (scaled to zero) if none of the kernels are performing computations for a specified period of time (CULL_IDLE_TIME). More information about this feature can be found in the Jupyter notebook idleness proposal.

  1. Export the following values values to configure the culling policy parameters:

    # whether to enable culling feature (true/false). ENABLE_CULLING must be set to “true” for this feature to take work
    export ENABLE_CULLING="true"
    # specified idleness time (minutes) that notebook instance to be culled since last activity
    export CULL_IDLE_TIMEOUT="30"
    # controller will update each notebook's LAST_ACTIVITY_ANNOTATION every IDLENESS_CHECK_PERIOD (minutes)
    export IDLENESS_CHECK_PERIOD="5"
    
  2. The following commands will inject those values in a configuration file for setting up Notebook culling: Select the package manager of your choice.

    • For Kustomize and Helm:

      printf '
      ENABLE_CULLING='$ENABLE_CULLING'
      CULL_IDLE_TIME='$CULL_IDLE_TIMEOUT'
      IDLENESS_CHECK_PERIOD='$IDLENESS_CHECK_PERIOD'
      ' > awsconfigs/apps/notebook-controller/params.env
          
      yq e '.cullingPolicy.enableCulling = env(ENABLE_CULLING)' -i charts/apps/notebook-controller/values.yaml
      yq e '.cullingPolicy.cullIdleTime = env(CULL_IDLE_TIMEOUT)' -i charts/apps/notebook-controller/values.yaml
      yq e '.cullingPolicy.idlenessCheckPeriod = env(IDLENESS_CHECK_PERIOD)' -i charts/apps/notebook-controller/values.yaml
          

    • For Terraform, append the notebook culling parameters in the sample.auto.tfvars file with chosen deployment option: Vanilla, Cognito, RDS-S3, and Cognito-RDS-S3.

      cat <<EOT >> sample.auto.tfvars
      notebook_enable_culling="${ENABLE_CULLING}" 
      notebook_cull_idle_time="${CULL_IDLE_TIMEOUT}"
      notebook_idleness_check_period="${IDLENESS_CHECK_PERIOD}"
      EOT
      
  3. Continue deploying Kubeflow based on your Deployment Option.

Last modified April 14, 2023: Notebook Culling doc change (#679) (0d7acefc)