Skip to content

Commit

Permalink
Init chart and exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
KrKOo committed Nov 10, 2023
1 parent b0d0925 commit 8e9ebf9
Show file tree
Hide file tree
Showing 22 changed files with 1,780 additions and 0 deletions.
1 change: 1 addition & 0 deletions nbgrader-chart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/charts/*.tgz
23 changes: 23 additions & 0 deletions nbgrader-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions nbgrader-chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: jupyterhub
repository: https://hub.jupyter.org/helm-chart/
version: 3.0.3
digest: sha256:fad52e3374588bd08d3382acd452a9335ad66337b49ce973d1b6383c185d4388
generated: "2023-11-10T10:37:31.611068395+01:00"
11 changes: 11 additions & 0 deletions nbgrader-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: nbgrader
description: A Helm chart for deploying nbgrader
type: application
version: 0.1.0
appVersion: '0.9.1'

dependencies:
- name: jupyterhub
version: 3.0.3
repository: https://hub.jupyter.org/helm-chart/
17 changes: 17 additions & 0 deletions nbgrader-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nbgrader.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions nbgrader-chart/templates/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nbgrader-config-global
data:
nbgrader_config.py: |
import os
from nbgrader.server_extensions.assignment_list.handlers import AssignmentList
from nbgrader.auth import Authenticator, JupyterHubAuthPlugin
c = get_config()
c.Exchange.path_includes_course = True
c.Exchange.root = "/mnt/exchange"
c.Authenticator.plugin_class = JupyterHubAuthPlugin
c.ExchangeFactory.collect = 'nbgrader_k8s_exchange.plugin.ExchangeCollect'
c.ExchangeFactory.exchange = 'nbgrader_k8s_exchange.plugin.Exchange'
c.ExchangeFactory.fetch_assignment = 'nbgrader_k8s_exchange.plugin.ExchangeFetchAssignment'
c.ExchangeFactory.fetch_feedback = 'nbgrader_k8s_exchange.plugin.ExchangeFetchFeedback'
c.ExchangeFactory.list = 'nbgrader_k8s_exchange.plugin.ExchangeList'
c.ExchangeFactory.release_assignment = 'nbgrader_k8s_exchange.plugin.ExchangeReleaseAssignment'
c.ExchangeFactory.release_feedback = 'nbgrader_k8s_exchange.plugin.ExchangeReleaseFeedback'
c.ExchangeFactory.submit = 'nbgrader_k8s_exchange.plugin.ExchangeSubmit'
# List courses for the student even if there are no assignments
def list_courses(self):
auth = Authenticator(config=c)
return {
"success": True,
"value": auth.get_student_courses(os.environ['JUPYTERHUB_USER'])
}
AssignmentList.list_courses = list_courses
12 changes: 12 additions & 0 deletions nbgrader-chart/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nbgrader-exchange
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: {{ .Values.exchange.size }}
storageClassName: {{ .Values.exchange.storageClassName }}
volumeMode: Filesystem
9 changes: 9 additions & 0 deletions nbgrader-chart/templates/svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "nbgrader.fullname" . }}
spec:
clusterIP: None
selector:
app: jupyterhub
component: hub
Loading

0 comments on commit 8e9ebf9

Please sign in to comment.