Created
November 28, 2015 04:45
-
-
Save yamamoto-febc/4270c35de7d254d9450e to your computer and use it in GitHub Desktop.
[実践編]docker-machine + さくらのクラウド:石狩〜東京間でスケールアウト可能なswarmクラスタ組むよ。 ref: http://qiita.com/yamamoto-febc/items/870e615c01315096039b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# コマンド入力補助用の環境変数設定 | |
$ export SAKURACLOUD_ACCESS_TOKEN=[さくらのクラウドのアクセストークン] | |
$ export SAKURACLOUD_ACCESS_TOKEN_SECRET=[さくらのクラウドのトークンシークレット] | |
# さくらのクラウド上にサーバ作成 | |
$ docker-machine create -d sakuracloud sakura-token | |
# docker-machineの対象サーバを切り替え | |
$ eval "$(docker-machine env sakura-token)" | |
# ディスカバリトークンの生成 | |
$ docker run swarm create | |
# | |
# トークンが出力されるため控えておく | |
# | |
# サーバを削除 | |
$ docker-machine rm sakura-token | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-machine create -d sakuracloud \ | |
--swarm \ | |
--swarm-master \ | |
--swarm-discovery token://<ディスカバリトークン> \ | |
--sakuracloud-region is1a \ | |
sakura-is1a-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 石狩第1リージョン | |
$ docker-machine create -d sakuracloud \ | |
--swarm \ | |
--swarm-discovery token://<ディスカバリトークン> \ | |
--sakuracloud-region is1a \ | |
sakura-is1a-agent | |
# 石狩第2リージョン | |
$ docker-machine create -d sakuracloud \ | |
--swarm \ | |
--swarm-discovery token://<ディスカバリトークン> \ | |
--sakuracloud-region is1b \ | |
sakura-is1b-agent | |
# 東京第1リージョン | |
$ docker-machine create -d sakuracloud \ | |
--swarm \ | |
--swarm-discovery token://<ディスカバリトークン> \ | |
--sakuracloud-region tk1a \ | |
sakura-tk1a-agent | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ eval "$(docker-machine env --swarm sakura-is1a-manager)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vi docker-compose.yml | |
web: | |
image: kitematic/hello-world-nginx | |
ports: | |
- "80:80" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker ps -a | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
bc79b4b45146 kitematic/hello-world-nginx "sh /start.sh" 7 seconds ago Up 6 seconds 133.242.52.77:80->80/tcp sakura-is1a-agent/sakuraswarm_web_1 | |
#以下swarm関連コンテナの出力のため省略 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose scale web=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker ps -a | |
6e7170526008 kitematic/hello-world-nginx "sh /start.sh" 17 seconds ago Up 15 seconds 27.133.129.167:80->80/tcp sakura-tk1a-agent/sakuraswarm_web_3 | |
3fe015b8f26c kitematic/hello-world-nginx "sh /start.sh" 17 seconds ago Up 15 seconds 153.127.193.144:80->80/tcp sakura-is1b-agent/sakuraswarm_web_2 | |
bc79b4b45146 kitematic/hello-world-nginx "sh /start.sh" 47 seconds ago Up 45 seconds 133.242.52.77:80->80/tcp sakura-is1a-agent/sakuraswarm_web_1 | |
#以下swarm関連コンテナの出力のため省略 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment