CoreOS  Study
by @subicura

1st Docker Korea Online Meetup /  July 30, 2014


etcd
+
systemd
+
fleet
+
(docker)
+
(cloud init)
=
CoreOS

Etcd



온갖종류의 (머신 리스트, 서비스 ip/port)
Key/Value를 (디렉토리 형식)
쉽게 (커맨드툴 또는 curl)
다양한 방밥으로 (ttl/lock)
여기저기 동기화 해줌 (discovery)

동기화는 신경쓰지 말고 로컬 etcd에
자기 정보를 저장하고 다른 정보를 가져다 쓰세요

Systemd



나아진 init system
(No daemon, easy control)

Systemd가 머신 init system이라면
Fleet는 systemd를 이용한
클러스터 init system

Fleet



etcd의 강력한 key/value 저장 기능과
systemd에 custom configuration을 추가해
간단하게
High availability를
구현함

Coreos



Cloud init으로
설치전에
설정 끝

설정파일 만들고
서버만 생성하면 끝




systemD


init system
(like init.d/upstart)

no need to daemonize!
no PID!




logging
(journal)

no need to find /var/log/??




coordination
(targets)

conditional
(before, after, require, bind, ...)


for fleet
(fleet custom option)

X-Conflicts=app.*.service
한 서버엔 한 서비스만

X-ConditionMachineMetadata=region=us-east-1
meta data check

X-ConditionMachineOf=app.1.service
해당 서비스가 존재한다면

systemd demo


/etc/systemd/system/app.1.service

[Unit]
Description=My Service 1
Requires=docker.service
After=docker.service

[Service]
ExecStart=/usr/bin/docker run --name app1 busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done" 

systemd demo


/etc/systemd/system/app.1.service

[Unit]
Description=My Service 1
Requires=docker.service
After=docker.service

[Service]
ExecStart=/usr/bin/docker run --rm --name app1 busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"
ExecStop=/usr/bin/docker kill app1

add ExecStop

systemctl





systemctl status app.1.service
systemctl start app.1.service
systemctl stop app.1.service
systemctl enable app.1.service

journalctl





journalctl -u app.1.service
journalctl -f -u app.1.service

etcd





consistent, distributed
key/value store

cluster discovery




set discovery endpoint

https://discovery.etcd.io/new

command / curl


ls
set --ttl
get
rm
watch
lock

"_" prefix key

etcd demo



etcdctl ls -recursive
etcdctl set /foo/bar "Hello world"
etcdctl set /foo/bar "Bye" --ttl 60
etcdctl get /foo/bar
etcdctl watch /foo/bar
etcdctl rm /foo/bar
etcdctl rm /foo -recursive

fleet




use systemd (+extra configuration)
runs on etcd
abstraction machines
High availability

fleet demo



fleetctl list-machines
fleetctl list-units
fleetctl start my app.service
fleetctl submit app.service
fleetctl destroy app.service
fleetctl start *
fleetctl journal -f app.service
fleetctl status app.service

Deploy


https://coreos.com/docs/launching-containers/launching/fleet-example-deployment/

https://github.com/redguava/docker-haproxy-etcd

CoreOS Study

By ChungSub Kim

CoreOS Study

CoreOS 스터디 자료입니다.

  • 6,298
Loading comments...

More from ChungSub Kim