3.2.2.2. OpenShift でサンプルアプリケーションを設定する方法


  1. OpenShift インスタンスにログインします。

    $ oc login <url>
  2. 必要に応じて新規プロジェクトを作成します。

    $ oc new-project jws-bin-demo
  3. oc get is -n openshift でアプリケーションに使用する OpenShift イメージストリームの JWS を特定します。

    $ oc get is -n openshift | grep ^jboss-webserver | cut -f1 -d ' '
    
    jboss-webserver30-tomcat7-openshift
    jboss-webserver30-tomcat8-openshift
    jboss-webserver31-tomcat7-openshift
    jboss-webserver31-tomcat8-openshift
  4. イメージストリームおよびアプリケーション名を指定して、新規ビルド設定を作成します。

    $ oc new-build --binary=true \
     --image-stream=jboss-webserver31-tomcat8-openshift \
     --name=jws-wsch-app
    
    --> Found image 8c3b85b (4 weeks old) in image stream "openshift/jboss-webserver31-tomcat8-openshift" under tag "latest" for "jboss-webserver31-tomcat8-openshift"
    
        JBoss Web Server 3.1
        --------------------
        Platform for building and running web applications on JBoss Web Server 3.1 - Tomcat v8
    
        Tags: builder, java, tomcat8
    
        * A source build using binary input will be created
          * The resulting image will be pushed to image stream "jws-wsch-app:latest"
          * A binary build was created, use 'start-build --from-dir' to trigger a new build
    
    --> Creating resources with label build=jws-wsch-app ...
        imagestream "jws-wsch-app" created
        buildconfig "jws-wsch-app" created
    --> Success
  5. バイナリービルドを開始します。OpenShift イメージビルドのバイナリー入力にソースディレクトリーを使用するように OpenShift に指示します。

    $ oc start-build jws-wsch-app --from-dir=./ocp --follow
    
    Uploading directory "ocp" as binary input for the build ...
    build "jws-wsch-app-1" started
    Receiving source from STDIN as archive ...
    
    Copying all deployments war artifacts from /home/jboss/source/deployments directory into /opt/webserver/webapps for later deployment...
    '/home/jboss/source/deployments/websocket-chat.war' -> '/opt/webserver/webapps/websocket-chat.war'
    
    
    Pushing image 172.30.202.111:5000/jws-bin-demo/jws-wsch-app:latest ...
    Pushed 0/7 layers, 7% complete
    Pushed 1/7 layers, 14% complete
    Pushed 2/7 layers, 29% complete
    Pushed 3/7 layers, 49% complete
    Pushed 4/7 layers, 62% complete
    Pushed 5/7 layers, 92% complete
    Pushed 6/7 layers, 100% complete
    Pushed 7/7 layers, 100% complete
    Push successful
  6. イメージに基づいて新しい OpenShift アプリケーションを作成します。

    $ oc new-app jws-wsch-app
    
    --> Found image e5f3a6b (About a minute old) in image stream "jws-bin-demo/jws-wsch-app" under tag "latest" for "jws-wsch-app"
    
        JBoss Web Server 3.1
        --------------------
        Platform for building and running web applications on JBoss Web Server 3.1 - Tomcat v8
    
        Tags: builder, java, tomcat8
    
        * This image will be deployed in deployment config "jws-wsch-app"
        * Ports 8080/tcp, 8443/tcp, 8778/tcp will be load balanced by service "jws-wsch-app"
          * Other containers can access this service through the hostname "jws-wsch-app"
    
    --> Creating resources ...
        deploymentconfig "jws-wsch-app" created
        service "jws-wsch-app" created
    --> Success
        Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
         'oc expose svc/jws-wsch-app'
        Run 'oc status' to view your app.
  7. サービスを公開して、アプリケーションがユーザーにアクセスできるようにします。

    # to check the name of the service to expose
    $ oc get svc -o name
    
    service/jws-wsch-app
    
    # to expose the service
    $ oc expose svc/jws-wsch-app
    
    route "jws-wsch-app" exposed
  8. 公開されたルートのアドレスを取得します。

    oc get routes --no-headers -o custom-columns='host:spec.host' jws-wsch-app
  9. ブラウザーでアプリケーションにアクセスします: http://<address_of_exposed_route>/websocket-chat
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る