4.6. Python 애플리케이션 배포

다음 절차에서는 parksmap 애플리케이션에 대한 백엔드 서비스를 배포합니다. Python 애플리케이션은 MongoDB 데이터베이스에 대해 2D 지리 공간 쿼리를 수행하여 전 세계 모든 국립공원의 지도 좌표를 찾고 반환합니다.

배포된 백엔드 서비스는 nationalparks 입니다.

사전 요구 사항

  • OpenShift Container Platform 클러스터에 대한 액세스 권한이 있어야 합니다.
  • OpenShift CLI(oc)가 설치되어 있어야 합니다.
  • 배포된 이미지가 있습니다.

절차

  1. 새 Python 애플리케이션을 생성하려면 다음 명령을 입력합니다.

    $ 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

    출력 예

    --> Found image 0406f6c (13 days old) in image stream "openshift/python" under tag "3.9-ubi8" 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

  2. nationalparks 애플리케이션을 공개할 경로를 생성하려면 다음 명령을 입력합니다.

    $ oc create route edge nationalparks --service=nationalparks

    출력 예

    route.route.openshift.io/parksmap created

  3. 생성된 애플리케이션 경로를 검색하려면 다음 명령을 입력합니다.

    $ oc get route

    출력 예

    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

추가 리소스