CoreOS + Vargrant でクラスタ構成を作る
CoreOSのクラスタ構成ことはじめとしてローカルPC上にCoreOS + Vargrantでテスト環境を作った。
環境
OSX 10.10.4
VirtualBox 4.3.30
Vagrant 1.7.4
coreos-vargrant でクラスタ構築
% git clone https://github.com/coreos/coreos-vagrant.git % cd coreos-vagrant/ % cp config.rb.sample config.rb #config.rbを編集 => $num_instances=3 % vagrant up % vagrant ssh core-01 CoreOS alpha (766.0.0) core@core-01 ~ $ exit % vagrant status Current machine states: core-01 running (virtualbox) core-02 running (virtualbox) core-03 running (virtualbox)
https://coreos.com/os/docs/latest/booting-on-vagrant.html
ifconfigしてVirtualBoxのgatewayのipを把握しておく。vboxnet<%d>で表示されてる。今回は172.17.8.1
複数ある場合はVirtualBoxの設定 -> ネットワーク -> アダプタ2 で確認
CoreOSの設定更新
cd coreos-vagrant cp user-data.sample user-data #user-dataを編集 => discovery: http://172.17.8.1:4001/v2/keys/machines vagrant reload
CoreOS上からクラスタを確認
% vagrant ssh core-01 core@core-01 ~ $ fleetctl list-machines -l MACHINE IP METADATA 18a7945540b041f6a61327a4149fd233 172.17.8.102 - 2d963622db9d4cfc959b3e6b633a4a8a 172.17.8.101 - b9fb68c68dcf47218f83a3755d991fdd 172.17.8.103 -
etcdctl 使ってみる
core@core-01 ~ $ etcdctl set hello world world core@core-01 ~ $ etcdctl get hello world core@core-01 ~ $ exit logout % vagrant ssh core-02 core@core-02 ~ $ etcdctl get hello world
おわり。