Commit be0bb687 authored by Dylan Murray's avatar Dylan Murray

Initial commit of Jupyterhub APB

parents
FROM ansibleplaybookbundle/apb-base:canary
LABEL "com.redhat.apb.spec"=\
"dmVyc2lvbjogMS4wCm5hbWU6IGp1cHl0ZXJodWItYXBiCmRlc2NyaXB0aW9uOiB5b3VyIGRlc2Ny\
aXB0aW9uCmJpbmRhYmxlOiBGYWxzZQphc3luYzogb3B0aW9uYWwKbWV0YWRhdGE6CiAgZGlzcGxh\
eU5hbWU6IGp1cHl0ZXJodWItYXBiCnBsYW5zOgogIC0gbmFtZTogZGVmYXVsdAogICAgZGVzY3Jp\
cHRpb246IFRoaXMgZGVmYXVsdCBwbGFuIGRlcGxveXMganVweXRlcmh1Yi1hcGIKICAgIGZyZWU6\
IFRydWUKICAgIG1ldGFkYXRhOiB7fQogICAgcGFyYW1ldGVyczoKICAgICAgLSBuYW1lOiBkYl9t\
ZW1vcnkKICAgICAgICB0eXBlOiBlbnVtCiAgICAgICAgZW51bTogWyc1MTJNaSddCiAgICAgICAg\
ZGVmYXVsdDogJzUxMk1pLCAyNTZNaScKICAgICAgICByZXF1aXJlZDogdHJ1ZQogICAgICAtIG5h\
bWU6IGRiX3Bhc3N3b3JkCiAgICAgICAgdHlwZTogc3RyaW5nCiAgICAgICAgcmVxdWlyZWQ6IHRy\
dWUKICAgICAgLSBuYW1lOiBjb29raWVfc2VjcmV0CiAgICAgICAgdHlwZTogc3RyaW5nCiAgICAg\
ICAgcmVxdWlyZWQ6IHRydWUKICAgICAgLSBuYW1lOiBqdXB5dGVyaHViX21lbW9yeQogICAgICAg\
IHR5cGU6IGVudW0KICAgICAgICBlbnVtOiBbJzUxMk1pJywgJzI1Nk1pJ10KICAgICAgICBkZWZh\
dWx0OiAnNTEyTWknCiAgICAgICAgcmVxdWlyZWQ6IHRydWUKICAgICAgLSBuYW1lOiBub3RlYm9v\
a19pbWFnZQogICAgICAgIHR5cGU6IGVudW0KICAgICAgICBlbnVtOiBbJ3MyaS1taW5pbWFsLW5v\
dGVib29rOjMuNScsICdzMmktc2NpcHktbm90ZWJvb2s6My41J10KICAgICAgICByZXF1aXJlZDog\
dHJ1ZQogICAgICAgIGRlZmF1bHQ6ICdzMmktbWluaW1hbC1ub3RlYm9vazozLjUnCiAgICAgIC0g\
bmFtZTogbm90ZWJvb2tfbWVtb3J5CiAgICAgICAgdHlwZTogZW51bQogICAgICAgIGVudW06IFsn\
NTEyTWknXQogICAgICAgIGRlZmF1bHQ6ICc1MTJNaScKICAgICAgICByZXF1aXJlZDogdHJ1ZQoK\
"
COPY playbooks /opt/apb/actions
COPY . /opt/ansible/roles/jupyterhub-apb
RUN chmod -R g=u /opt/{ansible,apb}
USER apb
DOCKERHOST = DOCKERHOST
DOCKERORG = DOCKERORG
IMAGENAME = jupyterhub-apb
TAG = latest
USER=$(shell id -u)
PWD=$(shell pwd)
build_and_push: apb_build docker_push apb_push
.PHONY: apb_build
apb_build:
docker run --rm --privileged -v $(PWD):/mnt:z -v $(HOME)/.kube:/.kube -v /var/run/docker.sock:/var/run/docker.sock -u $(USER) docker.io/ansibleplaybookbundle/apb-tools:latest prepare
docker build -t $(DOCKERHOST)/$(DOCKERORG)/$(IMAGENAME):$(TAG) .
.PHONY: docker_push
docker_push:
docker push $(DOCKERHOST)/$(DOCKERORG)/$(IMAGENAME):$(TAG)
.PHONY: apb_push
apb_push:
docker run --rm --privileged -v $(PWD):/mnt:z -v $(HOME)/.kube:/.kube -v /var/run/docker.sock:/var/run/docker.sock -u $(USER) docker.io/ansibleplaybookbundle/apb-tools:latest push
APB Name
=========
A brief description of the APB goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
APB Variables
--------------
A description of the settable variables for this APB should go here, including any variables that are in defaults/main.yml, vars/main.yml, apb.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (i.e. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other APBs/roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your APB (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
version: 1.0
name: jupyterhub-apb
description: your description
bindable: False
async: optional
metadata:
displayName: jupyterhub-apb
plans:
- name: default
description: This default plan deploys jupyterhub-apb
free: True
metadata: {}
parameters:
- name: db_memory
type: enum
enum: ['512Mi']
default: '512Mi, 256Mi'
required: true
- name: db_password
type: string
required: true
- name: cookie_secret
type: string
required: true
- name: jupyterhub_memory
type: enum
enum: ['512Mi', '256Mi']
default: '512Mi'
required: true
- name: notebook_image
type: enum
enum: ['s2i-minimal-notebook:3.5', 's2i-scipy-notebook:3.5']
required: true
default: 's2i-minimal-notebook:3.5'
- name: notebook_memory
type: enum
enum: ['512Mi']
default: '512Mi'
required: true
---
# defaults file for jupyterhub-apb
\ No newline at end of file
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "jupyterhub",
"namespace": "{{ namespace }}",
"labels": {
"build": "jupyterhub"
}
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/jupyter-on-openshift/jupyterhub-quickstart.git"
}
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"name": "python:3.5",
"namespace": "openshift"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "jupyterhub:latest"
}
}
}
}
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "jupyterhub-builder",
"namespace": "{{ namespace }}",
"annotations": {
"openshift.io/display-name": "JupyterHub Builder",
"description": "Template for creating customised JupyterHub images.",
"iconClass": "icon-python",
"tags": "python,jupyter,jupyterhub"
}
},
"parameters": [
{
"name": "JUPYTERHUB_NAME",
"value": "custom-jupyterhub",
"required": true
},
{
"name": "BUILDER_IMAGE",
"value": "jupyterhub:latest",
"required": true
},
{
"name": "GIT_REPOSITORY_URL",
"value": "",
"required": true
},
{
"name": "GIT_REFERENCE",
"value": "master",
"required": true
},
{
"name": "CONTEXT_DIR",
"value": "",
"required": false
}
],
"objects": [
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "${JUPYTERHUB_NAME}",
"labels": {
"build": "${JUPYTERHUB_NAME}"
}
},
"spec": {
"lookupPolicy": {
"local": true
}
}
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "${JUPYTERHUB_NAME}",
"labels": {
"build": "${JUPYTERHUB_NAME}"
}
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"source": {
"type": "Git",
"git": {
"uri": "${GIT_REPOSITORY_URL}",
"ref": "${GIT_REFERENCE}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"name": "${BUILDER_IMAGE}"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "${JUPYTERHUB_NAME}:latest"
}
}
}
}
]
}
This diff is collapsed.
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "jupyterhub",
"namespace": "{{ namespace }}",
"labels": {
"build": "jupyterhub"
}
},
"spec": {
"lookupPolicy": {
"local": true
}
}
}
This diff is collapsed.
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "s2i-minimal-notebook",
"namespace": "{{ namespace }}",
"labels": {
"build": "s2i-minimal-notebook"
}
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/jupyter-on-openshift/jupyter-notebooks"
},
"contextDir": "minimal-notebook"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"name": "python:3.5",
"namespace": "openshift"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "s2i-minimal-notebook:3.5"
}
},
"resources": {
"limits": {
"memory": "1Gi"
}
}
}
}
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "s2i-minimal-notebook",
"namespace": "{{ namespace }}",
"labels": {
"build": "s2i-minimal-notebook"
}
},
"spec": {
"lookupPolicy": {
"local": true
}
}
}
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "s2i-scipy-notebook",
"namespace": "{{ namespace }}",
"labels": {
"build": "s2i-scipy-notebook"
}
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/jupyter-on-openshift/jupyter-notebooks"
},
"contextDir": "scipy-notebook"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"name": "s2i-minimal-notebook:3.5"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "s2i-scipy-notebook:3.5"
}
},
"resources": {
"limits": {
"memory": "1Gi"
}
}
}
}
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "s2i-scipy-notebook",
"namespace": "{{ namespace }}",
"labels": {
"build": "s2i-scipy-notebook"
}
},
"spec": {
"lookupPolicy": {
"local": true
}
}
}
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "s2i-tensorflow-notebook",
"namespace": "{{ namespace }}",
"labels": {
"build": "s2i-tensorflow-notebook"
}
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/jupyter-on-openshift/jupyter-notebooks"
},
"contextDir": "tensorflow-notebook"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"name": "s2i-minimal-notebook:3.5"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "s2i-tensorflow-notebook:3.5"
}
},
"resources": {
"limits": {
"memory": "512Mi"
}
}
}
}
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "s2i-tensorflow-notebook",
"namespace": "{{ namespace }}",
"labels": {
"build": "s2i-tensorflow-notebook"
}
},
"spec": {
"lookupPolicy": {
"local": true
}
}
}
---
# handlers file for jupyterhub-apb
\ No newline at end of file
galaxy_info:
author: your name
description: your description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags:
- apb
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
\ No newline at end of file
- name: jupyterhub-apb playbook to deprovision the application
hosts: localhost
gather_facts: false
connection: local
vars:
apb_action: deprovision
roles:
- role: jupyterhub-apb
\ No newline at end of file
- name: jupyterhub-apb playbook to provision the application
hosts: localhost
gather_facts: false
connection: local
vars:
apb_action: provision
roles:
- role: jupyterhub-apb
\ No newline at end of file
---
# tasks file for jupyterhub-apb
- name: Create jupyterhub objects
openshift_raw:
state: present
definition: "{{ lookup('template', item) }}"
with_items:
- jupyterhub-buildconfig.json.j2
- jupyterhub-builder-template.json.j2
- jupyterhub-deployer-template.json.j2
- jupyterhub-imagestream.json.j2
- jupyterhub-quickstart-template.json.j2
- name: Create notebook objects
openshift_raw:
state: present
definition: "{{ lookup('template', item) }}"
with_items:
- minimal-notebook-buildconfig.json.j2
- minimal-notebook-imagestream.json.j2
- scipy-notebook-buildconfig.json.j2
- scipy-notebook-imagestream.json.j2
- tensorflow-notebook-buildconfig.json.j2
- tensorflow-notebook-imagestream.json.j2
- name: deploy Jupyterhub
openshift_raw:
state: present
definition: "{{ lookup('template', item)}}"
with_items:
- jupyterhub-deployer/serviceaccount.json.j2
- jupyterhub-deployer/rolebinding.json.j2
- jupyterhub-deployer/configmap.json.j2
- jupyterhub-deployer/jupyterhub-db-pv.json.j2
- jupyterhub-deployer/jupyterhub-db-dc.json.j2
- jupyterhub-deployer/jupyterhub-db-service.json.j2
- jupyterhub-deployer/jupyterhub-dc.json.j2
- jupyterhub-deployer/jupyterhub-service.json.j2
- jupyterhub-deployer/route.json.j2
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "jupyterhub",
"namespace": "{{ namespace }}",
"labels": {
"build": "jupyterhub"
}
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/jupyter-on-openshift/jupyterhub-quickstart.git"
}
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"name": "python:3.5",
"namespace": "openshift"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "jupyterhub:latest"
}
}
}
}
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "jupyterhub-builder",
"namespace": "{{ namespace }}",
"annotations": {
"openshift.io/display-name": "JupyterHub Builder",
"description": "Template for creating customised JupyterHub images.",
"iconClass": "icon-python",
"tags": "python,jupyter,jupyterhub"
}
},
"parameters": [
{
"name": "JUPYTERHUB_NAME",
"value": "custom-jupyterhub",
"required": true
},
{
"name": "BUILDER_IMAGE",
"value": "jupyterhub:latest",
"required": true
},
{
"name": "GIT_REPOSITORY_URL",
"value": "",
"required": true
},
{
"name": "GIT_REFERENCE",
"value": "master",
"required": true
},
{
"name": "CONTEXT_DIR",
"value": "",
"required": false
}
],
"objects": [
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "${JUPYTERHUB_NAME}",
"labels": {
"build": "${JUPYTERHUB_NAME}"
}
},
"spec": {
"lookupPolicy": {
"local": true
}
}
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "${JUPYTERHUB_NAME}",
"labels": {