2.7.3. フロントエンドコンポーネントのデプロイ

フロントエンドコンポーネントを作成およびデプロイするには、Node.js アプリケーションをダウンロードし、ソースコードを odo でクラスターにプッシュします。

手順

  1. フロントエンドアプリケーションのサンプルをダウンロードします。

    $ git clone https://github.com/openshift/nodejs-ex frontend
  2. 現在のディレクトリーをフロントエンドディレクトリーに切り替えます。

    $ cd frontend
  3. フロントエンドが Node.js アプリケーションであることを確認するために、ディレクトリーの内容を一覧表示します。

    $ ls

    出力例

    README.md       openshift       server.js       views
    helm            package.json    tests

    注記

    フロントエンドコンポーネントはインタプリター型言語で記述され (Node.js)、ビルドされる必要はありません。

  4. frontend という名前の Node.js コンポーネントタイプのコンポーネント設定を作成します。

    $ odo create nodejs frontend

    出力例

     ✓  Validating component [5ms]
    Please use `odo push` command to create the component with source deployed

  5. フロントエンドインターフェイスにアクセスするための URL を作成します。

    $ odo url create myurl

    出力例

     ✓  URL myurl created for component: nodejs-nodejs-ex-pmdp

  6. コンポーネントを OpenShift Container Platform クラスターにプッシュします。

    $ odo push

    出力例

    Validation
     ✓  Checking component [7ms]
    
     Configuration changes
     ✓  Initializing component
     ✓  Creating component [134ms]
    
     Applying URL changes
     ✓  URL myurl: http://myurl-app-myproject.192.168.42.79.nip.io created
    
     Pushing to component nodejs-nodejs-ex-mhbb of type local
     ✓  Checking files for pushing [657850ns]
     ✓  Waiting for component to start [6s]
     ✓  Syncing files to the component [408ms]
     ✓  Building component [7s]
     ✓  Changes successfully pushed to component