Compare commits

...

21 Commits

Author SHA1 Message Date
  Petr Hracek 587173e8dd
Update django.json 1 year ago
  Petr Hracek fe43560fd9
Fix empty image_name 1 year ago
  Petr Hracek 380fa28611
Merge pull request #210 from phracek/2_2_x_master_migrate_deployment 2 years ago
  Petr "Stone" Hracek 022e899ec9 Migration from DeploymentConfig to Deployment 2 years ago
  Petr Hracek 6e1bf649cc
Merge pull request #208 from phracek/2.2.x 2 years ago
  Petr Hracek f3d5a74cde
Merge branch '2.2.x' into 2.2.x 2 years ago
  Petr "Stone" Hracek 7e96a75807 Fix apiVersion for all API keys. 2 years ago
  BeataSolitudo 8f8f1048f1 Update README.md 2 years ago
  Lumir Balhar 46698d987f New version of psycopg2-binary works fine with Python 3.11 3 years ago
  Siteshwar Vashisht 200a5dafbe Fix broken links to documentation 3 years ago
  Lumír 'Frenzy' Balhar 439c427582 Mention the latest version in branch 2.2.x 4 years ago
  Lumír 'Frenzy' Balhar d409186155 Update pyscopg2-binary to 2.8.6 for Python 3.9 wheels 4 years ago
  Ben Parees 914c3ec7ad
Merge pull request #178 from sclorg/frenzymadness-patch-1 4 years ago
  Lumír 'Frenzy' Balhar f8f9d38b75
Mention Python compatibility in the readme 4 years ago
  Afreed-Sharief fa88380112 Update views.py 5 years ago
  Honza Horak a3cc749711 Update templates to 3.8 5 years ago
  Honza Horak d535d711a2
Merge pull request #162 from multi-arch/2.2.x 5 years ago
  Yaakov Selkowitz 2df0ccae87 Move templates to RHEL/CentOS/UBI 8 and PostgreSQL 12 5 years ago
  Lumír 'Frenzy' Balhar ba0c53d1fb
Merge pull request #157 from frenzymadness/psycopg2-wheels-2 5 years ago
  Lumir Balhar 6381ce544e Move from psycopg2 to psycopg2-binary to use manylinux wheels 5 years ago
  Lumir Balhar a33a1e9762 Update note in readme to reflect the old-new branches schema. 5 years ago
7 changed files with 66 additions and 141 deletions
Split View
  1. +3
    -3
      README.md
  2. +22
    -53
      openshift/templates/django-postgresql-persistent.json
  3. +22
    -53
      openshift/templates/django-postgresql.json
  4. +14
    -29
      openshift/templates/django.json
  5. +1
    -1
      requirements.txt
  6. +2
    -2
      welcome/templates/welcome/index.html
  7. +2
    -0
      welcome/views.py

+ 3
- 3
README.md View File

