CoreOS: Control Your Fleet
Upcoming SlideShare
Loading in...5
×
 

CoreOS: Control Your Fleet

on

  • 7,826 views

A quick introduction into CoreOS.

A quick introduction into CoreOS.

Statistics

Views

Total Views
7,826
Views on SlideShare
7,586
Embed Views
240

Actions

Likes
28
Downloads
98
Comments
2

9 Embeds 240

https://twitter.com 107
http://www.geekle.id.au 75
http://forum.docker.co.kr 43
https://www.linkedin.com 4
http://localhost 3
http://s3.amazonaws.com 3
http://feedly.com 2
http://digg.com 2
https://mail.google.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

CoreOS: Control Your Fleet CoreOS: Control Your Fleet Presentation Transcript

  • CoreOS Control your fleet @geekle
  • What is CoreOS? Systemd Docker Etcd Fleet Cloudinit
  • Docker LXC made easy Public repository Easy to share WYSIWY(M)G™
  • etcd Key value store, written in go Configuration and service discovery Simple API RAFT Protocol (distributed consensus) Nice extras: ttl, locks
  • Fleet Uses systemd Extra conditionals Runs on etcd
  • Cloudinit Subset of cloud-config CoreOS specific parameters OS agnostic
  • Demo
  • Demoish
  • Fetch a discovery URL
  • $ curl https://discovery.etcd.io/new
  • $ curl https://discovery.etcd.io/new https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788
  • $ curl https://discovery.etcd.io/new https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 $ curl https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788
  • $ 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}
  • Let’s create our cloud-init
  • #cloud-config coreos: etcd: discovery: https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 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:
  • #cloud-config coreos: etcd: discovery: https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 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:
  • #cloud-config coreos: etcd: discovery: https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 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:
  • coreos: etcd: discovery: https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 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
  • etcd: discovery: https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 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: |
  • discovery: https://discovery.etcd.io/cce83b966a3947533bc9e9a00b0c8788 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"
  • 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"
  • 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"
  • 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"
  • 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"
  • 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"
  • 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"
  • Boot with your favorite Paas
  • $ 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/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
  • $ 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":"
  • Let’s login
  • $ ssh -A core@54.206.85.138
  • $ ssh -A core@54.206.85.138 ______ ____ _____ / ____/___ ________ / __ / ___/ / / / __ / ___/ _ / / / /__ / /___/ /_/ / / / __/ /_/ /___/ / ____/____/_/ ___/____//____/ core@ip-10-0-0-114 ~ $
  • $ ssh -A core@54.206.85.138 ______ ____ _____ / ____/___ ________ / __ / ___/ / / / __ / ___/ _ / / / /__ / /___/ /_/ / / / __/ /_/ /___/ / ____/____/_/ ___/____//____/ core@ip-10-0-0-114 ~ $ fleetctl list-machines
  • $ 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 ~ $
  • $ 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/"
  • $ 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/
  • Let’s login remotely
  • $ fleetctl --tunnel '54.206.85.138' list-machines
  • $ 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' 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' 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
  • $ 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 ~ $
  • Let’s create some services
  • [Unit] Description=HAProxy Service [Service] ExecStart=/usr/bin/docker run --rm --name %n -p 80:80 -p 443:443 -p 8080:8080 redguava/haproxy-etcd ExecStop=/usr/bin/docker stop %n
  • [Unit] Description=Apache Service [Service] ExecStart=/usr/bin/docker run --rm --name %n -p 80 thomaswelton/apache ExecStop=/usr/bin/docker stop %n [X-Fleet] X-Conflicts=haproxy.service
  • [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
  • Let’s add the services
  • $ 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 -
  • $ 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
  • $ 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
  • 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" }
  • 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.