文档章节

Running CoreOS on Vagrant

longfirst
 longfirst
发布于 2015/05/25 10:25
字数 1074
阅读 103
收藏 0

Running CoreOS with Vagrant is the easiest way to bring up a single machine or virtualize an entire cluster on your laptop. Since the true power of CoreOS can be seen with a cluster, we’re going to concentrate on that. Instructions for a single machine can be found towards the end of the guide.

You can direct questions to the IRC channel or mailing list.

Install Vagrant and VirtualBox

Vagrant is a simple-to-use command line virtual machine manager. There are install packages available for Windows, Linux and OSX. Find the latest installer on the Vagrant downloads page. Be sure to get version 1.6.3 or greater.

Vagrant can use either the free VirtualBox provider or the commercial VMware provider. Instructions for both are below. For the VirtualBox provider, version 4.3.10 or greater is required.

Clone Vagrant Repo

Now that you have Vagrant installed you can bring up a CoreOS instance.

The following commands will clone a repository that contains the CoreOS Vagrantfile. This file tells Vagrant where it can find the latest disk image of CoreOS. Vagrant will download the image the first time you attempt to start the VM.

git clone https://github.com/coreos/coreos-vagrant.git
cd coreos-vagrant
Starting a Cluster

To start our cluster, we need to provide some config parameters in cloud-config format via the user-data file and set the number of machines in the cluster in config.rb.

Cloud-Config
CoreOS allows you to configure machine parameters, launch systemd units on start-up and more via cloud-config. Jump over to the docs to learn about the supported features. You can provide cloud-config data to your CoreOS Vagrant VM by editing the user-data file inside of the cloned directory. A sample file user-data.sample exists as a base and must be renamed to user-data for it to be processed.

Our cluster will use an etcd discovery URL to bootstrap the cluster of machines and elect an initial etcd leader. Be sure to replace with your own URL from https://discovery.etcd.io/new:

#cloud-config

coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new?size=3
# specify the intial size of your cluster with ?size=X
# WARNING: replace each time you ‘vagrant destroy’
discovery: https://discovery.etcd.io/
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
fleet:
public-ip: $public_ipv4
units:
– name: etcd.service
command: start
– name: fleet.service
command: start
The $private_ipv4 and $public_ipv4 substitution variables are fully supported in cloud-config on Vagrant. They will map to the first statically defined private and public networks defined in the Vagrantfile.

Your Vagrantfile should copy your cloud-config file to /var/lib/coreos-vagrant/vagrantfile-user-data. The provided Vagrantfile is already configured to do this. cloudinit reads vagrantfile-user-data on every boot and uses it to create the machine’s user-data file.

If you need to update your cloud-config later on, run vagrant reload –provision to reboot your VM and apply the new file.

Start up CoreOS
The config.rb.sample file contains a few useful settings about your Vagrant environment and most importantly, how many machines you’d like in your cluster.

CoreOS is designed to be updated automatically with different schedules per channel. Select the channel you’d like to use for this cluster below. Read the release notes for specific features and bug fixes.

Stable Channel
Beta Channel
Alpha Channel
The Stable channel should be used by production clusters. Versions of CoreOS are battle-tested within the Beta and Alpha channels before being promoted. Current version is CoreOS 633.1.0.

Rename the file to config.rb then uncomment and modify:

config.rb

# Size of the CoreOS cluster created by Vagrant
$num_instances=3
# Official CoreOS channel from which updates should be downloaded
$update_channel=’stable’
Start Machines Using Vagrant’s default VirtualBox Provider

Start the machine(s):

vagrant up
List the status of the running machines:

$ vagrant status
Current machine states:

