惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
C
Cybersecurity and Infrastructure Security Agency CISA
G
Google Developers Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
TaoSecurity Blog
TaoSecurity Blog
V
Visual Studio Blog
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
博客园 - Franky
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
T
Troy Hunt's Blog
B
Blog RSS Feed
A
About on SuperTechFans
IT之家
IT之家
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
J
Java Code Geeks
S
Securelist
T
Threatpost
SecWiki News
SecWiki News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Docker
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
H
Hacker News: Front Page
N
News and Events Feed by Topic
N
Netflix TechBlog - Medium
AWS News Blog
AWS News Blog
P
Privacy International News Feed
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Vulnerabilities – Threatpost
The Register - Security
The Register - Security

博客园 - YY哥

在github上写博客 从veth看虚拟网络设备的qdisc 深入学习golang(5)—接口 深入学习golang(4)—new与make 深入学习golang(3)—类型方法 深入学习golang(2)—channel 深入学习golang(1)—数组与切片 Docker实践(6)—CentOS7上部署Kubernetes CoreOS实践(2)—在coreos上安装Kubernetes Docker实践(5)—资源隔离 Docker实践(4)—network namespace与veth pair Ceph monitor故障恢复探讨 环回接口(loopback interface)的新认识 Docker实践(3)—浅析device mapper的thin provision Docker实践(2)—虚拟网络 Docker实践(1)—入门 gpg的一些常用操作 Open vSwitch实践——VLAN CentOS6.5下安装Open vSwitch
CoreOS实践(1)—CoreOS初体验
YY哥 · 2014-09-08 · via 博客园 - YY哥

CoreOS主要包含以下一些东西:

(1)最小的OS:kernel+systemd

(2)使用Docker运行应用

(3)使用fleet管理集群

(4)使用etcd实现服务发现:一个分布式的K/V存储引擎存储配置数据

下载vagrant的coreos配置文件

$ git clone https://github.com/coreos/coreos-vagrant.git

$vagrant up

$ vagrant status

Current machine states:

core-01                   running (virtualbox)

core-02                   running (virtualbox)

core-03                   running (virtualbox)

$ ssh-add ~/.vagrant.d/insecure_private_key

Identity added: /Users/yy/.vagrant.d/insecure_private_key (/Users/yy/.vagrant.d/insecure_private_key)

$ vagrant ssh core-01

Last login: Sun Sep  7 16:23:31 2014 from 10.0.2.2

CoreOS (beta)

core@core-01 ~ $ fleetctl list-machines

MACHINE           IP          METADATA

542a4130... 172.17.8.101     -

bcb90abf...  172.17.8.102     -

e6a8eaa9...  172.17.8.103     -

读写etcd

core@core-01 ~ $ etcdctl set first-etcd-key "Hello World"

Hello World

core@core-01 ~ $ etcdctl get first-etcd-key

Hello World

在core-02上可以读到first-etcd-key对应的值:

core@core-02 ~ $ etcdctl get first-etcd-key

Hello World

也可以直接提供的API读取相应的key:

core@core-02 ~ $ curl -L http://127.0.0.1:4001/v1/keys/first-etcd-key

{"action":"get","key":"/first-etcd-key","value":"Hello World","index":2264}

使用fleetctl管理服务

core@core-01 ~ $ cat hello.service

[Unit]

Description=My Service

After=docker.service

[Service]

TimeoutStartSec=0

ExecStartPre=-/usr/bin/docker kill hello

ExecStartPre=-/usr/bin/docker rm hello

ExecStartPre=/usr/bin/docker pull busybox

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

ExecStop=/usr/bin/docker stop hello

core@core-01 ~ $ fleetctl load hello.service

Job hello.service loaded on 542a4130.../172.17.8.101

core@core-01 ~ $ fleetctl start hello.service

Job hello.service launched on 542a4130.../172.17.8.101

查看服务状态

core@core-01 ~ $ fleetctl status hello.service

