Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

CoreOSによるDockerコンテナのクラスタリング

15,189 views

Published on

2014年09月06日(土)に行われた第4回 コンテナ型仮想化の情報交換会@東京の発表資料。

Published in: Technology

CoreOSによるDockerコンテナのクラスタリング

  1. 1. [Unit] Description=busybox Requires=docker.service After=docker.service [Service] TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill busybox ExecStartPre=-/usr/bin/docker rm busybox ExecStartPre=/usr/bin/docker pull busybox ExecStart=/usr/bin/docker run --name busybox busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done" ExecStop=/usr/bin/docker stop busybox [X-Fleet] X-Conflicts=busybox@*.service
  2. 2. coreos: etcd: discovery: https://discovery.etcd.io/<token> addr: $private_ipv4:4001 peer-addr: $private_ipv4:7001 units: - name: etcd.service command: start - name: fleet.service command: start ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUaf Ogrm+h... write_files: - path: /etc/motd permissions: 0644 owner: root content: | Good news, everyone!
  3. 3. #cloud-config coreos: update: reboot-strategy: best-effort etcd: # generate a new token for each unique cluster from https://discover y.etcd.io/new discovery: https://discovery.etcd.io/<token> addr: $private_ipv4:4001 peer-addr: $private_ipv4:7001 units: - name: etcd.service command: start - name: fleet.service command: start
  4. 4. write_files: - path: /tmp/busybox@.service content: | [Unit] Description=busybox Requires=docker.service After=docker.service [Service] TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill busybox-%i ExecStartPre=-/usr/bin/docker rm busybox-%i ExecStartPre=/usr/bin/docker pull busybox ExecStart=/usr/bin/docker run --name busybox-%i busybox /bin/sh - c "while true; do echo Hello World; sleep 1; done" ExecStop=/usr/bin/docker stop busybox-%i [X-Fleet] X-Conflicts=busybox@*.service
  5. 5. # 必要に応じて gcloud config set project <project_id> gcloud config set compute/zone asia-east1-a gcloud config set compute/region asia-east1 # 3つのインスタンスを起動 gcloud compute instances create core1 core2 core3 --image coreos --machine-type f1-micro --metadata-from-file user-data=cloud-config.ya ml
  6. 6. # ログイン gcloud compute ssh core1 # サービスの登録と起動 fleetctl submit /tmp/busybox@.service fleetctl start busybox@{1,2}.service fleetctl list-units
  7. 7. # unitに割り当てのあるインスタンスを削除してみる gcloud compute instances delete core2 gcloud compute ssh core1 # フェイルオーバーが行われることを確認 fleetctl list-units UNIT DSTATE STATE MACHINE ACTIVE busybox@.service inactive inactive - - busybox@1.service launched launched ffc81480.../10.xxx.xxx.237 active busybox@2.service launched launched 99f741a8.../10.xxx.xxx.150 active UNIT DSTATE STATE MACHINE ACTIVE busybox@.service inactive inactive - - busybox@1.service launched launched ffc81480.../10.xxx.xxx.237 active busybox@2.service launched launched 27c76d9a.../10.xxx.xxx.221 activa ting

×