Skip to content

Commit

Permalink
add delete_forever hook to cleanup user's PVC on user deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
nsshah1288 committed May 5, 2021
1 parent c215e24 commit 889ab6e
Show file tree
Hide file tree
Showing 21 changed files with 1,104 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.15.1.dev
current_version = 0.16.2.dev
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z0-9]+))?
tag_name = {new_version}
allow_dirty = True
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ jobs:
pip install codecov
codecov
# Keep this job synced with the publish job in publish.yaml!
package-build:
name: Test package build
Expand Down
70 changes: 52 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,53 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Run on all files: pre-commit run --all-files
# - Register git hooks: pre-commit install --install-hooks
#
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.9.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: flake8
# Autoformat: Python code
- repo: https://github.com/ambv/black
rev: 20.8b1
hooks:
- id: black
args: [--target-version=py36]

# Autoformat: markdown, yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
hooks:
- id: prettier

# Autoformat: https://github.com/asottile/reorder_python_imports
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0
hooks:
- id: reorder-python-imports

# Misc...
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
hooks:
# Autoformat: Makes sure files end in a newline and only a newline.
- id: end-of-file-fixer

# Autoformat: Sorts entries in requirements.txt.
- id: requirements-txt-fixer

# Lint: Check for files with names that would conflict on a
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
- id: check-case-conflict

# Lint: Checks that non-binary executables have a proper shebang.
- id: check-executables-have-shebangs

