OpenShift Origin 3.6 : アプリケーションをデプロイする2017/11/23 |
アプリケーションをデプロイします。利用ユーザー視点での操作になります。
当例では以下のような環境を例に OpenShift クラスターを構成しています。
-----------+-----------------------------------------------------------+------------ |10.0.0.30 |10.0.0.51 |10.0.0.52 +----------+-----------+ +----------+-----------+ +----------+-----------+ | [ dlp.srv.world ] | | [ node01.srv.world ] | | [ node02.srv.world ] | | (Master Node) | | (Compute Node) | | (Compute Node) | | (Compute Node) | | | | | +----------------------+ +----------------------+ +----------------------+ |
[1] | Master ノードへ登録済みの任意のユーザーでログインして実行可能です。 操作としては、まず最初にプロジェクトを作成し、プロジェクト配下でアプリケーションをデプロイするという流れになります。 |
[cent@dlp ~]$ oc login Authentication required for https://dlp.srv.world:8443 (openshift) Username: cent Password: Login successful. You don't have any projects. You can try to create a new project, by running oc new-project <projectname> # [test-project] プロジェクト作成 [cent@dlp ~]$ oc new-project test-project Now using project "test-project" on server "https://dlp.srv.world:8443". You can add applications to this project with the 'new-app' command. For example, try: oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git to build a new example application in Ruby. # Docker Hub から取得するイメージをタグ付け [cent@dlp ~]$ oc tag --source=docker openshift/deployment-example:v2 deployment-example:latest Tag deployment-example:latest set to openshift/deployment-example:v2. # [deployment-example] アプリケーション デプロイ [cent@dlp ~]$ oc new-app deployment-example --> Found image da61bb2 (2 years old) in image stream "test-project/deployment-example" under tag "latest" for "deployment-example" * This image will be deployed in deployment config "deployment-example" * Port 8080/tcp will be load balanced by service "deployment-example" * Other containers can access this service through the hostname "deployment-example" * WARNING: Image "test-project/deployment-example:latest" runs as the 'root' user which may not be permitted by your cluster administrator --> Creating resources ... deploymentconfig "deployment-example" created service "deployment-example" created --> Success Run 'oc status' to view your app. # ステータス確認 [cent@dlp ~]$ oc status In project test-project on server https://dlp.srv.world:8443 svc/deployment-example - 172.30.141.119:8080 dc/deployment-example deploys istag/deployment-example:latest deployment #1 deployed 18 seconds ago - 1 pod View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'. # アプリケーション概要 [cent@dlp ~]$ oc describe svc/deployment-example Name: deployment-example Namespace: test-project Labels: app=deployment-example Annotations: openshift.io/generated-by=OpenShiftNewApp Selector: app=deployment-example,deploymentconfig=deployment-example Type: ClusterIP IP: 172.30.141.119 Port: 8080-tcp 8080/TCP Endpoints: 10.129.0.3:8080 Session Affinity: None Events: <none> # Pod 動作状況 [cent@dlp ~]$ oc get pods NAME READY STATUS RESTARTS AGE deployment-example-1-0w7fq 1/1 Running 0 8m # クラスターIP に HTTP アクセスして確認 [cent@dlp ~]$ curl 172.30.141.119:8080 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Deployment Demonstration</title> ..... ..... </head> <body> <div class="box"><h1>v2</h1><h2></h2></div> </body> # Pod にシェルアクセス [cent@dlp ~]$ oc exec -it deployment-example-1-0w7fq bash bash-4.2$ hostname deployment-example-1-0w7fq bash-4.2$ exit exit # アプリケーションを削除する場合は以下 [cent@dlp ~]$ oc delete all -l app=deployment-example deploymentconfig "deployment-example" deleted service "deployment-example" deleted pod "deployment-example-1-4bmf4" deleted [cent@dlp ~]$ oc get pods No resources found. |
[2] | OpenShift 管理コンソールからもアプリケーションの状況が確認できます。 |
Sponsored Link |