@ -2,7 +2,7 @@
This is a [Django](http://www.djangoproject.com) project that you can use as the starting point to develop your own and deploy it on an [OpenShift](https://github.com/openshift/origin) cluster.
**NOTE:** The current master branch works with Django 2.2 LTS. The version for older Django 1.11 LTS is in [branch 1.11.x](https://github.com/sclorg/django-ex/tree/1.11.x).
**NOTE:** This is an example Django application for specific Django LTS version. If you want an older or newer version, check the alternative branches.
The steps in this document assume that you have access to an OpenShift deployment that you can deploy applications on.
@ -56,9 +56,9 @@ To run this project in your development machine, follow these steps:
2. Ensure that the executable `pg_config` is available on your machine. You can check this using `which pg_config`. Otherwise, sqlite will be used.
3. Fork this repo and clone your fork:
**Note:** pg_config is not needed. You can use sqlite instead.
`git clone https://github.com/sclorg/django-ex.git`
3. Fork this repo and clone your fork. Make sure that you are in the right branch.
4. Install dependencies:


+ 22
- 53
openshift/templates/django-postgresql-persistent.json View File

@ -1,6 +1,6 @@
{
"kind": "Template",
"apiVersion": "v1",
"apiVersion": "template.openshift.io/v1",
"metadata": {
"name": "django-psql-persistent",
"annotations": {
@ -58,7 +58,7 @@
},
{
"kind": "Route",
"apiVersion": "v1",
"apiVersion": "route.openshift.io/v1",
"metadata": {
"name": "${NAME}"
},
@ -72,7 +72,7 @@
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"apiVersion": "image.openshift.io/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
@ -82,7 +82,7 @@
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"apiVersion": "build.openshift.io/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
@ -141,40 +141,25 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server",
"template.alpha.openshift.io/wait-for-ready": "true"
"template.alpha.openshift.io/wait-for-ready": "true",
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
}
},
"spec": {
"strategy": {
"type": "Recreate"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"django-psql-persistent"
],
"from": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${NAME}"
"matchLabels":{
"name": "${NAME}"
}
},
"template": {
"metadata": {
@ -305,41 +290,25 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "${DATABASE_SERVICE_NAME}",
"annotations": {
"description": "Defines how to deploy the database",
"template.alpha.openshift.io/wait-for-ready": "true"
"template.alpha.openshift.io/wait-for-ready": "true",
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"postgresql:${POSTGRESQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
}
},
"spec": {
"strategy": {
"type": "Recreate"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"postgresql"
],
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "postgresql:${POSTGRESQL_VERSION}"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${DATABASE_SERVICE_NAME}"
"matchLabels":{
"name": "${DATABASE_SERVICE_NAME}"
}
},
"template": {
"metadata": {
@ -440,15 +409,15 @@
{
"name": "PYTHON_VERSION",
"displayName": "Version of Python Image",
"description": "Version of Python image to be used (3.6 or latest).",
"value": "3.6",
"description": "Version of Python image to be used (3.6-ubi8, 3.8-ubi8, or latest).",
"value": "3.8-ubi8",
"required": true
},
{
"name": "POSTGRESQL_VERSION",
"displayName": "Version of PostgreSQL Image",
"description": "Version of PostgreSQL image to be used (10 or latest).",
"value": "10",
"description": "Version of PostgreSQL image to be used (10-el8, 12-el8, or latest).",
"value": "12-el8",
"required": true
},
{


+ 22
- 53
openshift/templates/django-postgresql.json View File

@ -1,6 +1,6 @@
{
"kind": "Template",
"apiVersion": "v1",
"apiVersion": "template.openshift.io/v1",
"metadata": {
"name": "django-psql-example",
"annotations": {
@ -58,7 +58,7 @@
},
{
"kind": "Route",
"apiVersion": "v1",
"apiVersion": "route.openshift.io/v1",
"metadata": {
"name": "${NAME}"
},
@ -72,7 +72,7 @@
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"apiVersion": "image.openshift.io/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
@ -82,7 +82,7 @@
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"apiVersion": "build.openshift.io/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
@ -141,40 +141,25 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server",
"template.alpha.openshift.io/wait-for-ready": "true"
"template.alpha.openshift.io/wait-for-ready": "true",
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
}
},
"spec": {
"strategy": {
"type": "Recreate"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"django-psql-example"
],
"from": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${NAME}"
"matchLabels":{
"name": "${NAME}"
}
},
"template": {
"metadata": {
@ -288,41 +273,25 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "${DATABASE_SERVICE_NAME}",
"annotations": {
"description": "Defines how to deploy the database",
"template.alpha.openshift.io/wait-for-ready": "true"
"template.alpha.openshift.io/wait-for-ready": "true",
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"postgresql:${POSTGRESQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
}
},
"spec": {
"strategy": {
"type": "Recreate"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"postgresql"
],
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "postgresql:${POSTGRESQL_VERSION}"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${DATABASE_SERVICE_NAME}"
"matchLabels":{
"name": "${DATABASE_SERVICE_NAME}"
}
},
"template": {
"metadata": {
@ -421,15 +390,15 @@
{
"name": "PYTHON_VERSION",
"displayName": "Version of Python Image",
"description": "Version of Python image to be used (3.6 or latest).",
"value": "3.6",
"description": "Version of Python image to be used (3.6-ubi8, 3.8-ubi8, or latest).",
"value": "3.8-ubi8",
"required": true
},
{
"name": "POSTGRESQL_VERSION",
"displayName": "Version of PostgreSQL Image",
"description": "Version of PostgreSQL image to be used (10 or latest).",
"value": "10",
"description": "Version of PostgreSQL image to be used (10-el8, 12-el8, or latest).",
"value": "12-el8",
"required": true
},
{


+ 14
- 29
openshift/templates/django.json View File

@ -1,6 +1,6 @@
{
"kind": "Template",
"apiVersion": "v1",
"apiVersion": "template.openshift.io/v1",
"metadata": {
"name": "django-example",
"annotations": {
@ -55,7 +55,7 @@
},
{
"kind": "Route",
"apiVersion": "v1",
"apiVersion": "route.openshift.io/v1",
"metadata": {
"name": "${NAME}"
},
@ -69,7 +69,7 @@
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"apiVersion": "image.openshift.io/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
@ -79,7 +79,7 @@
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"apiVersion": "build.openshift.io/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
@ -138,40 +138,25 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server",
"template.alpha.openshift.io/wait-for-ready": "true"
"template.alpha.openshift.io/wait-for-ready": "true",
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
}
},
"spec": {
"strategy": {
"type": "Rolling"
"type": "RollingUpdate"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"django-example"
],
"from": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${NAME}"
"matchLabels":{
"name": "${NAME}"
}
},
"template": {
"metadata": {
@ -251,8 +236,8 @@
{
"name": "PYTHON_VERSION",
"displayName": "Version of Python Image",
"description": "Version of Python image to be used (3.6 or latest).",
"value": "3.6",
"description": "Version of Python image to be used (3.6-ubi8, 3.8-ubi8, or latest).",
"value": "3.8-ubi8",
"required": true
},
{


+ 1
- 1
requirements.txt View File

@ -1,7 +1,7 @@
Django>=2.2.12,<3.0
django-debug-toolbar==2.2
gunicorn==20.0.4
psycopg2==2.8.5
psycopg2-binary==2.9.5
pytz==2020.1
sqlparse==0.3.1
whitenoise==5.1.0

+ 2
- 2
welcome/templates/welcome/index.html View File

@ -220,7 +220,7 @@ pre {
<section class='col-xs-12 col-sm-6 col-md-6'>
<section>
<h2>How to use this example application</h2>
<p>For instructions on how to use this application with OpenShift, start by reading the <a href="http://docs.okd.io/latest/dev_guide/templates.html#using-the-quickstart-templates">Developer Guide</a>.</p>
<p>For instructions on how to use this application with OpenShift, start by reading the <a href="https://docs.okd.io/latest/openshift_images/using-templates.html#templates-using-instant-app-quickstart_using-templates">Developer Guide</a>.</p>
<h2>Deploying code changes</h2>
<p>
@ -282,7 +282,7 @@ $ git push</pre>
<h2>Managing your application</h2>
<p>Documentation on how to manage your application from the Web Console or Command Line is available at the <a href="http://docs.okd.io/latest/dev_guide/overview.html">Developer Guide</a>.</p>
<p>Documentation on how to manage your application from the <a href="https://docs.okd.io/latest/web_console/web-console.html">Web Console</a> or <a href="https://docs.okd.io/latest/cli_reference/index.html">Command Line</a> is available at the <a href="http://docs.okd.io/latest/welcome/overview.html">OKD Documentation</a>.</p>
<h3>Web Console</h3>
<p>You can use the Web Console to view the state of your application components and launch new builds.</p>


+ 2
- 0
welcome/views.py View File

@ -9,6 +9,7 @@ from .models import PageView
# Create your views here.
def index(request):
"""Takes an request object as a parameter and creates an pageview object then responds by rendering the index view."""
hostname = os.getenv('HOSTNAME', 'unknown')
PageView.objects.create(hostname=hostname)
@ -19,4 +20,5 @@ def index(request):
})
def health(request):
"""Takes an request as a parameter and gives the count of pageview objects as reponse"""
return HttpResponse(PageView.objects.count())

Loading…
Cancel
Save