- CoreOS cluster の安定稼働
- CoreOS の知識を増やす
- 公式のドキュメントを読みつつ、ローカルに CoreOS cluster をつくり、ためす
- CoreOS の最新安定版を使う
- CoreOS 522.6.0
- etcd 0.4.6
- Vagrant
- VirtualBox
VAIO Pro 11 VJP1111 では VirtualBox で仮想マシンが動かなかった。 → BIOS で Intel (R) Virtualization Technology を Enabled にする https://github.com/coreos/coreos-vagrant/issues/63 → BIOS には F3 を押しながら電源ボタン http://okisanjp.com/archives/851
ghq get coreos/coreos-vagrant
ghq look coreos/coreos-vagrant
Vagrantfile
、 config.rb
および user-data
をつくる。
config.rb
は Vagrantfile
内で読み込まれるだけ。user-data
はいわゆる cloud-config
というもの。
[x] cloud-config に記述できる内容を調べる
etcd discovery url は config.rb
次第で自動生成できそうだが手動で生成する。以下で得られる。
curl https://discovery.etcd.io/new
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/76bbf3f58891ce88462c7f4dae8a86ae
peer-addr: $public_ipv4:7001
fleet:
public-ip: $public_ipv4
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
SSH でログイン。
vagrant up
vagrant ssh core-01
CoreOS のバージョンを確認。
core@core-01 ~ $ cat /etc/os-release
NAME=CoreOS
ID=coreos
VERSION=522.6.0
VERSION_ID=522.6.0
BUILD_ID=
PRETTY_NAME="CoreOS 522.6.0"
ANSI_COLOR="1;32"
HOME_URL="https://coreos.com/"
BUG_REPORT_URL="https://github.com/coreos/bugs/issues"
環境変数用によまれるファイルを確認。
core@core-01 ~ $ cat /etc/environment
COREOS_PUBLIC_IPV4=172.17.8.101
COREOS_PRIVATE_IPV4=172.17.8.101
core@core-01 ~ $ etcdctl --debug ls
Cluster-Peers: http://127.0.0.1:4001 http://127.0.0.1:4001 http://127.0.0.1:4001
Curl-Example: curl -X GET http://127.0.0.1:4001/v2/keys/?consistent=true&recursive=false&sorted=false
/coreos.com
ん?ダメっぽい。
vagrant destroy
2 回目。 user-data
を変更する。$public_ipv4
を $private_ipv4
に discovery url も更新。
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/89e2e9a0ca0712984caa221d584b7a93
peer-addr: $private_ipv4:7001
fleet:
public-ip: $private_ipv4
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
vagrant up
vagrant ssh core-01
core@core-01 ~ $ cat /etc/environment
COREOS_PUBLIC_IPV4=172.17.8.101
COREOS_PRIVATE_IPV4=172.17.8.101
core@core-01 ~ $ etcdctl --debug ls
Cluster-Peers: http://127.0.0.1:4001 http://127.0.0.1:4001 http://127.0.0.1:4001
Curl-Example: curl -X GET http://127.0.0.1:4001/v2/keys/?consistent=true&recursive=false&sorted=false
/coreos.com
ダメっぽい。
vagrant destroy
Vagrantfile
は以下のようになっているし、先の /etc/environment
でも大丈夫なのに、なぜに。
ip = "172.17.8.#{i+100}"
config.vm.network :private_network, ip: ip
user-data
を変更する。$private_ipv4
を $public_ipv4
に戻す。あと、cloud-config
の設定項目を確認する。
https://coreos.com/docs/cluster-management/setup/cloudinit-cloud-config/
coreos.etcd.addr
というキーがある。これが Cluster-Peers
ってやつじゃねえの。:4001
だし。
[x] etcd の設定を調べる
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
fleet:
public-ip: $public_ipv4
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
vagrant up
vagrant ssh core-01
core@core-01 ~ $ etcdctl --debug ls
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001 http://172.17.8.103:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/?consistent=true&recursive=false&sorted=false
/coreos.com
なおったっぽい。
ドキュメント見たけど、peer-addr
というキーが存在しない。バージョンが違うっぽい。最近 etcd の 2.0.0 出たはずなので、API 変わっていると予想。
https://github.com/coreos/etcd/blob/master/Documentation/configuration.md
etcd のバージョンを確認する。etcd のバージョンは 0.4.6 。
core@core-01 ~ $ etcdctl --version
etcdctl version 0.4.6
正しいバージョン (v0.4.6) のドキュメントはここ。peer-addr
がある。 option はコマンドライン引数 -xxx
は環境変数 ETCD_XXX
と同じらしい。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/configuration.md
user-data
(cloud-config
) の値は環境変数になるぽい。じゃあ、さっき指定した addr
も。
本当っぽい。
core@core-01 ~ $ systemctl cat etcd
# /usr/lib64/systemd/system/etcd.service
[Unit]
Description=etcd
[Service]
User=etcd
PermissionsStartOnly=true
Environment=ETCD_DATA_DIR=/var/lib/etcd
Environment=ETCD_NAME=%m
ExecStart=/usr/bin/etcd
Restart=always
RestartSec=10s
# /run/systemd/system/etcd.service.d/20-cloudinit.conf
[Service]
Environment="ETCD_ADDR=172.17.8.101:4001"
Environment="ETCD_DISCOVERY=https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58"
Environment="ETCD_PEER_ADDR=172.17.8.101:7001"
ここまでを改めて確認。課題も一旦まとめる。
config.rb
は $num_instances=3
だけ。あと config.rb.sample
のまま。
$new_discovery_url='https://discovery.etcd.io/new'
# To automatically replace the discovery token on 'vagrant up', uncomment
# the lines below:
#
#if File.exists?('user-data') && ARGV[0].eql?('up')
# require 'open-uri'
# require 'yaml'
#
# token = open($new_discovery_url).read
#
# data = YAML.load(IO.readlines('user-data')[1..-1].join)
# data['coreos']['etcd']['discovery'] = token
#
# yaml = YAML.dump(data)
# File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") }
#end
#
#
# coreos-vagrant is configured through a series of configuration
# options (global ruby variables) which are detailed below. To modify
# these options, first copy this file to "config.rb". Then simply
# uncomment the necessary lines, leaving the $, and replace everything
# after the equals sign..
# Size of the CoreOS cluster created by Vagrant
$num_instances=3
# Change basename of the VM
# The default value is "core", which results in VMs named starting with
# "core-01" through to "core-${num_instances}".
#$instance_name_prefix="core"
# Official CoreOS channel from which updates should be downloaded
#$update_channel='alpha'
$update_channel='stable'
# Log the serial consoles of CoreOS VMs to log/
# Enable by setting value to true, disable with false
# WARNING: Serial logging is known to result in extremely high CPU usage with
# VirtualBox, so should only be used in debugging situations
#$enable_serial_logging=false
# Enable port forwarding of Docker TCP socket
# Set to the TCP port you want exposed on the *host* machine, default is 2375
# If 2375 is used, Vagrant will auto-increment (e.g. in the case of $num_instances > 1)
# You can then use the docker tool locally by setting the following env var:
# export DOCKER_HOST='tcp://127.0.0.1:2375'
#$expose_docker_tcp=2375
# Enable NFS sharing of your home directory ($HOME) to CoreOS
# It will be mounted at the same path in the VM as on the host.
# Example: /Users/foobar -> /Users/foobar
#$share_home=false
# Customize VMs
#$vm_gui = false
#$vm_memory = 1024
#$vm_cpus = 1
user-data
(cloud-config
) は coreos.etcd.discovery
と coreos.etcd.addr
とを設定。user-data.sample
は未使用。
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
fleet:
public-ip: $public_ipv4
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
core@core-01 ~ $ cat /etc/os-release
NAME=CoreOS
ID=coreos
VERSION=522.6.0
VERSION_ID=522.6.0
BUILD_ID=
PRETTY_NAME="CoreOS 522.6.0"
ANSI_COLOR="1;32"
HOME_URL="https://coreos.com/"
BUG_REPORT_URL="https://github.com/coreos/bugs/issues"
core@core-01 ~ $ cat /etc/environment
COREOS_PUBLIC_IPV4=172.17.8.101
COREOS_PRIVATE_IPV4=172.17.8.101
core@core-01 ~ $ etcdctl --version
etcdctl version 0.4.6
core@core-01 ~ $ systemctl cat etcd
# /usr/lib64/systemd/system/etcd.service
[Unit]
Description=etcd
[Service]
User=etcd
PermissionsStartOnly=true
Environment=ETCD_DATA_DIR=/var/lib/etcd
Environment=ETCD_NAME=%m
ExecStart=/usr/bin/etcd
Restart=always
RestartSec=10s
# /run/systemd/system/etcd.service.d/20-cloudinit.conf
[Service]
Environment="ETCD_ADDR=172.17.8.101:4001"
Environment="ETCD_DISCOVERY=https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58"
Environment="ETCD_PEER_ADDR=172.17.8.101:7001"
core@core-01 ~ $ etcdctl --debug ls
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001 http://172.17.8.103:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/?consistent=true&recursive=false&sorted=false
/coreos.com
[x] cloud-config に記述できる内容を調べる
[x] etcd の設定を調べる
[x] etcd の addr
(:4001
) と peer-addr
(:7001
) との違いを調べる
addr は client communication 、 peer-addr は server communication 。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/configuration.md
うーん。よく分からないな。
API のドキュメント。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/api.md
これも v2.0.0 と v0.4.6 で変わってるみたい。そのうちに stable も 2.0.0 にあがるんだろうな。
http://jedipunkz.github.io/blog/2013/12/09/coreos-etcd-cluster/
あんまり関係なかった。
etcdctl --debug ls
の結果から考えるに、etcdctl
は client communication
を使う、つまり addr
(:4001
) を使う、ってことかな。
キーの追加や削除や取得などは client (etcdctl
, addr
, :4001
) でできるけど、machine の追加とかは server (peer-addr
, :7001
) でないとできないってことかな。etcdctl --debug
の cluster-peers
ってのが client になっているのが謎い。
core@core-01 ~ $ etcdctl --debug ls
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.103:4001 http://172.17.8.102:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/?consistent=true&recursive=false&sorted=false
/coreos.com
極端な話 etcdctl
は curl
の etcd
向けの wrapper ってとこかな。
中途半端に情報に触れすぎていて、わけがわからないので、最初から読むことにした。流し読みで。
https://github.com/coreos/etcd/tree/v0.4.6
まず README
の時点で etcdctl
のかわりに curl
使ってもいいよ、って書いてある。なるほど。
API。さっき読んだので流し読み。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/api.md
consistent=true
で現在の master というか、leader のノードから値を読める。なるほど。
確かに consistent=true
がついている。
core@core-01 ~ $ etcdctl --debug ls
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001 http://172.17.8.103:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/?consistent=true&recursive=false&sorted=false
/coreos.com
leader を確認できる。leader / followers が分かる。peers の誰が leader かを知りたいとき、かな。
core@core-01 ~ $ curl http://127.0.0.1:4001/v2/stats/leader
{"leader":"23f0bf4ff9314646bddb7a5e46099c33","followers":{"84a46eee491d4556b9a9a7d2022d1d9c":{"latency":{"current":0.931149,"average":1.484046963485261,"standardDeviation":1.1799944061613936,"minimum":0.345372,"maximum":123.196008},"counts":{"fail":0,"success":93387}},"be25f877510442e18080e02bc51bd47d":{"latency":{"current":0.787287,"average":1.451885673503857,"standardDeviation":1.1766207222338632,"minimum":0.349836,"maximum":91.823544},"counts":{"fail":0,"success":92923}}}}
leader の stats を確認できる。
core@core-01 ~ $ curl http://127.0.0.1:4001/v2/stats/self
{"name":"23f0bf4ff9314646bddb7a5e46099c33","state":"leader","startTime":"2015-01-31T03:30:06.102392727Z","leaderInfo":{"leader":"23f0bf4ff9314646bddb7a5e46099c33","uptime":"1h19m42.227757761s","startTime":"2015-01-31T03:30:30.722816822Z"},"recvAppendRequestCnt":0,"sendAppendRequestCnt":190825,"sendPkgRate":40.37580214714636,"sendBandwidthRate":2422.1443708073098}
store の stats を確認できる。
core@core-01 ~ $ curl http://127.0.0.1:4001/v2/stats/store
{"getsSuccess":29067,"getsFail":10646,"setsSuccess":2,"setsFail":0,"deleteSuccess":0,"deleteFail":0,"updateSuccess":963,"updateFail":0,"createSuccess":9,"createFail":2,"compareAndSwapSuccess":2422,"compareAndSwapFail":1,"compareAndDeleteSuccess":0,"compareAndDeleteFail":0,"expireCount":0,"watchers":6}
ここまでが client (:4001
) 側の API 。残りは server (:7001
) 。
core@core-01 ~ $ curl -L http://127.0.0.1:7001/v2/admin/config
{"activeSize":9,"removeDelay":1800,"syncInterval":5}
core@core-01 ~ $ curl -L http://127.0.0.1:7001/v2/admin/machines
[{"name":"23f0bf4ff9314646bddb7a5e46099c33","state":"leader","clientURL":"http://172.17.8.101:4001","peerURL":"http://172.17.8.101:7001"},{"name":"84a46eee491d4556b9a9a7d2022d1d9c","state":"follower","clientURL":"http://172.17.8.102:4001","peerURL":"http://172.17.8.102:7001"},{"name":"be25f877510442e18080e02bc51bd47d","state":"follower","clientURL":"http://172.17.8.103:4001","peerURL":"http://172.17.8.103:7001"}]
activeSize
と machines
の数が一致しないんだけど……。
[x] activeSize と machines の不一致の理由を調べる。→ activeSize は最大数っぽい
READMEに書かれた順番で読む。次は clustering (set up a multi-machine cluster) .
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/clustering.md
peers をとれる。 JSON じゃない……。あと client (:4001) だ。
curl -L http://127.0.0.1:4001/v2/machines
こっちは JSON 。ただのキー。隠しキーかな。
curl -L http://127.0.0.1:4001/v2/keys/_etcd/machines
leader をとれる。 JSON じゃない。あと client (:4001) 。
curl -L http://127.0.0.1:4001/v2/leader
あんまり大した情報がないな……。再接続されますよ、とか書いてあるけど、本当かなあ。
次は configuration (Learn the config format, env variables and flags.)
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/configuration.md
OK 。-cluster-active-size などの cluster 設定についての説明がすこしだけ詳しい。
次は library-and-tools (Find language bindings and tools.).
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/libraries-and-tools.md
スクリプトなどから操作するときは要るかも。ただ、 curl やらで十分なので、シェルスクリプトになるかも。
これ deprecated らしいので。読まない。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/modules.md
TLS まわり。いまは読まなくて良いかも。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/security.md
Tuning (Tune etcd.)。ざっと見たけど、現状ではそこまで気にしてないので読まない。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/tuning.md
Upgrade (Upgrade from old version).
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/upgrade.md
etcd-dump でバックアップとれるっぽい。tools のところにも書いてあったけど。
curl http://127.0.0.1:4001/version
でバージョン確認。ふむ。
https://github.com/coreos/etcd/tree/v0.4.6/Documentation
- api
- clustring
- configuration
- library-and-tools
- modules
- security
- tuning
- upgrade
- clients-matrix → client の補足情報。機能をどこまでサポートしているか。
- cluster-discovery → もうちょっと詳しく読む
- debugging → ログの詳細化や profiling など。
- development-tools → 情報なし。
vagrant up
で簡単に起動できるよ、ってそれだけ。 - discovery-protocol → もうちょっと詳しく読む
- errorcode → エラーの一覧
- etcd-file-system → etcd の file system 的な構造。シンプルに使う分には dir と file だけ分かっていれば十分な気がする。
- internal-protocol-versioning → バージョンアップがかかる際にバージョン混在すると大変で、どうしましょう、という話。そこまでの実装は理解しなくていいので飛ばす。
- optimal-cluster-size → もうちょっと詳しく読む
- production-ready → いくつかの製品で使われているけど、まだ開発中だし、使うの難しいよ。この警告は 1.0 で削除するよ。
README にないもの (1)
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/cluster-discovery.md
https://discovery.etcd.io/ を使った peer-addr の共有について。discovery protocol は cluster が他の peer を探すのを助ける。 実装については design/cluster-finding.md (割愛)を参照。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/design/cluster-finding.md → 簡単なフローが載っている。どうやって cluster が、を手軽に知るには良さそう。
cluster の availability のためには少なくとも 3 node は必要。clusteer の availability については optimal-cluster-size.md を参照(後述)。
https://discovery.etcd.io/new でトークンを作れる。
discovery flag つきで etcd を起動する。これは etcd ドキュメント読み始める前に試していた cloud-config
でも指定済み。
自分で discovery endpoint を立てることもできる。詳細は discovery-protocol.md を参照(後述)。
AWS などの region をまたぐ場合は peer-addr で相互に通信できるように設定しておくことが必要。
discovery api は古い peer を TTL にしたがって消す。クラスタに接続するためには、少なくとも一台は valid な peer が必要。
discovery url を再利用するのはやめなさい。ふむ。
README にないもの (2)
discovery api の protocol の説明かな。discovery api といってもただの etcd の特定パス (/v2/keys/_etcd/registry
)を使っているだけのものっぽい。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/discovery-protocol.md
README にないもの (3)
activeSize を設定すると、raft consensus algorithm で active な peer の数を設定できる。active じゃない分は standby になる。このアルゴリズムは 3 - 9 で効率よく動くので、デフォルトで activeSize は 9 になっている。
障害耐性について書いてある。 奇数台のときに failure tolerance が向上するので、 1, 3, 5, 7, 9 台で cluster を組むのが良さそう。
https://github.com/coreos/etcd/blob/v0.4.6/Documentation/optimal-cluster-size.md
- 整理 (1) までには vagrant + virtualbox で CoreOS の cluster を組んだ
- 整理 (2) までには etcd 0.4.6 のドキュメントにひと通り目を通した
etcd の各種 API については、あとは使いながら……といったところ。
[ ] cloud-config に記述できる内容を調べる
curl
による API 呼び出しを etcdctl
に置き換えてみる。
/v2/keys/
やパラメーターを省略した形で呼び出せる模様。
core@core-01 ~ $ curl http://172.17.8.101:4001/v2/keys/coreos.com
{"action":"get","node":{"key":"/coreos.com","dir":true,"nodes":[{"key":"/coreos.com/updateengine","dir":true,"modifiedIndex":7,"createdIndex":7}],"modifiedIndex":7,"createdIndex":7}}
core@core-01 ~ $ etcdctl --debug ls /coreos.com
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.103:4001 http://172.17.8.102:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/coreos.com?consistent=true&recursive=false&sorted=false
/coreos.com/updateengine
また、いくつか特殊なキーがある模様。 ...:7001/v2/admin/XXX
は ...:4001/v2/keys/_etcd/XXX
に対応する。書き込みなどに対応しているかは不明。
参考
- https://www.digitalocean.com/community/tutorials/how-to-use-etcdctl-and-etcd-coreos-s-distributed-key-value-store
- https://github.com/coreos/etcd/blob/v0.4.6/Documentation/api.md
core@core-01 ~ $ curl http://172.17.8.101:7001/v2/admin/config
{"activeSize":9,"removeDelay":1800,"syncInterval":5}
core@core-01 ~ $ curl http://172.17.8.101:4001/v2/keys/_etcd/config
{"action":"get","node":{"key":"/_etcd/config","value":"{\"activeSize\":9,\"removeDelay\":1800,\"syncInterval\":5}","modifiedIndex":2,"createdIndex":2}}
core@core-01 ~ $ etcdctl --debug get /_etcd/config
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.103:4001 http://172.17.8.102:4001
Curl-Example: curl -X GET http://172.17.8.102:4001/v2/keys/_etcd/config?recursive=false&sorted=false
{"activeSize":9,"removeDelay":1800,"syncInterval":5}
core@core-01 ~ $ curl http://172.17.8.101:7001/v2/admin/machines
[{"name":"23f0bf4ff9314646bddb7a5e46099c33","state":"leader","clientURL":"http://172.17.8.101:4001","peerURL":"http://172.17.8.101:7001"},{"name":"84a46eee491d4556b9a9a7d2022d1d9c","state":"follower","clientURL":"http://172.17.8.102:4001","peerURL":"http://172.17.8.102:7001"},{"name":"be25f877510442e18080e02bc51bd47d","state":"follower","clientURL":"http://172.17.8.103:4001","peerURL":"http://172.17.8.103:7001"}]
core@core-01 ~ $ curl http://172.17.8.101:4001/v2/keys/_etcd/machines
{"action":"get","node":{"key":"/_etcd/machines","dir":true,"nodes":[{"key":"/_etcd/machines/23f0bf4ff9314646bddb7a5e46099c33","value":"etcd=http%3A%2F%2F172.17.8.101%3A4001\u0026raft=http%3A%2F%2F172.17.8.101%3A7001","modifiedIndex":1,"createdIndex":1},{"key":"/_etcd/machines/84a46eee491d4556b9a9a7d2022d1d9c","value":"etcd=http%3A%2F%2F172.17.8.102%3A4001\u0026raft=http%3A%2F%2F172.17.8.102%3A7001","modifiedIndex":19,"createdIndex":19},{"key":"/_etcd/machines/be25f877510442e18080e02bc51bd47d","value":"etcd=http%3A%2F%2F172.17.8.103%3A4001\u0026raft=http%3A%2F%2F172.17.8.103%3A7001","modifiedIndex":36,"createdIndex":36}],"modifiedIndex":1,"createdIndex":1}}
core@core-01 ~ $ etcdctl --debug ls /_etcd/machines
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001 http://172.17.8.103:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/_etcd/machines?consistent=true&recursive=false&sorted=false
/_etcd/machines/23f0bf4ff9314646bddb7a5e46099c33
/_etcd/machines/84a46eee491d4556b9a9a7d2022d1d9c
/_etcd/machines/be25f877510442e18080e02bc51bd47d
覚え方としては、管理情報 (:7001
) 向け API にアクセスするときは etcdctl ls /_etcd/XXX
って感じ。
core@core-01 ~ $ etcdctl --debug ls /_etcd/machines/
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001 http://172.17.8.103:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/_etcd/machines?consistent=true&recursive=false&sorted=false
/_etcd/machines/23f0bf4ff9314646bddb7a5e46099c33
/_etcd/machines/84a46eee491d4556b9a9a7d2022d1d9c
/_etcd/machines/be25f877510442e18080e02bc51bd47d
core@core-01 ~ $ etcdctl --debug rm /_etcd/machines/be25f877510442e18080e02bc51bd47d
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001 http://172.17.8.103:4001
Curl-Example: curl -X DELETE http://172.17.8.101:4001/v2/keys/_etcd/machines/be25f877510442e18080e02bc51b$47d?dir=false&recursive=false
core@core-01 ~ $ etcdctl --debug ls /_etcd/machines/
Cluster-Peers: http://172.17.8.101:4001 http://172.17.8.102:4001
Curl-Example: curl -X GET http://172.17.8.101:4001/v2/keys/_etcd/machines?consistent=true&recursive=false$sorted=false
/_etcd/machines/23f0bf4ff9314646bddb7a5e46099c33
/_etcd/machines/84a46eee491d4556b9a9a7d2022d1d9c
ちなみに discovery 側からは削除されない。
core@core-01 ~ $ curl https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58
{"action":"get","node":{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58","dir":true,"nodes":[{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58/23f0bf4ff9314646bddb7a5e46099c33","value":"http://172.17.8.101:7001","expiration":"2015-02-07T03:39:24.571608812Z","ttl":590165,"modifiedIndex":311963326,"createdIndex":311963326},{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58/84a46eee491d4556b9a9a7d2022d1d9c","value":"http://172.17.8.102:7001","expiration":"2015-02-07T07:21:49.086771424Z","ttl":603509,"modifiedIndex":312275316,"createdIndex":312275316},{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58/be25f877510442e18080e02bc51bd47d","value":"http://172.17.8.103:7001","expiration":"2015-02-07T07:12:00.692307046Z","ttl":602921,"modifiedIndex":312277168,"createdIndex":312277168}],"modifiedIndex":311958664,"createdIndex":311958664}}
必要ならそちらも削除。
core@core-01 ~ $ curl -X DELETE https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58/be25f877510442e18080e02bc51bd47d
{"action":"delete","node":{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58/be25f877510442e18080e02bc51bd47d","modifiedIndex":312294214,"createdIndex":312277168}
core@core-01 ~ $ curl https://discovery.etcd.io/efa668745b68aea6c1927f458ef6cd58
{"action":"get","node":{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58","dir":true,"nodes":[{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58/23f0bf4ff9314646bddb7a5e46099c33","value":"http://172.17.8.101:7001","expiration":"2015-02-07T03:39:24.571608812Z","ttl":590581,"modifiedIndex":311963327,"createdIndex":311963327},{"key":"/_etcd/registry/efa668745b68aea6c1927f458ef6cd58/84a46eee491d4556b9a9a7d2022d1d9c","value":"http://172.17.8.102:7001","expiration":"2015-02-07T07:21:49.086771424Z","ttl":603926,"modifiedIndex":312275317,"createdIndex":312275317}],"modifiedIndex":311958665,"createdIndex":311958665}}
https://coreos.com/docs/#distributed-configuration
etcd のドキュメントにひと通りは目を通しているので、認証まわりくらいしか見るところがない。認証まわりもたぶん重複している。
https://coreos.com/docs/distributed-configuration/customize-etcd-unit/
認証をつける話。
coreos/etcd-ca 興味ある。https://github.com/coreos/etcd-ca
https://coreos.com/docs/distributed-configuration/etcd-configuration/
coreos/etcd の documentation/configuration.md と同じ。
https://coreos.com/docs/distributed-configuration/getting-started-with-etcd/
coreos/etcd の documentation/api.md を簡素化したもの?
https://coreos.com/docs/distributed-configuration/etcd-api/
coreos/etcd の documentation/api.md と同じ。
https://coreos.com/docs/distributed-configuration/etcd-security/
認証をつける話。
etcd は大体 OK 。次は fleet 。現状の認識だと etcd を使いつつ、CoreOS クラスタの systemd を操作できるツール。
https://github.com/coreos/fleet
リポジトリによると systemd と etcd による 分散 init system 、らしい。
(続く)