CoreOS
What's CoreOS ?
Linux distribution designed to run services
at scale and high resilience.
Features
- kernel & core
- ~160MB RAM
- fast boot time
- no package manager
- read only
- docker
- etcd
- systemd
- fleet
- cloud-config
Update OS
The core filesystem is read only, how do you update CoreOS ?
- download entire image of update
- install in offline root partition
- restart on new root partition
- previous images is still available for easy rollback
Install & Update Apps
All applications run inside docker containers
- all libraries and dependencies are in the container
- no more version conflicts or side effects
- install app = run new container
- update app = update container
- fast, only a few seconds
- easy to test
- easy to rollback
etcd
distributed key value store
- master election
- distributed by raft protocol
- > 1000 writes / second
- easy listen for changes
- store configurations
- connection details
- etc.
systemd
init system for starting, stopping and managing processes
- units = lifecycle
- service = app
- target = run level
[Unit]
Description=My Advanced Service
After=etcd.service
After=docker.service
[Service]
ExecStart=/bin/bash -c '/usr/bin/docker start -a apache || /usr/bin/docker run -name apache -p 80:80 coreos/apache /usr/sbin/apache2ctl -D FOREGROUND'
ExecStartPost=/usr/bin/etcdctl set /domains/example.com/10.10.10.123:8081 running
ExecStop=/usr/bin/docker stop apache
ExecStopPost=/usr/bin/etcdctl rm /domains/example.com/10.10.10.123:8081
[Install]
WantedBy=multi-user.target
fleet
systemd for entire cluster
- deploy container on arbitrary host
- distribute services across cluster
- multiple instances of same service
- re-schedule on failure
- systemd + extra fields
subgun-http.1.service
[X-Fleet]
X-Conflicts=subgun-http.*.service
subgun-presence.1.service
[X-Fleet]
X-ConditionMachineOf=subgun-http.1.service
cloud-config
configure users, networking, etc. on startup
- makes adding hosts to the cluster easy
- configure once, use everywhere
- all hosts are identical
- easy to maintain
#cloud-config
coreos:
etcd:
name: node001
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
Summary
- next generation OS
- distributed
- easy updates
- easy to configure
Things to improve
- etcd integration
- configd
- fig