OpenShift Origin (OKD) 3.11 : アプリケーションをデプロイする2018/11/20 |
アプリケーションをデプロイします。利用ユーザー視点での操作になります。
当例では以下のような環境を例に OpenShift クラスターを構成しています。
-----------+-----------------------------+-----------------------------+------------ |10.0.0.25 |10.0.0.51 |10.0.0.52 +----------+-----------+ +----------+-----------+ +----------+-----------+ | [ ctrl.srv.world ] | | [ node01.srv.world ] | | [ node02.srv.world ] | | (Master Node) | | (Compute Node) | | (Compute Node) | | (Infra Node) | | | | | | (Compute Node) | | | | | +----------------------+ +----------------------+ +----------------------+ |
[1] | Master ノードへ登録済みの任意のユーザーでログインして実行可能です。 操作としては、まず最初にプロジェクトを作成し、プロジェクト配下でアプリケーションをデプロイするという流れになります。 |
[cent@ctrl ~]$ oc login Authentication required for https://ctrl.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@ctrl ~]$ oc new-project test-project Now using project "test-project" on server "https://ctrl.srv.world:8443". You can add applications to this project with the 'new-app' command. For example, try: oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git to build a new example application in Ruby. # Docker Hub から取得するイメージをタグ付け [cent@ctrl ~]$ oc tag --source=docker openshift/deployment-example:v2 deployment-example:latest Tag deployment-example:latest set to openshift/deployment-example:v2. # [deployment-example] アプリケーション デプロイ [cent@ctrl ~]$ oc new-app deployment-example --> Found image da61bb2 (3 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.apps.openshift.io "deployment-example" created service "deployment-example" 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/deployment-example' Run 'oc status' to view your app. # ステータス確認 [cent@ctrl ~]$ oc status In project test-project on server https://ctrl.srv.world:8443 svc/deployment-example - 172.30.43.30:8080 dc/deployment-example deploys istag/deployment-example:latest deployment #1 deployed about a minute ago - 1 pod 2 infos identified, use 'oc status --suggest' to see details. # アプリケーション概要 [cent@ctrl ~]$ 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.43.30 Port: 8080-tcp 8080/TCP TargetPort: 8080/TCP Endpoints: 10.130.0.3:8080 Session Affinity: None Events: <none> # Pod 動作状況 [cent@ctrl ~]$ oc get pods NAME READY STATUS RESTARTS AGE deployment-example-1-2jzws 1/1 Running 0 1m # クラスターIP に HTTP アクセスして確認 [cent@ctrl ~]$ curl 172.30.43.30: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> </html> # アプリケーションを削除する場合は以下 [cent@ctrl ~]$ oc delete all -l app=deployment-example deploymentconfig "deployment-example" deleted pod "deployment-example-1-dv2fh" deleted service "deployment-example" deleted [cent@ctrl ~]$ oc get pods No resources found. |
[2] | OpenShift 管理コンソールからもアプリケーションの状況が確認できます。 |
Sponsored Link |