Add OpenShift template for building, but not deploying an image using Source-to-Image builder.

This commit is contained in:
Graham Dumpleton
2018-02-19 11:43:20 +11:00
parent f87dec5936
commit 52fba5967f

View File

@@ -1,266 +1,375 @@
{ {
"kind": "Template", "kind": "List",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "items": [
"name": "jupyter-notebook-quickstart",
"annotations": {
"openshift.io/display-name": "Jupyter Notebook Quickstart",
"description": "Template for deploying Jupyter Notebook images with bundled notebooks and files.",
"iconClass": "icon-python",
"tags": "python,jupyter"
}
},
"parameters": [
{
"name": "APPLICATION_NAME",
"value": "notebook",
"required": true
},
{
"name": "BUILDER_IMAGE",
"value": "jupyter/minimal-notebook:latest",
"required": true
},
{
"name": "BUILDER_SCRIPTS",
"value": "https://raw.githubusercontent.com/jupyter/docker-stacks/source-to-image/examples/source-to-image",
"required": true
},
{
"name": "GIT_REPOSITORY_URL",
"value": "",
"required": true
},
{
"name": "GIT_REFERENCE",
"value": "master",
"required": true
},
{
"name": "CONTEXT_DIR",
"value": "",
"required": false
},
{
"name": "NOTEBOOK_PASSWORD",
"from": "[a-f0-9]{32}",
"generate": "expression"
}
],
"objects": [
{
"apiVersion": "v1",
"kind": "ImageStream",
"metadata": {
"name": "${APPLICATION_NAME}",
"labels": {
"app": "${APPLICATION_NAME}"
}
},
"spec": {
"lookupPolicy": {
"local": false
}
}
},
{
"apiVersion": "v1",
"kind": "BuildConfig",
"metadata": {
"name": "${APPLICATION_NAME}",
"labels": {
"app": "${APPLICATION_NAME}"
}
},
"spec": {
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "${APPLICATION_NAME}:latest"
}
},
"source": {
"type": "Git",
"git": {
"uri": "${GIT_REPOSITORY_URL}",
"ref": "${GIT_REFERENCE}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "DockerImage",
"name": "${BUILDER_IMAGE}"
},
"scripts": "${BUILDER_SCRIPTS}"
}
},
"triggers": [
{
"type": "ConfigChange"
}
]
}
},
{
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "${APPLICATION_NAME}-cfg",
"labels": {
"app": "${APPLICATION_NAME}"
}
},
"data": {
"jupyter_notebook_config.py": "import os\n\npassword = os.environ.get('JUPYTER_NOTEBOOK_PASSWORD')\n\nif password:\n import notebook.auth\n c.NotebookApp.password = notebook.auth.passwd(password)\n del password\n del os.environ['JUPYTER_NOTEBOOK_PASSWORD']\n\nimage_config_file = '/home/jovyan/work/.jupyter/jupyter_notebook_config.py'\n\nif os.path.exists(image_config_file):\n with open(image_config_file) as fp:\n exec(compile(fp.read(), image_config_file, 'exec'), globals())\n"
}
},
{ {
"kind": "DeploymentConfig", "kind": "Template",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "${APPLICATION_NAME}", "name": "jupyter-notebook-builder",
"labels": { "annotations": {
"app": "${APPLICATION_NAME}" "openshift.io/display-name": "Jupyter Notebook Builder",
"description": "Template for building Jupyter Notebook images with bundled notebooks and files.",
"iconClass": "icon-python",
"tags": "python,jupyter"
} }
}, },
"spec": { "parameters": [
"strategy": { {
"type": "Recreate" "name": "IMAGE_NAME",
"value": "notebook",
"required": true
}, },
"triggers": [ {
{ "name": "BUILDER_IMAGE",
"type": "ConfigChange" "value": "jupyter/minimal-notebook:latest",
}, "required": true
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"jupyter-notebook"
],
"from": {
"kind": "ImageStreamTag",
"name": "${APPLICATION_NAME}:latest"
}
}
}
],
"replicas": 1,
"selector": {
"app": "${APPLICATION_NAME}",
"deploymentconfig": "${APPLICATION_NAME}"
}, },
"template": { {
"name": "BUILDER_SCRIPTS",
"value": "https://raw.githubusercontent.com/jupyter/docker-stacks/source-to-image/examples/source-to-image",
"required": true
},
{
"name": "GIT_REPOSITORY_URL",
"value": "",
"required": true
},
{
"name": "GIT_REFERENCE",
"value": "master",
"required": true
},
{
"name": "CONTEXT_DIR",
"value": "",
"required": false
}
],
"objects": [
{
"apiVersion": "v1",
"kind": "ImageStream",
"metadata": { "metadata": {
"annotations": { "name": "${IMAGE_NAME}",
"alpha.image.policy.openshift.io/resolve-names": "*"
},
"labels": { "labels": {
"app": "${APPLICATION_NAME}", "app": "${IMAGE_NAME}"
"deploymentconfig": "${APPLICATION_NAME}" }
}
},
{
"apiVersion": "v1",
"kind": "BuildConfig",
"metadata": {
"name": "${IMAGE_NAME}",
"labels": {
"app": "${IMAGE_NAME}"
} }
}, },
"spec": { "spec": {
"containers": [ "output": {
"to": {
"kind": "ImageStreamTag",
"name": "${IMAGE_NAME}:latest"
}
},
"resources": {
"limits": {
"memory": "1Gi"
}
},
"source": {
"type": "Git",
"git": {
"uri": "${GIT_REPOSITORY_URL}",
"ref": "${GIT_REFERENCE}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "DockerImage",
"name": "${BUILDER_IMAGE}"
},
"scripts": "${BUILDER_SCRIPTS}"
}
},
"triggers": [
{ {
"name": "jupyter-notebook", "type": "ConfigChange"
"image": "${APPLICATION_NAME}:latest", }
"command": [ ]
"start-notebook.sh", }
"--config=/home/jovyan/configs/jupyter_notebook_config.py", }
"--no-browser", ]
"--ip=0.0.0.0" },
], {
"kind": "Template",
"ports": [ "apiVersion": "v1",
{ "metadata": {
"containerPort": 8888, "name": "jupyter-notebook-quickstart",
"protocol": "TCP" "annotations": {
"openshift.io/display-name": "Jupyter Notebook QuickStart",
"description": "Template for deploying Jupyter Notebook images with bundled notebooks and files.",
"iconClass": "icon-python",
"tags": "python,jupyter"
}
},
"parameters": [
{
"name": "APPLICATION_NAME",
"value": "notebook",
"required": true
},
{
"name": "BUILDER_IMAGE",
"value": "jupyter/minimal-notebook:latest",
"required": true
},
{
"name": "BUILDER_SCRIPTS",
"value": "https://raw.githubusercontent.com/jupyter/docker-stacks/source-to-image/examples/source-to-image",
"required": true
},
{
"name": "GIT_REPOSITORY_URL",
"value": "",
"required": true
},
{
"name": "GIT_REFERENCE",
"value": "master",
"required": true
},
{
"name": "CONTEXT_DIR",
"value": "",
"required": false
},
{
"name": "NOTEBOOK_PASSWORD",
"from": "[a-f0-9]{32}",
"generate": "expression"
}
],
"objects": [
{
"apiVersion": "v1",
"kind": "ImageStream",
"metadata": {
"name": "${APPLICATION_NAME}",
"labels": {
"app": "${APPLICATION_NAME}"
}
}
},
{
"apiVersion": "v1",
"kind": "BuildConfig",
"metadata": {
"name": "${APPLICATION_NAME}",
"labels": {
"app": "${APPLICATION_NAME}"
}
},
"spec": {
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "${APPLICATION_NAME}:latest"
}
},
"resources": {
"limits": {
"memory": "1Gi"
}
},
"source": {
"type": "Git",
"git": {
"uri": "${GIT_REPOSITORY_URL}",
"ref": "${GIT_REFERENCE}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "DockerImage",
"name": "${BUILDER_IMAGE}"
},
"scripts": "${BUILDER_SCRIPTS}"
}
},
"triggers": [
{
"type": "ConfigChange"
}
]
}
},
{
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "${APPLICATION_NAME}-cfg",
"labels": {
"app": "${APPLICATION_NAME}"
}
},
"data": {
"jupyter_notebook_config.py": "import os\n\npassword = os.environ.get('JUPYTER_NOTEBOOK_PASSWORD')\n\nif password:\n import notebook.auth\n c.NotebookApp.password = notebook.auth.passwd(password)\n del password\n del os.environ['JUPYTER_NOTEBOOK_PASSWORD']\n\nimage_config_file = '/home/jovyan/work/.jupyter/jupyter_notebook_config.py'\n\nif os.path.exists(image_config_file):\n with open(image_config_file) as fp:\n exec(compile(fp.read(), image_config_file, 'exec'), globals())\n"
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "${APPLICATION_NAME}",
"labels": {
"app": "${APPLICATION_NAME}"
}
},
"spec": {
"strategy": {
"type": "Recreate"
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"jupyter-notebook"
],
"from": {
"kind": "ImageStreamTag",
"name": "${APPLICATION_NAME}:latest"
} }
], }
"env": [
{
"name": "JUPYTER_NOTEBOOK_PASSWORD",
"value": "${NOTEBOOK_PASSWORD}"
}
],
"volumeMounts": [
{
"mountPath": "/home/jovyan/configs",
"name": "configs"
}
]
} }
], ],
"securityContext": { "replicas": 1,
"supplementalGroups": [ "selector": {
100 "app": "${APPLICATION_NAME}",
] "deploymentconfig": "${APPLICATION_NAME}"
}, },
"volumes": [ "template": {
{ "metadata": {
"configMap": { "annotations": {
"name": "${APPLICATION_NAME}-cfg" "alpha.image.policy.openshift.io/resolve-names": "*"
}, },
"name": "configs" "labels": {
} "app": "${APPLICATION_NAME}",
] "deploymentconfig": "${APPLICATION_NAME}"
}
},
"spec": {
"containers": [
{
"name": "jupyter-notebook",
"image": "${APPLICATION_NAME}:latest",
"command": [
"start-notebook.sh",
"--config=/home/jovyan/configs/jupyter_notebook_config.py",
"--no-browser",
"--ip=0.0.0.0"
],
"ports": [
{
"containerPort": 8888,
"protocol": "TCP"
}
],
"env": [
{
"name": "JUPYTER_NOTEBOOK_PASSWORD",
"value": "${NOTEBOOK_PASSWORD}"
}
],
"volumeMounts": [
{
"mountPath": "/home/jovyan/configs",
"name": "configs"
}
]
}
],
"securityContext": {
"supplementalGroups": [
100
]
},
"volumes": [
{
"configMap": {
"name": "${APPLICATION_NAME}-cfg"
},
"name": "configs"
}
]
}
}
} }
} },
} {
}, "kind": "Route",
{ "apiVersion": "v1",
"kind": "Route", "metadata": {
"apiVersion": "v1", "name": "${APPLICATION_NAME}",
"metadata": { "labels": {
"name": "${APPLICATION_NAME}", "app": "${APPLICATION_NAME}"
"labels": { }
"app": "${APPLICATION_NAME}" },
} "spec": {
}, "host": "",
"spec": { "to": {
"host": "", "kind": "Service",
"to": { "name": "${APPLICATION_NAME}",
"weight": 100
},
"port": {
"targetPort": "8888-tcp"
},
"tls": {
"termination": "edge",
"insecureEdgeTerminationPolicy": "Redirect"
}
}
},
{
"kind": "Service", "kind": "Service",
"name": "${APPLICATION_NAME}", "apiVersion": "v1",
"weight": 100 "metadata": {
}, "name": "${APPLICATION_NAME}",
"port": { "labels": {
"targetPort": "8888-tcp" "app": "${APPLICATION_NAME}"
}, }
"tls": { },
"termination": "edge", "spec": {
"insecureEdgeTerminationPolicy": "Redirect" "ports": [
} {
} "name": "8888-tcp",
}, "protocol": "TCP",
{ "port": 8888,
"kind": "Service", "targetPort": 8888
"apiVersion": "v1", }
"metadata": { ],
"name": "${APPLICATION_NAME}", "selector": {
"labels": { "app": "${APPLICATION_NAME}",
"app": "${APPLICATION_NAME}" "deploymentconfig": "${APPLICATION_NAME}"
} },
}, "type": "ClusterIP"
"spec": {
"ports": [
{
"name": "8888-tcp",
"protocol": "TCP",
"port": 8888,
"targetPort": 8888
} }
], }
"selector": { ]
"app": "${APPLICATION_NAME}",
"deploymentconfig": "${APPLICATION_NAME}"
},
"type": "ClusterIP"
}
} }
] ]
} }