# Lint: Python code
- repo: https://gitlab.com/pycqa/flake8
rev: "3.8.4"
hooks:
- id: flake8
1 change: 0 additions & 1 deletion readthedocs.yml → .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
Expand Down
90 changes: 48 additions & 42 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,31 @@ Welcome! As a [Jupyter](https://jupyter.org) project, we follow the [Jupyter con

There are many ways to contribute to kubespawner, here are some of them:

* **Update the documentation.**
- **Update the documentation.**
If you're reading a page or docstring and it doesn't make sense (or doesn't exist!), please let us know by opening a bug report.
It's even more amazing if you can give us a suggested change.
* **Fix bugs or add requested features.**
- **Fix bugs or add requested features.**
Have a look through the [issue tracker](https://github.com/jupyterhub/kubespawner/issues) and see if there are any tagged as ["help wanted"](https://github.com/jupyterhub/kubespawner/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).
As the label suggests, we'd love your help!
* **Report a bug.**
- **Report a bug.**
If kubespawner isn't doing what you thought it would do then open a [bug report](https://github.com/jupyterhub/kubespawner/issues/new).
Please provide details on what you were trying to do, what goal you were trying to achieve and how we can reproduce the problem.
* **Suggest a new feature.**
- **Suggest a new feature.**
We know that there are lots of ways to extend kubespawner!
If you're interested in adding a feature then please open a [feature request](https://github.com/jupyterhub/kubespawner/issues/new?template=feature_request.md).
Try to explain what the feature is, what alternatives you have though about, what skills are required to work on this task and how big a task you estimate it to be.
* **Review someone's Pull Request.**
- **Review someone's Pull Request.**
Whenever somebody proposes changes to the kubespawner codebase, the community reviews
the changes, and provides feedback, edits, and suggestions. Check out the
[open pull requests](https://github.com/jupyterhub/kubespawner/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc)
and provide feedback that helps improve the PR and get it merged. Please keep your
feedback positive and constructive!
* **Tell people about kubespawner.**
- **Tell people about kubespawner.**
Kubespawner is built by and for its community.
If you know anyone who would like to use kubespawner, please tell them about the project!
You could give a talk about it or run a demonstration or make a poster.
The sky is the limit :rocket::star2:.


## Setting up for documentation changes

We use Sphinx to build the kubespawner documentation. You can make changes to
Expand All @@ -47,6 +46,7 @@ To make edits through the GitHub website visit https://github.com/jupyterhub/kub
walk you through the process of proposing your change ("making a Pull Request").

A brief guide to setting up for local development

```sh
git clone https://github.com/jupyterhub/kubespawner.git
cd kubespawner/docs
Expand Down Expand Up @@ -98,6 +98,7 @@ rules on your computer. We will now walk you through the steps to get going:
```

### Troubleshooting

Got an error like below?

```
Expand All @@ -110,7 +111,7 @@ rules on your computer. We will now walk you through the steps to get going:

```json
{
"bip": "172.19.1.1/16"
"bip": "172.19.1.1/16"
}
```

Expand All @@ -123,47 +124,51 @@ rules on your computer. We will now walk you through the steps to get going:
`sudo ip route add` command again. Note that restarting docker will
restart all your running containers by default.

1. Clone this repository
```sh
git clone https://github.com/jupyterhub/kubespawner.git
```
1. Clone this repository

```sh
git clone https://github.com/jupyterhub/kubespawner.git
```

1. Setup a virtual environment. After cloning the repository, you should set up an
isolated environment to install libraries required for running / developing
kubespawner.
1. Setup a virtual environment. After cloning the repository, you should set up an
isolated environment to install libraries required for running / developing
kubespawner.

There are many ways of doing this: conda envs, virtualenv, pipenv, etc. Pick
your favourite. We show you how to use venv:
```sh
cd kubespawner
There are many ways of doing this: conda envs, virtualenv, pipenv, etc. Pick
your favourite. We show you how to use venv:

python3 -m venv .
source bin/activate
```
```sh
cd kubespawner
3. Install a locally editable version of kubespawner and its dependencies for
running it and testing it.
```sh
pip install -e ".[test]"
```
python3 -m venv .
source bin/activate
```

1. Install the nodejs based [Configurable HTTP Proxy
(CHP)](https://github.com/jupyterhub/configurable-http-proxy), and make it
accessible to JupyterHub.
1. Install a locally editable version of kubespawner and its dependencies for
running it and testing it.

```sh
npm install configurable-http-proxy
export PATH=$(pwd)/node_modules/.bin:$PATH
```
```sh
pip install -e ".[test]"
```

1. Start JupyterHub
```sh
# Run this from the repo's root directory where the preconfigured
# jupyterhub_config.py file resides!
jupyterhub
```
1. Install the nodejs based [Configurable HTTP Proxy
(CHP)](https://github.com/jupyterhub/configurable-http-proxy), and make it
accessible to JupyterHub.

1. Visit [http://localhost:8000/](http://localhost:8000/)!
```sh
npm install configurable-http-proxy
export PATH=$(pwd)/node_modules/.bin:$PATH
```

1. Start JupyterHub

```sh
# Run this from the repo's root directory where the preconfigured
# jupyterhub_config.py file resides!
jupyterhub
```

1. Visit [http://localhost:8000/](http://localhost:8000/)!

You should now have a JupyterHub running directly on your computer outside of
the Kubernetes cluster, using a locally editable kubespawner code base. The
Expand All @@ -172,17 +177,18 @@ JupyterHub is setup with
so any user + password combination will allow you to log in. You can make changes to
kubespawner and restart the jupyterhub, and rapidly iterate :)


## Running tests

To run our automated test-suite you need to have a local development setup.

Run all tests with:

```sh
pytest
```

### Troubleshooting

If you a huge amount of errors, make sure your minikube is up and running and see it if helps to clear your .eggs
directory.

Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
include README.md
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Code coverage](https://codecov.io/gh/jupyterhub/kubespawner/branch/master/graph/badge.svg)](https://codecov.io/gh/jupyterhub/kubespawner)
[![](https://img.shields.io/pypi/v/jupyterhub-kubespawner.svg?logo=pypi)](https://pypi.python.org/pypi/jupyterhub-kubespawner)

The *kubespawner* (also known as JupyterHub Kubernetes Spawner) enables JupyterHub to spawn
The _kubespawner_ (also known as JupyterHub Kubernetes Spawner) enables JupyterHub to spawn
single-user notebook servers on a [Kubernetes](https://kubernetes.io/)
cluster.

Expand All @@ -19,34 +19,34 @@ management of containerized applications. If you want to run a JupyterHub
setup that needs to scale across multiple nodes (anything with over ~50
simultaneous users), Kubernetes is a wonderful way to do it. Features include:

* Easily and elasticly run anywhere between 2 and thousands of nodes with the
- Easily and elasticly run anywhere between 2 and thousands of nodes with the
same set of powerful abstractions. Scale up and down as required by simply
adding or removing nodes.

* Run JupyterHub itself inside Kubernetes easily. This allows you to manage
- Run JupyterHub itself inside Kubernetes easily. This allows you to manage
many JupyterHub deployments with only Kubernetes, without requiring an extra
layer of Ansible / Puppet / Bash scripts. This also provides easy integrated
monitoring and failover for the hub process itself.

* Spawn multiple hubs in the same kubernetes cluster, with support for
- Spawn multiple hubs in the same kubernetes cluster, with support for
[namespaces](https://kubernetes.io/docs/admin/namespaces/). You can limit the
amount of resources each namespace can use, effectively limiting the amount
of resources a single JupyterHub (and its users) can use. This allows
organizations to easily maintain multiple JupyterHubs with just one
kubernetes cluster, allowing for easy maintenance & high resource
utilization.

* Provide guarantees and limits on the amount of resources (CPU / RAM) that
- Provide guarantees and limits on the amount of resources (CPU / RAM) that
single-user notebooks can use. Kubernetes has comprehensive [resource control](https://kubernetes.io/docs/user-guide/compute-resources/) that can
be used from the spawner.

* Mount various types of [persistent volumes](https://kubernetes.io/docs/user-guide/persistent-volumes/)
- Mount various types of [persistent volumes](https://kubernetes.io/docs/user-guide/persistent-volumes/)
onto the single-user notebook's container.

* Control various security parameters (such as userid/groupid, SELinux, etc)
- Control various security parameters (such as userid/groupid, SELinux, etc)
via flexible [Pod Security Policies](https://kubernetes.io/docs/user-guide/pod-security-policy/).

* Run easily in multiple clouds (or on your own machines). Helps avoid vendor
- Run easily in multiple clouds (or on your own machines). Helps avoid vendor
lock-in. You can even spread out your cluster across
[multiple clouds at the same time](https://kubernetes.io/docs/user-guide/federation/).

Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PyPI](https://pypi.org/project/jupyterhub-kubespawner/). These are instructions
on how to make a release on PyPI.

For you to follow along according to these instructions, you need:

- To have push rights to the [kubespawner GitHub
repository](https://github.com/jupyterhub/kubespawner).

Expand Down
8 changes: 4 additions & 4 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- sphinx_rtd_theme
- traitlets>=4.1
- pip:
- recommonmark==0.4.0
- pyyaml
- sphinx-copybutton
- setuptools
- recommonmark==0.4.0
- pyyaml
- sphinx-copybutton
- setuptools
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyyaml
recommonmark==0.4.0
setuptools
sphinx-copybutton
sphinx>=1.7
sphinx-copybutton
sphinx_rtd_theme
traitlets>=4.1
Loading

0 comments on commit 889ab6e

Please sign in to comment.