LoginSignup
23
23

More than 5 years have passed since last update.

Running Kubernetes on CoreOS with flannel (formerly Rudder)

Last updated at Posted at 2014-08-29

Introducing flannel: An etcd backed overlay network for containers
https://coreos.com/blog/introducing-rudder/

Things are not as easy on other cloud providers where a host cannot get an entire subnet to itself. Rudder aims to solve this problem by creating an overlay mesh network that provisions a subnet to each server.

Running Kubernetes Example on CoreOS, Part 2 - Qiita
http://qiita.com/yungsang/items/f286154be7bb6c4ef09f

で懸案になっていた VirtualBox でのコンテナ間のネットワーキングが Rudder によって解決できそうです。

今回大きく変更したのは、master.ymlminion.yml で、
flannel のおかげで複雑だったブリッジや iptables の設定が一切必要無くなりました!素晴らしいー!!

もちろん、前回手作業で行った「コンテナ間のルーティングの設定」も不要!!

ここでポイントとなったのは、

minion.yml
    - name: flannel.service
      command: start
      content: |
        [Unit]
        Requires=etcd.service
        After=etcd.service

        [Service]
        ExecStart=/opt/bin/flanneld -iface=$public_ipv4

flannel に対して使用する IP アドレス(インターフェース)を指定してあげること。
これをしないと Vagrant で起動した場合に、全ての VM で共通のプライベートな IP が選択されてしまい、全ての VM で同じ SUBNET が設定されてしまう結果になりました。

以下、Kubernetes の操作は前回と全く変更ありません。

コードは前回同様、
Running Kubernetes Example on CoreOS, Part 2 with Rudder
https://gist.github.com/YungSang/6177b69f1754f0590dbe
に置いてあります。

Step Zero: クラスタの構築

$ git clone https://gist.github.com/6177b69f1754f0590dbe.git
$ vagrant up

これで、etcd discovery 用に一つ、Kubernetes master 用に一つ、Kubernetes minion が2つ起動されます。

SSH tunnel の設定

ローカルマシンから kubecfg を使う場合は、以下の設定をします。
master にログインしてから kubecfg を使っても同じです。

$ curl -OL http://storage.googleapis.com/kubernetes/darwin/kubecfg
$ chmod +x kubecfg
$ mv kubecfg /usr/local/bin
$ kubecfg --version
Kubernetes v0.2-dev
$ vagrant ssh-config master > ssh.config
$ ssh -f -nNT -L 8080:127.0.0.1:8080 -F ssh.config master
$ kubecfg list pods
ID                  Image(s)            Host                Labels              Status
----------          ----------          ----------          ----------          ----------


Step One: redis master の起動

$ kubecfg -c redis-master.json create pods

Step Two: redis master service の設定

$ kubecfg -c redis-master-service.json create services

Step Three: redis slave の起動

$ kubecfg -c redis-slave-controller.json create replicationControllers

Step Four: redis slave service の設定

$ kubecfg -c redis-slave-service.json create services

Step Five: frontend UI の起動

$ kubecfg -c frontend-controller.json create replicationControllers
$ open http://192.168.12.11:8000
$ open http://192.168.12.12:8000

どちらからアクセスしても Guestbook の同期がちゃんと取れています。

23
23
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
23
23