Más contenido relacionado La actualidad más candente (20) Similar a CoreOS: Control Your Fleet (20) CoreOS: Control Your Fleet4. etcd
Key value store, written in go
Configuration and service discovery
Simple API
RAFT Protocol (distributed consensus)
Nice extras: ttl, locks
21. addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
users:
- name: core
coreos-ssh-import-github: geekle
write_files:
- path: /etc/fleet/fleet.conf
content: |
public_ip="$private_ipv4"
metadata="elastic_ip=true,public_ip=$public_ipv4"
22. peer-addr: $private_ipv4:7001
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
users:
- name: core
coreos-ssh-import-github: geekle
write_files:
- path: /etc/fleet/fleet.conf
content: |
public_ip="$private_ipv4"
metadata="elastic_ip=true,public_ip=$public_ipv4"
23. units:
- name: etcd.service
command: start
- name: fleet.service
command: start
users:
- name: core
coreos-ssh-import-github: geekle
write_files:
- path: /etc/fleet/fleet.conf
content: |
public_ip="$private_ipv4"
metadata="elastic_ip=true,public_ip=$public_ipv4"
24. units:
- name: etcd.service
command: start
- name: fleet.service
command: start
users:
- name: core
coreos-ssh-import-github: geekle
write_files:
- path: /etc/fleet/fleet.conf
content: |
public_ip="$private_ipv4"
metadata="elastic_ip=true,public_ip=$public_ipv4"
25. units:
- name: etcd.service
command: start
- name: fleet.service
command: start
users:
- name: core
coreos-ssh-import-github: geekle
write_files:
- path: /etc/fleet/fleet.conf
content: |
public_ip="$private_ipv4"
metadata="elastic_ip=true,public_ip=$public_ipv4"
26. units:
- name: etcd.service
command: start
- name: fleet.service
command: start
users:
- name: core
coreos-ssh-import-github: geekle
write_files:
- path: /etc/fleet/fleet.conf
content: |
public_ip="$private_ipv4"
metadata="elastic_ip=true,public_ip=$public_ipv4"
30. $ curl https://discovery.etcd.io/new
https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788
$ curl https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788
{"action":"get","node":{"key":"
/_etcd/registry/cce83b966a3947533bc9e9a00b0c8788","dir":true,"
modifiedIndex":5285489,"createdIndex":5285489}
$ curl https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788
{"action":"get","node":{"key":"
/_etcd/registry/cce83b966a3947533bc9e9a00b0c8788","dir":true,"nodes":
[{"key":"
/_etcd/registry/cce83b966a3947533bc9e9a00b0c8788/24bb98332c044a1287e937c216
f5d27a","value":"http://10.0.1.50:7001","expiration":"2014-04-14T11:40:
57.102816593Z","ttl":604576,"modifiedIndex":5288689,"createdIndex":
5288689},{"key":"
/_etcd/registry/cce83b966a3947533bc9e9a00b0c8788/cf321c2c8dbc46d99236fd4a28
84e353","value":"http://10.0.0.114:7001","expiration":"2014-04-14T11:44:
07.598817138Z","ttl":604766,"modifiedIndex":5289124,"createdIndex":
5289124},{"key":"
33. $ ssh -A core@54.206.85.138
______ ____ _____
/ ____/___ ________ / __ / ___/
/ / / __ / ___/ _ / / / /__
/ /___/ /_/ / / / __/ /_/ /___/ /
____/____/_/ ___/____//____/
core@ip-10-0-0-114 ~ $
34. $ ssh -A core@54.206.85.138
______ ____ _____
/ ____/___ ________ / __ / ___/
/ / / __ / ___/ _ / / / /__
/ /___/ /_/ / / / __/ /_/ /___/ /
____/____/_/ ___/____//____/
core@ip-10-0-0-114 ~ $ fleetctl list-machines
35. $ ssh -A core@54.206.85.138
______ ____ _____
/ ____/___ ________ / __ / ___/
/ / / __ / ___/ _ / / / /__
/ /___/ /_/ / / / __/ /_/ /___/ /
____/____/_/ ___/____//____/
core@ip-10-0-0-114 ~ $ fleetctl list-machines
MACHINE IP METADATA
12206e61... 10.0.1.50 elastic_ip=false
bd57c96a... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
37e5ec47... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
core@ip-10-0-0-114 ~ $
36. $ ssh -A core@54.206.85.138
______ ____ _____
/ ____/___ ________ / __ / ___/
/ / / __ / ___/ _ / / / /__
/ /___/ /_/ / / / __/ /_/ /___/ /
____/____/_/ ___/____//____/
core@ip-10-0-0-114 ~ $ fleetctl list-machines
MACHINE IP METADATA
12206e61... 10.0.1.50 elastic_ip=false
bd57c96a... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
37e5ec47... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
core@ip-10-0-0-114 ~ $ echo "o/"
37. $ ssh -A core@54.206.85.138
______ ____ _____
/ ____/___ ________ / __ / ___/
/ / / __ / ___/ _ / / / /__
/ /___/ /_/ / / / __/ /_/ /___/ /
____/____/_/ ___/____//____/
core@ip-10-0-0-114 ~ $ fleetctl list-machines
MACHINE IP METADATA
12206e61... 10.0.1.50 elastic_ip=false
bd57c96a... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
37e5ec47... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
core@ip-10-0-0-114 ~ $ echo "o/"
o/
40. $ fleetctl --tunnel '54.206.85.138' list-machines
MACHINE IP METADATA
f7898d12... 10.0.1.50 elastic_ip=false
ca1355b0... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
40e69aa8... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
41. $ fleetctl --tunnel '54.206.85.138' list-machines
MACHINE IP METADATA
f7898d12... 10.0.1.50 elastic_ip=false
ca1355b0... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
40e69aa8... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
42. $ fleetctl --tunnel '54.206.85.138' list-machines
MACHINE IP METADATA
f7898d12... 10.0.1.50 elastic_ip=false
ca1355b0... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
40e69aa8... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
$ fleetctl --tunnel '54.206.85.138' ssh f7898d12
43. $ fleetctl --tunnel '54.206.85.138' list-machines
MACHINE IP METADATA
f7898d12... 10.0.1.50 elastic_ip=false
ca1355b0... 10.0.0.231 elastic_ip=true, public_ip=54.206.52.131
40e69aa8... 10.0.0.114 elastic_ip=true, public_ip=54.206.85.138
$ fleetctl --tunnel '54.206.85.138' ssh f7898d12
______ ____ _____
/ ____/___ ________ / __ / ___/
/ / / __ / ___/ _ / / / /__
/ /___/ /_/ / / / __/ /_/ /___/ /
____/____/_/ ___/____//____/
core@ip-10-0-1-50 ~ $
47. [Unit]
Description=Apache Announce
BindsTo=apache.service
[Service]
ExecStart=/bin/bash -c "HOST_IP=$(/bin/ifconfig eth0 | awk '/inet /{print
$2}') && CONTAINER_PORT=$(docker inspect apache.service | grep -m 1
HostPort | tr -d ' ' | cut -d: -f2 | tr -d '"') && while true; do etcdctl
set /services/web/%H "{ "host": "$HOST_IP", "port":
"$CONTAINER_PORT" }" --ttl 60;sleep 45;done"
ExecStop=/usr/bin/etcdctl rm /services/web/%H
[X-Fleet]
X-ConditionMachineOf=apache.service
49. $ fleetctl --tunnel '54.206.85.138' submit *.service
$ fleetctl --tunnel '54.206.85.138' list-units
UNIT LOAD ACTIVE SUB DESC MACHINE
apache-announce.service - - - Apache Announce -
apache.service - - - Apache Service -
haproxy.service - - - HAProxy Service -
50. $ fleetctl --tunnel '54.206.85.138' start --require 'elastic_ip=true'
haproxy.service
$ fleetctl --tunnel '54.206.85.138' list-units
UNIT LOAD ACTIVE SUB DESC MACHINE
apache-announce.service - - - Apache Announce -
apache.service - - - Apache Service -
haproxy.service loaded active running HAProxy Service ca1355b0...
/10.0.0.231
51. $ fleetctl --tunnel '54.206.85.138' start apache*.service
$ fleetctl --tunnel '54.206.85.138' list-units
UNIT LOAD ACTIVE SUB DESC MACHINE
apache-announce.service loaded active running Apache Announce
f7898d12.../10.0.1.50
apache.service loaded active running Apache Service f7898d12...
/10.0.1.50
haproxy.service loaded active running HAProxy Service ca1355b0...
/10.0.0.231
52. core@ip-10-0-1-50 ~ $ etcdctl ls --recursive
/services
/services/web
/services/web/ip-10-0-1-50
core@ip-10-0-1-50 ~ $ etcdctl get /services/web/ip-10-0-1-50
{ "host": "10.0.1.50", "port": "49154" }
55. Things You Should Know
- discovery.etcd.io has a 1 week TTL
- It is in alpha. Beta on the way.
- Automatic restarts after updates during the
alpha. You can disable this.