- 追加された行はこの色です。
- 削除された行はこの色です。
「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfrastructure.osscons.jp]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。
-[[戻る>OpenShift]]
*目次 [#x4916341]
#contents
*概要 [#lf3cae5d]
-「[[ファースト・ステップ>OpenShiftファースト・ステップ]]」では、~
基本的操作とJBossアプリケーションのデプロイを行った。
-「セカンド・ステップ」では、~
ASP.NET Coreアプリケーションのデプロイを行う。
-いきなり
>「まずは手順に従って、imagestreamを設定するのですが、~
最初は検証用のプロジェクトを作ってそのプロジェクトに~
imagestreamを作ってみましょう。」
>とあって、「[[imagestream>OpenShift#r01d6b00]]」なんて「[[ファースト・ステップ>OpenShiftファースト・ステップ]]」で~
出てきてないので、潔く「Red Hat Customer Portal」を読もうと思いました。
*詳細 [#sf031fab]
**其の一 [#he8efe1f]
**2.1. Install [[Image Streams>OpenShift#r01d6b00]] [#v517c590]
***2.1. Install [[Image Streams>OpenShift#r01d6b00]] [#v517c590]
-dotnetの一覧表示
--OpenShift Container Platformのインストールの一部である場合がある。
--次のコマンドを実行で、グローバルに使用可能なdotnetを一覧表示する。
***dotnetの一覧表示 [#d86a025e]
--既に OpenShift の一部である場合がある。
--次のコマンドで、名前空間で使用可能なdotnetを一覧表示する。
>oc describe is dotnet --namespace openshift
-
***[[Image Streams>OpenShift#r01d6b00]]を追加 [#h6fe4348]
希望のバージョンがない場合、[[Image Streams>OpenShift#r01d6b00]]を追加できる。
>oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams.json
***2.2. Deploy Applications [#d7ebdc73]
***[[Image Streams>OpenShift#r01d6b00]]をグローバルに追加 [#n9eb2b8c]
権限があれば、[[Image Streams>OpenShift#r01d6b00]]をグローバルに追加できる。
>oc create --namespace openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams.json
***2.3. Configuration [#k34561d1]
**2.2. Deploy Applications [#d7ebdc73]
***2.4. Sample Applications [#s4593bee]
***oc new-app [#b8fa42da]
github.comのredhat-developer/s2i-dotnetcore-exの~
dotnetcore-2.0ブランチのaspnetcore2アプリをappフォルダにデプロイする。~
(dotnet:2.0で)読み込んだ[[Image Streams>OpenShift#r01d6b00]]と紐付け?
>oc new-app --name=exampleapp 'dotnet:2.0~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnetcore-2.0' --build-env DOTNET_STARTUP_PROJECT=app
***2.5. Create a Runtime Image [#mb1e4050]
***進行状況の確認 [#ka02c0ae]
>oc logs -f bc/exampleapp
**其の二 [#h96454a6]
***[[サービス>OpenShift#l875353c]]のルートを作成する。 [#u220d51a]
>oc expose svc/exampleapp
>oc get routes
**2.3. Configuration [#k34561d1]
***概要 [#s621136d]
-.NET Coreイメージは、.NET Core用の環境変数をサポートしている。
-これらの変数は、
--ビルド構成の一部として設定することも、
--リポジトリの「.s2i/environment」ファイルに追加することも
>できる。
***環境変数の一覧 [#y7b1efea]
|#|名前|説明|既定値|h
|1|DOTNET_STARTUP_PROJECT|プロジェクト・ファイルを含むフォルダ||
|2|DOTNET_ASSEMBLY_NAME|アセンブリ名(.dll拡張子を含めない)|プロジェクト・ファイル名|
|3|DOTNET_RESTORE_SOURCES|NuGetパッケージソースのスペース区切りリスト。NuGet.configを上書き。|Unset|
|4|DOTNET_NPM_TOOLS|NPMパッケージのリスト|Unset|
|5|DOTNET_TEST_PROJECTS|テストプロジェクトのフォルダのリスト|Unset|
|6|DOTNET_CONFIGURATION|デバッグモード(Release)/リリースモード(Debug)|Release|
|7|ASPNETCORE_URLS|公開ポート(OpenShiftに於いて変更は非推奨)|http://*:8080|
**2.4. Sample Applications [#s4593bee]
3つのサンプルアプリケーションが利用可能
***説明 [#caaf8051]
|#|名前|説明|h
|1|dotnet-example|デフォルトのMVCアプリケーション|
|2|dotnet-runtime-example|ランタイム・イメージとビルド・チェーンを使用して&br;MVCアプリをビルドする方法を示す。|
|3|dotnet-pgsql-persistent|Music Storeサンプルアプリケーション|
***利用 [#u35c1046]
-ポータルを使用
--プロジェクトを参照
--[プロジェクトに追加]をクリック
-CLIを使用
--プロジェクトに追加
---dotnet-example
>oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-example.json
---dotnet-runtime-example
>oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-runtime-example.json
---dotnet-pgsql-persistent.json
> oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-pgsql-persistent.json
--グローバルに追加
---dotnet-example
>oc create -n openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-example.json
>oc replace -n openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-example.json
---dotnet-runtime-example
>oc create -n openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-runtime-example.json
>oc replace -n openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-runtime-example.json
---dotnet-pgsql-persistent.json
>oc create -n openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-pgsql-persistent.json
>oc replace -n openshift -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-pgsql-persistent.json
**2.5. Create a Runtime Image [#mb1e4050]
-[[chaining-buildsのBuild Configuration>OpenShift#tf47d740]]は、~
dotnet-runtime-example templateが参考になる。
-このテンプレートでは、
--「*-build」と
--「*-runtime」の
>[[Build Configuration>OpenShift#tf47d740]]を定義する。
***ビルド・イメージ [#i8f20e54]
-GitHubプロジェクトから構築され、
-変更を自動的に再構築するトリガを持つ。
--プロジェクトが変更されたとき
--またはベース・イメージ(dotnet-20-rhel7)が更新されたとき
***ランタイム・イメージ [#t6a48587]
-dotnet-20-runtime-rhel7ベース・イメージから構築される。
--ビルド・イメージからtar.gzファイルを取得。
--ビルド設定でこのソース定義を使用。
-変更を自動的に再構築するトリガを持つ。
--プロジェクトの内部[[Image Streams>OpenShift#r01d6b00]]でビルドイメージが更新されたとき、
--またはdotnet-20-runtime-rhel7ベースイメージが更新されたときに、
-ランタイムイメージ用に定義されたデプロイメントを持つ。
--ビルドイメージにはデプロイメントは必要ない。
***トリガ [#pca91ef7]
トリガを使用すると、イメージやコードが更新されたときに、~
チェーン内のオブジェクトが必要に応じて再構築される。
*演習 [#x661662d]
-ログイン
>oc login https://opnshdnsxx.centralus.cloudapp.azure.com --token=XXXXX
**dotnet-example [#b08fcd4a]
***[[Image Streams>OpenShift#r01d6b00]] + GitソースURIから [#s0e2e5f5]
-プロジェクトを生成
>oc oc new-project pj11
-[[Image Streams>OpenShift#r01d6b00]]の読込。
>oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams.json
-アプリケーションを生成
>oc new-app --name=exampleapp 'dotnet:2.0~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnetcore-2.0' --build-env DOTNET_STARTUP_PROJECT=app
-進行状況の確認~
>oc logs -f bc/exampleapp
-[[サービス>OpenShift#l875353c]]のルートを作成する。
>oc expose svc/exampleapp
>oc get routes
-[[サービス>OpenShift#l875353c]]にアクセスする。
***テンプレートから [#z54b90a2]
-プロジェクトを生成
>oc oc new-project pj11
-テンプレートの読込
>oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-example.json
-アプリケーションを生成
>oc new-app dotnet-example --name=exampleapp
-進行状況の確認~
>oc logs -f bc/exampleapp
-[[サービス>OpenShift#l875353c]]のルートを作成する。
>oc expose svc/exampleapp
>oc get routes
-[[サービス>OpenShift#l875353c]]にアクセスする。
**dotnet-runtime-example [#z9e1fb1d]
***テンプレートから [#y8812782]
-プロジェクトを生成
>oc oc new-project pj2
-テンプレートの読込
>oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-runtime-example.json
-アプリケーションを生成
>oc new-app dotnet-runtime-example --name=runtimeexampleapp
-進行状況の確認~
>oc logs -f bc/runtimeexampleapp
-[[サービス>OpenShift#l875353c]]のルートを作成する。
>oc expose svc/runtimeexampleapp
>oc get routes
-[[サービス>OpenShift#l875353c]]にアクセスする。
**dotnet-pgsql-persistent [#r7fc29bf]
***テンプレートから [#v2a7923f]
-プロジェクトを生成
>oc oc new-project pj2
-テンプレートの読込
> oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/templates/dotnet-pgsql-persistent.json
-アプリケーションを生成
>oc new-app dotnet-pgsql-persistent --name=persistentapp
-進行状況の確認~
>oc logs -f bc/persistentapp
-[[サービス>OpenShift#l875353c]]のルートを作成する。
>oc expose svc/persistentapp
>oc get routes
-[[サービス>OpenShift#l875353c]]にアクセスする。
*参考 [#sa74f43c]
**銀の光と碧い空 [#c6a0a798]
-OpenShift で .NET Core 2.0を使いはじめる~
http://tech.tanaka733.net/entry/2017/09/06/OpenShift_%E3%81%A7_.NET_Core_2.0%E3%82%92%E4%BD%BF%E3%81%84%E3%81%AF%E3%81%98%E3%82%81%E3%82%8B
**redhat.com [#ga8c3948]
-Developing .NET Core 2.0 Web Applications on OpenShift - RHD Blog~
https://developers.redhat.com/blog/2017/11/22/developing-net-core-2-0-web-applications-openshift/
***Red Hat Customer Portal [#we8ccdea]
-Getting Started Guide~
https://access.redhat.com/documentation/en-us/net_core/2.0/html/getting_started_guide/
--Chapter 1. .NET Core 2.0 on Red Hat Enterprise Linux~
https://access.redhat.com/documentation/en-us/net_core/2.0/html/getting_started_guide/gs_install_dotnet
---1.1. Install and Register Red Hat Enterprise Linux
---1.2. Install .NET Core
---1.3. Create an Application
---1.4. Publish Applications~
1.4.1. Publish .NET Core Applications~
1.4.2. Publish ASP.NET Core Applications
---1.5. Run Applications on Docker
--Chapter 2. .NET Core 2.0 on Red Hat OpenShift Container Platform~
https://access.redhat.com/documentation/en-us/net_core/2.0/html/getting_started_guide/gs_dotnet_on_openshift
---2.1. Install Image Streams
---2.2. Deploy Applications
---2.3. Configuration
---2.4. Sample Applications
---2.5. Create a Runtime Image
**openshift.com [#n82796b5]
-Announcing .NET Core 2.0 Support for OpenShift – OpenShift Blog~
https://blog.openshift.com/announcing-net-core-2-0-support-openshift/