[O’Reilly Media / Infinite Skills] Introduction to CoreOS Training Video [2015, ENG] : Deploying A DatabaseBacked Web Application : Deploying RethinkDB Database

DataBase Layer (RethinkDB) 8080 port - database admin dashboard

$ cd ~/coreos-vagrant


$ vi config.rb

Прописываем:

$forwarded_ports = {80 => 8000, 3000 => 3000, 8080 => 8080 }


$ vagrant reload


$ vagrant ssh core-01 -- -A


core-01



[Unit]
Description=Announce RethinkDB %i service

[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/sh -c "while true; do etcdctl set /services/rethinkdb/rethinkdb-%i ${COREOS_PUBLIC_IPV4} --ttl 60; sleep 45; done"
ExecStop=/usr/bin/etcdctl rm /services/rethinkdb/rethinkdb-%i

[X-Fleet]
[email protected]*.service



[Unit]
Description=RethinkDB %i service
After=docker.service
[email protected]%i.service

[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill rethinkdb-%i
ExecStartPre=-/usr/bin/docker rm rethinkdb-%i
ExecStartPre=-/usr/bin/mkdir -p /home/core/docker-volumes/rethinkdb
ExecStartPre=/usr/bin/docker pull marley/coreos-rethinkdb:latest
ExecStart=/bin/sh -c '/usr/bin/docker run --name rethinkdb-%i   \
 -p ${COREOS_PUBLIC_IPV4}:8080:8080                        \
 -p ${COREOS_PUBLIC_IPV4}:28015:28015                      \
 -p ${COREOS_PUBLIC_IPV4}:29015:29015                      \
 marley/coreos-rethinkdb:latest rethinkdb --bind all \
 --canonical-address ${COREOS_PUBLIC_IPV4}                 \
 $(/usr/bin/etcdctl ls /services/rethinkdb |               \
     xargs -I {} /usr/bin/etcdctl get {} |                 \
     sed s/^/"--join "/ | sed s/$/":29015"/ |              \
     tr "\n" " ")'

ExecStop=/usr/bin/docker stop rethinkdb-%i

[X-Fleet]
[email protected]%i.service


$ fleetctl submit *


$ fleetctl list-unit-files
UNIT				HASH	DSTATE		STATE		TARGET
[email protected]	3f7611a	inactive	inactive	-
[email protected]		5698af1	inactive	inactive	-



Несколько минут ждал, чтобы статус стал active running у всех сервисов

$ fleetctl list-units
UNIT				MACHINE				ACTIVE	SUB
[email protected]	3408f7ab.../172.17.8.103	active	running
[email protected]	b2ca4512.../172.17.8.101	active	running
[email protected]		3408f7ab.../172.17.8.103	active	running
[email protected]		b2ca4512.../172.17.8.101	active	running


$ curl 172.17.8.101:8080


// лог
$ fleetctl journal -f --lines=50 [email protected]
$ fleetctl journal -f --lines=50 [email protected]

$ fleetctl journal -f --lines=50 [email protected]
$ fleetctl journal -f --lines=50 [email protected]


http://172.17.8.101:8080/#servers
http://172.17.8.103:8080/#servers


coreos cluster