2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PCF DevをWindowsで使ってみる Part-2

Posted at

はじめに

PCF DevをWindowsで使ってみる Part-1の続きです。

1. 前提

以下の環境で動作した内容を記述しています。

Windows 10 Home (64bit)
VirtualBox 5.2
cf-cli-installer_6.32.0_winx64
pcfdev-v0.28.0+PCF1.11.0-windows
JDK 1.8 *サンプルアプリのBuildで使用

2. サンプルアプリをビルド

githubからサンプルアプリを取得

>git clone https://github.com/cloudfoundry-samples/spring-music

PCF Devにログイン

> cf login -a api.local.pcfdev.io --skip-ssl-validation
API endpoint:  api.local.pcfdev.io   
Email>     user
Password>  pass

サンプルアプリのフォルダに移動しビルド

> cd .\spring-music
> .\gradlew.bat assemble

image.png

3.サンプルアプリをデプロイ

PDC DEVにpush

> cf push --hostname spring-music

image.png

image.png

4.サンプルアプリにアクセス

ブラウザでhttp://spring-music.local.pcfdev.io/にアクセス
image.png

5.ログを確認

直近のスナップショット

> cf logs spring-music --recent

image.png

ストリームログ(ブラウザでリロードするとログが表示されます)

> cf logs spring-music

image.png

6.データベースをバインド

今の状態だとデータはメモリーに格納されるので、変更したデータは保存できません。ブラウザ画面右上のInfoアイコンをクリックすると状態が見れます。
image.png

早速データベースをバインドしてみます。mysqlを使いますがリストしてみると512mbと1gbのものがマーケットプレイスにあるようです。今回は512mbのものを使います。

> cf marketplace -s p-mysql
> cf create-service p-mysql 512mb my-spring-db
> cf bind-service spring-music my-spring-db

image.png

バインドがうまくいったらアプリを再起動し、バインド状況を確認します。

> cf restart spring-music
> cf services

image.png

ブラウザ画面でも確認。
image.png

7.アプリをスケールアウト、スケールアップする

インスタンスを2つに増やし、状態を確認。

> cf scale spring-music -i 2
> cf app spring-music

image.png

メモリとディスクを増やす(失敗)

> cf scale spring-music -m 1G
> cf scale spring-music -k 512M

※非力なマシンでスケールアップは耐えられず、コンソールにログインしてみたところアプリがクラッシュしていました。残念、、、
image.png

参考ページ

https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry-dev/deploy-the-sample-app
https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry-dev/view-the-logs
https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry-dev/connect-a-database
https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry-dev/scale-the-app

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?