LoginSignup
18
16

More than 5 years have passed since last update.

RancherOSをCDブートで運用

Last updated at Posted at 2015-12-03

本記事はDocker Advent Calendar 2015の3日目の記事です。

RancherOSをCDブートで運用

参考: Rancher Documentation

HDDにデータを保存

参考: Booting from ISO

HDDにデータを保存
mkfs.ext4 -L RANCHER_STATE /dev/sda
reboot

ネットワーク設定

/usr/share/ros/os-config.yml
   network:
     dns:
       nameservers: [8.8.8.8, 8.8.4.4]
     interfaces:
-      eth*:
-        dhcp: true
+      eth0:
+        address: 10.10.10.2/24
+        gateway: 10.10.10.1
+        dhcp: false

もしくは/usr/share/ros/os-config.yml最終行に以下追記でもよい。
上の行に書いてある値を上書きしてくれる。

/usr/share/ros/os-config.yml
  #
  services_include:
    ubuntu-console: false
    debian-console: true
  network:
    interfaces:
      eth0:
        address: 10.10.10.2/24
        gateway: 10.10.10.1
        dhcp: false
reboot
CLIからIPを指定する場合
ip addr add 10.10.10.2/24 dev eth0
ip route add default via 10.10.10.1

debian-consoleに切り替える

service一覧を表示
sudo ros service list

https://raw.githubusercontent.com/rancher/os-services/v0.4.1/index.yml
のデータを表示する様子。

ros service enable debian-console
reboot
他の端末からssh接続ができる。
ssh rancher@10.10.10.2
  • passwordは rancher

注意点

ros service disable debian-console -> 再起動
ros service enable debian-console -> 再起動

をするとdebian-consoleのデータが消えます。

ubuntu-consoleに切り替える

  • 一度素os-consoleに切り替えてからでないと、別のconsoleに切り替えられません。
ros service disable debian-console
reboot
ros service enable ubuntu-console
reboot

sshd起動方法

  • os-consoleの場合: /usr/sbin/sshd
  • debian-consoleの場合
    • 自動で起動しました。

サービス自動起動方法(debian-console)

試しにcronを入れてみる
sudo apt-get install -y cron
/etc/rc.local
+ /etc/init.d/cron start
  exit 0

boot2dockerと各consoleのメモリ使用量比較

console メモリ DISK version
boot2docker 32M - -
RancherOS(os-console) 268M 195.8M 0.4.1
RancherOS(debian-console) 93M jessie
RancherOS(ubuntu-console) 215M trusty

マウント済みのHDD消去方法

/dev/sdaの先頭をゼロ埋めして強制再起動
dd if=/dev/zero of=/dev/sda bs=1M count=100
echo b > /proc/sysrq-trigger 

rancher/server起動

  • 手元の環境で実施した。
1GBの空き容量が必要
docker run -d -p 8080:8080 rancher/server
  • 起動まで3分ほどかかる。http://10.10.10.2:8080 にアクセス
  • Hostの追加。自身を登録するにはCustomをクリック。

hostadd.png

Containerの作成

containers.png

containers1.png

  • この状態でDISK 2.8GB、メモリ829MBを使用した。

services.png

  • Application Stackの作成も成功した。

Load Balancer

lbsetting.png

lb.png

8082.png

dockerコマンドのシステム側とユーザ側

  • システム側 : /usr/bin/system-docker
    • ユーザ側 : /usr/bin/docker

コンテナを自動起動させるには(これは成功しなかった)

/opt/rancher/bin/start.shを作成
sudo mkdir -p /opt/rancher/bin/
sudo touch /opt/rancher/bin/start.sh
sudo chmod +x /opt/rancher/bin/start.sh
/opt/rancher/bin/start.sh
docker start afe249cf26d4

まとめ

  • RancherOS 上で rancher/server を使うと問題なく動いて良い。
  • ホストOSをインストールしなくて良いので楽。
  • debian, ubuntuコンソールが便利。これにAnsible使ってサービス投入もありかも。
18
16
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
18
16