1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/getting-started-cli-deploying-python-app.adoc
2023-05-11 20:40:30 +00:00

81 lines
3.2 KiB
Plaintext

// Module included in the following assemblies:
//
// * getting-started/openshift-cli.adoc
:_content-type: PROCEDURE
[id="getting-started-cli-deploying-python-app_{context}"]
= Deploying a Python application
The following procedure deploys a back-end service for the `parksmap` application. The Python application performs 2D geo-spatial queries against a MongoDB database to locate and return map coordinates of all national parks in the world.
The deployed back-end service is `nationalparks`.
.Prerequisites
* You must have access to an {product-title} cluster.
* You must have installed the OpenShift CLI (`oc`).
* You have a deployed image.
.Procedure
. To create a new Python application, enter the following command:
+
[source,terminal]
----
$ oc new-app python~https://github.com/openshift-roadshow/nationalparks-py.git --name nationalparks -l 'app=national-parks-app,component=nationalparks,role=backend,app.kubernetes.io/part-of=national-parks-app,app.kubernetes.io/name=python' --allow-missing-images=true
----
+
.Example output
+
[source,text]
----
--> Found image 0406f6c (13 days old) in image stream "openshift/python" under tag "3.9-ubi9" for "python"
Python 3.9
----------
Python 3.9 available as container is a base platform for building and running various Python 3.9 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
Tags: builder, python, python39, python-39, rh-python39
* A source build using source code from https://github.com/openshift-roadshow/nationalparks-py.git will be created
* The resulting image will be pushed to image stream tag "nationalparks:latest"
* Use 'oc start-build' to trigger a new build
--> Creating resources with label app=national-parks-app,app.kubernetes.io/name=python,app.kubernetes.io/part-of=national-parks-app,component=nationalparks,role=backend ...
imagestream.image.openshift.io "nationalparks" created
buildconfig.build.openshift.io "nationalparks" created
deployment.apps "nationalparks" created
service "nationalparks" created
--> Success
----
. To create a route to expose your application, `nationalparks`, enter the following command:
+
[source,terminal]
----
$ oc create route edge nationalparks --service=nationalparks
----
+
.Example output
+
[source,terminal]
----
route.route.openshift.io/parksmap created
----
. To retrieve the created application route, enter the following command:
+
[source,terminal]
----
$ oc get route
----
+
.Example output
+
[source,terminal]
----
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
nationalparks nationalparks-user-getting-started.apps.cluster.example.com nationalparks 8080-tcp edge None
parksmap parksmap-user-getting-started.apps.cluster.example.com parksmap 8080-tcp edge None
----