Skip to content

rschumm/hallopython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimales Beispiel für eine Phython (Flask) - Applikation in OpenShift:
(läuft auf jedem OpenShift Cluster)

HalloPython for OpenShift s2i insprired by the Docker Example

features

Python Flask Application with HTML templating and Layout based on Bootstrap.
Redis Cache Backend with persistent Storage.

OpenShift erstellt für die Python-Applikation automatisch eine BuildConfig und DeploymentConfig (etc.), baut ein Docker-Image in der internen Registry und lässt es laufen.
Der Redis-Cache wird in diesem Set-Up von Hand mit einem Template von OpenShift erstellt.

OpenShift

set up OpenShift Project

oc new-project py

set up Redis

Apply the template redis-persistent (Do this with the button "Add to project -> import from json" hand or by oc create -f...) - or by just selection Redis from the Catalog.

set up Python Applikation

oc new-app openshift/python~https://github.com/rschumm/hallopython.git 
optional: --source-secret='rs-password'

Finishing:

  • in the generated build-config of the Phyton-Application, add an environment-variable with name REDIS_PW with the value database-password from the redis secret (this will be read by the Python Application via os.getenv('REDIS_PW'))
  • make sure the generated service points to port 5000
  • add a route to port 5000 to the generated service
  • voilà... should work.

Goodie: Job and CronJob

The little script job.py will be packed in the same image by the builder image.
As a demo, job.py can be started by a Kubernetes Job or CronJob:

oc apply -f job.yml
oc apply -f cronjob.yml

respectively.

Doku

Documentation for the oc new app command.

Local run

to run the application locally: (needs a redis cache of course...)

pip install -r requirements.txt
python app.py 

About

Python Flask Hallo Welt for OpenShift

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published