From 67470cb254efea62f764fd5eed89ee5e37c977ff Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Thu, 11 Jun 2015 21:05:29 +0200 Subject: [PATCH] Standardize templates across examples --- openshift/templates/django-postgresql.json | 167 +++++++++------------ openshift/templates/django.json | 114 +++++++------- 2 files changed, 127 insertions(+), 154 deletions(-) diff --git a/openshift/templates/django-postgresql.json b/openshift/templates/django-postgresql.json index 0e583da..d5df8d5 100644 --- a/openshift/templates/django-postgresql.json +++ b/openshift/templates/django-postgresql.json @@ -2,24 +2,24 @@ "kind": "Template", "apiVersion": "v1", "metadata": { - "name": "django-quickstart-source-postgresql", + "name": "django-postgresql-example", "annotations": { - "description": "Django application template that uses the Source build strategy and includes a PostgreSQL database server for storage.", + "description": "An example Django application with a PostgreSQL database", "tags": "instant-app,python,django,postgresql", - "iconClass" : "icon-python" + "iconClass": "icon-python" } }, "labels": { - "template": "django-quickstart-source-postgresql" + "template": "django-postgresql-example" }, "objects": [ { "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "${FRONTEND_SERVICE_NAME}", + "name": "django-frontend", "annotations": { - "description": "Exposes and load balances the Django app instances." + "description": "Exposes and load balances the application pods" } }, "spec": { @@ -31,29 +31,7 @@ } ], "selector": { - "name": "${FRONTEND_SERVICE_NAME}" - } - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "${DATABASE_SERVICE_NAME}", - "annotations": { - "description": "Exposes the PostgreSQL database server." - } - }, - "spec": { - "ports": [ - { - "name": "postgresql", - "port": 5432, - "targetPort": 5432 - } - ], - "selector": { - "name": "${DATABASE_SERVICE_NAME}" + "name": "django-frontend" } } }, @@ -61,30 +39,40 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "${FRONTEND_SERVICE_NAME}-route" + "name": "django-route" }, "spec": { - "host" : "${FRONTEND_ROUTE}", - "to": { - "kind" : "Service", - "name" : "${FRONTEND_SERVICE_NAME}" - } + "host": "${FRONTEND_ROUTE}", + "to": { + "kind": "Service", + "name": "django-frontend" + } + } + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "django-example", + "annotations": { + "description": "Keeps track of changes in the application image" + } } }, { "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "django-quickstart-source", + "name": "django-example", "annotations": { - "description": "Defines how to build the Django app." + "description": "Defines how to build the application" } }, "spec": { "source": { "type": "Git", "git": { - "uri": "${GIT_REPOSITORY}" + "uri": "${SOURCE_REPOSITORY_URL}" }, "contextDir": "${CONTEXT_DIR}" }, @@ -92,15 +80,16 @@ "type": "Source", "sourceStrategy": { "from": { - "kind": "ImageStream", - "name": "python-33-centos7" + "kind": "ImageStreamTag", + "namespace": "openshift", + "name": "python:3.3" } } }, "output": { "to": { "kind": "ImageStream", - "name": "django-quickstart-source" + "name": "django-example" } }, "triggers": [ @@ -110,13 +99,7 @@ { "type": "GitHub", "github": { - "secret": "secret123" - } - }, - { - "type": "Generic", - "generic": { - "secret": "secret123" + "secret": "${GITHUB_WEBHOOK_SECRET}" } } ] @@ -126,9 +109,9 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "${FRONTEND_SERVICE_NAME}", + "name": "django-frontend", "annotations": { - "description": "Defines how to deploy the Django app." + "description": "Defines how to deploy the application server" } }, "spec": { @@ -141,10 +124,11 @@ "imageChangeParams": { "automatic": true, "containerNames": [ - "django-quickstart" + "django-example" ], "from": { - "name": "django-quickstart-source:latest" + "kind": "ImageStreamTag", + "name": "django-example:latest" } } }, @@ -154,20 +138,20 @@ ], "replicas": 1, "selector": { - "name": "${FRONTEND_SERVICE_NAME}" + "name": "django-frontend" }, "template": { "metadata": { - "name": "${FRONTEND_SERVICE_NAME}", + "name": "django-frontend", "labels": { - "name": "${FRONTEND_SERVICE_NAME}" + "name": "django-frontend" } }, "spec": { "containers": [ { - "name": "django-quickstart", - "image": "django-quickstart-source", + "name": "django-example", + "image": "django-example", "ports": [ { "containerPort": 8080 @@ -209,16 +193,35 @@ } } }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}", + "annotations": { + "description": "Exposes the database server" + } + }, + "spec": { + "ports": [ + { + "name": "postgresql", + "port": 5432, + "targetPort": 5432 + } + ], + "selector": { + "name": "${DATABASE_SERVICE_NAME}" + } + } + }, { "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { "name": "${DATABASE_SERVICE_NAME}", - "labels": { - "name": "${DATABASE_SERVICE_NAME}" - }, "annotations": { - "description": "Defines how to deploy the database." + "description": "Defines how to deploy the database" } }, "spec": { @@ -270,50 +273,28 @@ } } } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "django-quickstart-source", - "annotations": { - "description": "Keeps track of changes in the Django app image." - } - } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "python-33-centos7", - "annotations": { - "description": "Keeps track of changes in the Python base image." - } - }, - "spec": { - "dockerImageRepository": "openshift/python-33-centos7" - } } ], "parameters": [ { - "name": "GIT_REPOSITORY", - "description": "Change this to match your project's Git repository", - "value": "git://github.com/openshift/django-ex.git" + "name": "SOURCE_REPOSITORY_URL", + "description": "The URL of the repository with your application source code", + "value": "https://github.com/openshift/django-ex.git" }, { "name": "CONTEXT_DIR", "description": "Set this to the relative path to your project if it is not in the root of your repository" }, { - "name": "FRONTEND_SERVICE_NAME", - "description": "Frontend service name", - "value": "django" + "name": "FRONTEND_ROUTE", + "description": "The exposed hostname that will route to the Django service", + "value": "django.app" }, { - "name": "FRONTEND_ROUTE", - "description": "The exposed hostname that will route to the frontend service", - "value": "django-frontend.apps" + "name": "GITHUB_WEBHOOK_SECRET", + "description": "A secret string used to configure the GitHub webhook", + "generate": "expression", + "from": "[a-zA-Z0-9]{40}" }, { "name": "DATABASE_SERVICE_NAME", diff --git a/openshift/templates/django.json b/openshift/templates/django.json index 0b6180c..936eea6 100644 --- a/openshift/templates/django.json +++ b/openshift/templates/django.json @@ -2,24 +2,24 @@ "kind": "Template", "apiVersion": "v1", "metadata": { - "name": "django-quickstart-source", + "name": "django-example", "annotations": { - "description": "Django application template that uses the Source build strategy.", + "description": "An example Django application with no database", "tags": "instant-app,python,django", - "iconClass" : "icon-python" + "iconClass": "icon-python" } }, "labels": { - "template": "django-quickstart-source" + "template": "django-example" }, "objects": [ { "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "${FRONTEND_SERVICE_NAME}", + "name": "django-frontend", "annotations": { - "description": "Exposes and load balances the Django app instances." + "description": "Exposes and load balances the application pods" } }, "spec": { @@ -31,7 +31,7 @@ } ], "selector": { - "name": "${FRONTEND_SERVICE_NAME}" + "name": "django-frontend" } } }, @@ -39,30 +39,40 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "${FRONTEND_SERVICE_NAME}-route" + "name": "django-route" }, "spec": { - "host" : "${FRONTEND_ROUTE}", - "to": { - "kind" : "Service", - "name" : "${FRONTEND_SERVICE_NAME}" - } + "host": "${FRONTEND_ROUTE}", + "to": { + "kind": "Service", + "name": "django-frontend" + } + } + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "django-example", + "annotations": { + "description": "Keeps track of changes in the application image" + } } }, { "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "django-quickstart-source", + "name": "django-example", "annotations": { - "description": "Defines how to build the Django app." + "description": "Defines how to build the application" } }, "spec": { "source": { "type": "Git", "git": { - "uri": "${GIT_REPOSITORY}" + "uri": "${SOURCE_REPOSITORY_URL}" }, "contextDir": "${CONTEXT_DIR}" }, @@ -70,15 +80,16 @@ "type": "Source", "sourceStrategy": { "from": { - "kind": "ImageStream", - "name": "${BUILDER_IMAGE_STREAM}" + "kind": "ImageStreamTag", + "namespace": "openshift", + "name": "python:3.3" } } }, "output": { "to": { "kind": "ImageStream", - "name": "django-quickstart-source" + "name": "django-example" } }, "triggers": [ @@ -88,13 +99,7 @@ { "type": "GitHub", "github": { - "secret": "secret123" - } - }, - { - "type": "Generic", - "generic": { - "secret": "secret123" + "secret": "${GITHUB_WEBHOOK_SECRET}" } } ] @@ -104,9 +109,9 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "${FRONTEND_SERVICE_NAME}", + "name": "django-frontend", "annotations": { - "description": "Defines how to deploy the Django app." + "description": "Defines how to deploy the application server" } }, "spec": { @@ -119,10 +124,11 @@ "imageChangeParams": { "automatic": true, "containerNames": [ - "django-quickstart" + "django-example" ], "from": { - "name": "django-quickstart-source:latest" + "kind": "ImageStreamTag", + "name": "django-example:latest" } } }, @@ -132,20 +138,20 @@ ], "replicas": 1, "selector": { - "name": "${FRONTEND_SERVICE_NAME}" + "name": "django-frontend" }, "template": { "metadata": { - "name": "${FRONTEND_SERVICE_NAME}", + "name": "django-frontend", "labels": { - "name": "${FRONTEND_SERVICE_NAME}" + "name": "django-frontend" } }, "spec": { "containers": [ { - "name": "django-quickstart", - "image": "django-quickstart-source", + "name": "django-example", + "image": "django-example", "ports": [ { "containerPort": 8080 @@ -186,42 +192,33 @@ } } } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "django-quickstart-source", - "annotations": { - "description": "Keeps track of changes in the Django app image." - } - } } ], "parameters": [ { - "name": "GIT_REPOSITORY", - "description": "Change this to match your project's Git repository", - "value": "git://github.com/openshift/django-ex.git" + "name": "SOURCE_REPOSITORY_URL", + "description": "The URL of the repository with your application source code", + "value": "https://github.com/openshift/django-ex.git" }, { "name": "CONTEXT_DIR", "description": "Set this to the relative path to your project if it is not in the root of your repository" }, { - "name": "FRONTEND_SERVICE_NAME", - "description": "Frontend service name", - "value": "django" + "name": "FRONTEND_ROUTE", + "description": "The exposed hostname that will route to the Django service", + "value": "django.app" + }, + { + "name": "GITHUB_WEBHOOK_SECRET", + "description": "A secret string used to configure the GitHub webhook", + "generate": "expression", + "from": "[a-zA-Z0-9]{40}" }, { "name": "DATABASE_SERVICE_NAME", "description": "Database service name" }, - { - "name": "FRONTEND_ROUTE", - "description": "The exposed hostname that will route to the frontend service", - "value": "django-frontend.apps" - }, { "name": "DATABASE_ENGINE", "description": "Database engine: postgresql, mysql or sqlite (default)" @@ -238,11 +235,6 @@ "name": "DATABASE_PASSWORD", "description": "Database user password" }, - { - "name": "BUILDER_IMAGE_STREAM", - "description": "Image Stream of the builder image", - "value": "python-33-centos7" - }, { "name": "APP_CONFIG", "description": "Relative path to Gunicorn configuration file (optional)"