● hello.service - My Service

   Loaded: loaded (/run/fleet/units/hello.service; linked-runtime)

   Active: active (running) since Mon 2014-09-08 04:21:13 UTC; 1min 25s ago

  Process: 1117 ExecStartPre=/usr/bin/docker pull busybox (code=exited, status=0/SUCCESS)

  Process: 1108 ExecStartPre=/usr/bin/docker rm hello (code=exited, status=1/FAILURE)

  Process: 1046 ExecStartPre=/usr/bin/docker kill hello (code=exited, status=1/FAILURE)

 Main PID: 1185 (docker)

   CGroup: /system.slice/hello.service

           └─1185 /usr/bin/docker run --name hello busybox /bin/sh -c while true; do echo Hello World; sleep 1; done

Sep 08 04:22:28 core-01 docker[1185]: Hello World

Sep 08 04:22:29 core-01 docker[1185]: Hello World

Sep 08 04:22:30 core-01 docker[1185]: Hello World

Sep 08 04:22:31 core-01 docker[1185]: Hello World

Sep 08 04:22:32 core-01 docker[1185]: Hello World

Sep 08 04:22:33 core-01 docker[1185]: Hello World

Sep 08 04:22:34 core-01 docker[1185]: Hello World

Sep 08 04:22:35 core-01 docker[1185]: Hello World

Sep 08 04:22:36 core-01 docker[1185]: Hello World

Sep 08 04:22:37 core-01 docker[1185]: Hello World

core@core-01 ~ $ docker ps

CONTAINER ID        IMAGE                       COMMAND                CREATED             STATUS              PORTS               NAMES

fa7084105f19        busybox:buildroot-2014.02   /bin/sh -c 'while tr   2 minutes ago       Up 2 minutes                            hello

在另一个coreos查看服务状态

$ vagrant ssh core-02 -- -A

Last login: Mon Sep  8 04:35:40 2014 from 10.0.2.2

CoreOS (beta)

core@core-02 ~ $ fleetctl list-units

UNIT            DSTATE              TMACHINE                STATE          MACHINE                         ACTIVE

hello.service       launched     542a4130.../172.17.8.101    launched     542a4130.../172.17.8.101    active

core@core-02 ~ $ fleetctl status hello.service

● hello.service - My Service

   Loaded: loaded (/run/fleet/units/hello.service; linked-runtime)

   Active: active (running) since Mon 2014-09-08 04:21:13 UTC; 15min ago

  Process: 1117 ExecStartPre=/usr/bin/docker pull busybox (code=exited, status=0/SUCCESS)

  Process: 1108 ExecStartPre=/usr/bin/docker rm hello (code=exited, status=1/FAILURE)

  Process: 1046 ExecStartPre=/usr/bin/docker kill hello (code=exited, status=1/FAILURE)

 Main PID: 1185 (docker)

   CGroup: /system.slice/hello.service

           └─1185 /usr/bin/docker run --name hello busybox /bin/sh -c while true; do echo Hello World; sleep 1; done

Sep 08 04:36:20 core-01 docker[1185]: Hello World

Sep 08 04:36:21 core-01 docker[1185]: Hello World

Sep 08 04:36:22 core-01 docker[1185]: Hello World

Sep 08 04:36:23 core-01 docker[1185]: Hello World

Sep 08 04:36:24 core-01 docker[1185]: Hello World

Sep 08 04:36:25 core-01 docker[1185]: Hello World

Sep 08 04:36:26 core-01 docker[1185]: Hello World

Sep 08 04:36:27 core-01 docker[1185]: Hello World

Sep 08 04:36:28 core-01 docker[1185]: Hello World

Sep 08 04:36:29 core-01 docker[1185]: Hello World

core@core-02 ~ $ fleetctl destroy hello.service             

Destroyed hello.service

主要参考

[1] https://coreos.com/docs/quickstart/


作者:YY哥 
出处:http://www.cnblogs.com/hustcat/ 
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。