core-01 running (virtualbox)
core-02 running (virtualbox)
core-03 running (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
Connect to one of the machines:

vagrant ssh core-01 — -A
Start Machines Using Vagrant’s VMware Provider

If you have purchased the VMware Vagrant provider, run the following commands:

vagrant up –provider vmware_fusion
vagrant ssh core-01 — -A
Single Machine

To start a single machine, we need to provide some config parameters in cloud-config format via the user-data file.

Cloud-Config
This cloud-config starts etcd and fleet when the machine is booted:

#cloud-config

coreos:
etcd:
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
fleet:
public-ip: $public_ipv4
units:
– name: etcd.service
command: start
– name: fleet.service
command: start
Start up CoreOS
The config.rb.sample file contains a few useful settings about your Vagrant environment. We’re going to set the CoreOS channel that we’d like the machine to track.

Beta Channel
Alpha Channel
The beta channel consists of promoted alpha releases. Current version is CoreOS 647.0.0.

Rename the file to config.rb then uncomment and modify:

config.rb

# Official CoreOS channel from which updates should be downloaded
$update_channel=’beta’
Start Machine Using Vagrant’s default VirtualBox Provider

Start the machine:

vagrant up
Connect to the machine:

vagrant ssh core-01 — -A
Start Machine Using Vagrant’s VMware Provider

If you have purchased the VMware Vagrant provider, run the following commands:

vagrant up –provider vmware_fusion
vagrant ssh core-01 — -A
Shared Folder Setup

Optionally, you can share a folder from your laptop into the virtual machine. This is useful for easily getting code and Dockerfiles into CoreOS.

config.vm.synced_folder “.”, “/home/core/share”, id: “core”, :nfs => true, :mount_options => [‘nolock,vers=3,udp’]
After a ‘vagrant reload’ you will be prompted for your local machine password.

New Box Versions

CoreOS is a rolling release distribution and versions that are out of date will automatically update. If you want to start from the most up to date version you will need to make sure that you have the latest box file of CoreOS. You can do this using vagrant box update – or, simply remove the old box file and Vagrant will download the latest one the next time you vagrant up.

vagrant box remove coreos-alpha vmware_fusion
vagrant box remove coreos-alpha virtualbox
If you’d like to download the box separately, you can download the URL contained in the Vagrantfile and add it manually:

vagrant box add coreos-alpha Using CoreOS

Now that you have a machine booted it is time to play around. Check out the CoreOS Quickstart guide, learn about CoreOS clustering with Vagrant, or dig into more specific topics.


© 著作权归作者所有

longfirst
粉丝 4
博文 81
码字总数 37827
作品 0
郑州
系统管理员
私信 提问
使用 Vagrant 和 Docker 在一个 VM 中进行开发

理由 1. 用Vagrant开发很酷-一个项目/组件一个VB 2. 用Vagrant开发很垃圾-缓慢的Chef/Puppet/Ansible,多个巨大的VM,遍地重复的软件。 3. Docker带来独立的仅有一个VM的VM盒子。 4. CoreOS内...

tsl0922
2014/07/07
9.4K
3
使用 Ansible 管理 CoreOS

文章作者: Roman Shtylman 这篇文章是关于使用 Ansible 管理 CoreOS 的基础技术。如果你熟悉 Ansible 和一些基本的 CoreOS知识有助于更好的理解下文 。 什么是Ansible? 引自 Ansible Docume...

oschina
2015/05/25
3.9K
2
Deis 0.9.0 发布,开源 PaaS 系统

Deis 0.9.0 发布了,Deis 是一个开源的 PaaS 系统,简化和 LXC 容器和 Chef 节点的发布和伸缩。可用于托管应用、数据库、中间件和其他服务。Deis 利用 Chef、Docker 和 Heroku Buildpacks 来...

oschina
2014/06/01
2.5K
1
CoreOS Alpha 459.0.0 发布,服务器操作系统

CoreOS Alpha 459.0.0 发布,此版本现已提供下载,更新内容如下: fleet 0.8.3 修复在 Vagrant w/ VirtualBox 配置 virtio 网络设备的问题 通过 进行按需更新触发,不再通过 CoreUpdate 服务...

oschina
2014/10/05
1K
2
CoreOS 717.0.0 发布,服务器操作系统

CoreOS 717.0.0 发布,主要更新内容如下: Fix booting CoreOS on Vagrant (https://github.com/coreos/bugs/issues/382) OpenSSL 1.0.1o Fix mounting /sysroot on bare metal Update CA c......

oschina
2015/06/23
1K
5

没有更多内容

加载失败,请刷新页面

加载更多

Qt的MVC设计模式——InterView框架(MVD)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/weixin_39743893/article/details/80625759 英雄不问,饮水...

shzwork
5分钟前
0
0
Python 开发植物大战僵尸游戏

作者:楷楷 链接:https://segmentfault.com/a/1190000019418065 开发思路 完整项目地址: https://github.com/371854496/pygame 更多好玩有趣的python,尽在公众号「Python专栏」,后台回复...

上海小胖
今天
12
0
JVM优化之逃逸分析与分配消除

要了解逃逸分析背后的基本原理,我们先来看下这段有问题的C代码——当然这个是没法用Java来写的: 这段C代码在栈上创建了一个int类型的变量,然后把它的指针作为函数的返回值返回了。这样做是...

onedotdot
今天
3
0
最简单的获取相机拍照的图片

  import android.content.Intent;import android.graphics.Bitmap;import android.os.Bundle;import android.os.Environment;import android.provider.MediaStore;import andr......

MrLins
今天
6
0
说好不哭!数据可视化深度干货,前端开发下一个涨薪点在这里~

随着互联网在各行各业的影响不断深入,数据规模越来越大,各企业也越来越重视数据的价值。作为一家专业的数据智能公司,个推从消息推送服务起家,经过多年的持续耕耘,积累沉淀了海量数据,在...

个推
今天
12
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部