Skip to content

Commit

Permalink
Doc fixes + more polish
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Nov 2, 2016
1 parent de77f82 commit 17e4928
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# jupyterhub-kubernetes-spawner #

The KubernetesSpawner enables JupyterHub to spawn singleuser notebooks on a [kubernetes](https://kubernetes.io/) cluster.
The KubernetesSpawner enables JupyterHub to spawn single-user notebooks on a [Kubernetes](https://kubernetes.io/) cluster.

## Features ##

Kubernetes is a popular & powerful container orchestration platform that helps run containerized applications at scale. 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.

* Easily and elasticly run on 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.
Kubernetes is an open-source system for automating deployment, scaling, and 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.
* 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 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 [namespaces](http://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 singleuser notebooks can use. Kubernetes has comprehensive [resource control](http://kubernetes.io/docs/user-guide/compute-resources/) that can be used from the spawner.
* Provide guarantees and limits on the amount of resources (CPU / RAM) that single-user notebooks can use. Kubernetes has comprehensive [resource control](http://kubernetes.io/docs/user-guide/compute-resources/) that can be used from the spawner.
* Mount various types of [persistent volumes](http://kubernetes.io/docs/user-guide/persistent-volumes/) onto the singleuser notebook's container.
* Control various security parameters (such as userid/groupid, SELinux, etc) via flexible [Pod Security Policies](http://kubernetes.io/docs/user-guide/pod-security-policy/).
* 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](http://kubernetes.io/docs/user-guide/federation/).
Expand Down
2 changes: 1 addition & 1 deletion kubespawner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
in your `jupyterhub_config.py` file.
We explort KubeSpawner specifically here, so people can import kubespawner.KubeSpawner
We export KubeSpawner specifically here, so people can import kubespawner.KubeSpawner
instead of kubespawner.spawner.KubeSpawner
"""
from kubespawner.spawner import KubeSpawner
Expand Down
12 changes: 9 additions & 3 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def get_pod_info(self, pod_name):
Return `None` if pod with given name does not exist in current namespace
"""
try:
resp = yield self.httpclient.fetch(self.request(
response = yield self.httpclient.fetch(self.request(
k8s_url(
self.namespace,
'pods',
Expand All @@ -342,14 +342,14 @@ def get_pod_info(self, pod_name):
if e.code == 404:
return None
raise
data = resp.body.decode('utf-8')
data = response.body.decode('utf-8')
return json.loads(data)

def is_pod_running(self, pod):
"""
Check if the given pod is running
pod must be a dictionary representing a Pod kubernets API object.
pod must be a dictionary representing a Pod kubernetes API object.
"""
return pod['status']['phase'] == 'Running'

Expand Down Expand Up @@ -383,6 +383,12 @@ def load_state(self, state):

@gen.coroutine
def poll(self):
"""
Check if the pod is still running.
Returns None if it is, and 1 if it isn't. These are the return values
JupyterHub expects.
"""
data = yield self.get_pod_info(self.pod_name)
if data is not None and self.is_pod_running(data):
return None
Expand Down

0 comments on commit 17e4928

Please sign in to comment.