mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Initial commit
Initial commit of files to use Vagrant for building etcd 2.0 cluster
This commit is contained in:
parent
83873ef3b6
commit
85a9d5db2e
8 changed files with 154 additions and 0 deletions
17
etcd-2.0/README.md
Normal file
17
etcd-2.0/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Running an etcd 2.0 Cluster
|
||||
|
||||
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) to quickly and relatively easily spin up a cluster running etcd 2.0 (etcd 2.0.9 was the version specifically tested). The configuration was tested using Vagrant 1.7.2, VMware Fusion 6.0.5, and the Vagrant VMware plugin.
|
||||
|
||||
## Contents
|
||||
|
||||
* **README.md**: This file you're currently reading.
|
||||
|
||||
* **servers.yml**: This YAML file contains a list of VM definitions. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. You will need to edit this file to provide appropriate IP addresses and other VM configuration data (see "Instructions" below).
|
||||
|
||||
* **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file.
|
||||
|
||||
## Instructions
|
||||
|
||||
These instructions assume you've already installed VMware Fusion, Vagrant, and the Vagrant VMware plugin. Please refer to the documentation for those products for more information on installation or configuration.
|
||||
|
||||
**[NOT YET COMPLETE]**
|
||||
42
etcd-2.0/Vagrantfile
vendored
Normal file
42
etcd-2.0/Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Specify Vagrant version and Vagrant API version
|
||||
Vagrant.require_version ">= 1.6.0"
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
# Require 'yaml' module
|
||||
require 'yaml'
|
||||
|
||||
# Read YAML file with VM details (box, CPU, RAM, IP addresses)
|
||||
# Be sure to edit servers.yml to provide correct IP addresses
|
||||
servers = YAML.load_file('servers.yml')
|
||||
|
||||
# Create and configure the VMs
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
# Always use Vagrant's default insecure key
|
||||
config.ssh.insert_key = false
|
||||
|
||||
# Iterate through entries in YAML file to create VMs
|
||||
servers.each do |servers|
|
||||
config.vm.define servers["name"] do |srv|
|
||||
# Don't check for box updates
|
||||
srv.vm.box_check_update = false
|
||||
srv.vm.hostname = servers["name"]
|
||||
srv.vm.box = servers["box"]
|
||||
# Assign an additional static private network
|
||||
srv.vm.network "private_network", ip: servers["priv_ip"]
|
||||
# Specify default synced folder; requires VMware Tools
|
||||
# Note shared folders are REQUIRED for the shell provisioning to work
|
||||
srv.vm.synced_folder ".", "/vagrant"
|
||||
# Provision etcd to the VMs
|
||||
srv.vm.provision "shell", path: "provision.sh", privileged: true
|
||||
# Configure VMs with RAM and CPUs per settings in servers.yml
|
||||
srv.vm.provider :vmware_fusion do |vmw|
|
||||
vmw.vmx["memsize"] = servers["ram"]
|
||||
vmw.vmx["numvcpus"] = servers["vcpu"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
12
etcd-2.0/etcd-01.override
Normal file
12
etcd-2.0/etcd-01.override
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Override file for etcd Upstart script
|
||||
|
||||
# Environment variables
|
||||
env ETCD_INITIAL_CLUSTER="etcd-01=http://192.168.101.101:2380,etcd-02=http://192.168.101.102:2380,etcd-03=http://192.168.101.103:2380"
|
||||
env ETCD_INITIAL_CLUSTER_STATE="new"
|
||||
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
|
||||
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.101.101:2380"
|
||||
env ETCD_DATA_DIR="/var/etcd"
|
||||
env ETCD_LISTEN_PEER_URLS="http://192.168.101.101:2380"
|
||||
env ETCD_LISTEN_CLIENT_URLS="http://192.168.101.101:2379"
|
||||
env ETCD_ADVERTISE_CLIENT_URLS="http://192.168.101.101:2379"
|
||||
env ETCD_NAME="etcd-01"
|
||||
12
etcd-2.0/etcd-02.override
Normal file
12
etcd-2.0/etcd-02.override
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Override file for etcd Upstart script
|
||||
|
||||
# Environment variables
|
||||
env ETCD_INITIAL_CLUSTER="etcd-01=http://192.168.101.101:2380,etcd-02=http://192.168.101.102:2380,etcd-03=http://192.168.101.103:2380"
|
||||
env ETCD_INITIAL_CLUSTER_STATE="new"
|
||||
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
|
||||
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.101.102:2380"
|
||||
env ETCD_DATA_DIR="/var/etcd"
|
||||
env ETCD_LISTEN_PEER_URLS="http://192.168.101.102:2380"
|
||||
env ETCD_LISTEN_CLIENT_URLS="http://192.168.101.102:2379"
|
||||
env ETCD_ADVERTISE_CLIENT_URLS="http://192.168.101.102:2379"
|
||||
env ETCD_NAME="etcd-02"
|
||||
12
etcd-2.0/etcd-03.override
Normal file
12
etcd-2.0/etcd-03.override
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Override file for etcd Upstart script
|
||||
|
||||
# Environment variables
|
||||
env ETCD_INITIAL_CLUSTER="etcd-01=http://192.168.101.101:2380,etcd-02=http://192.168.101.102:2380,etcd-03=http://192.168.101.103:2380"
|
||||
env ETCD_INITIAL_CLUSTER_STATE="new"
|
||||
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
|
||||
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.101.103:2380"
|
||||
env ETCD_DATA_DIR="/var/etcd"
|
||||
env ETCD_LISTEN_PEER_URLS="http://192.168.101.103:2380"
|
||||
env ETCD_LISTEN_CLIENT_URLS="http://192.168.101.103:2379"
|
||||
env ETCD_ADVERTISE_CLIENT_URLS="http://192.168.101.103:2379"
|
||||
env ETCD_NAME="etcd-03"
|
||||
19
etcd-2.0/etcd.conf
Normal file
19
etcd-2.0/etcd.conf
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
description "etcd 2.0 distributed key-value store"
|
||||
author "Scott Lowe <scott.lowe@scottlowe.org>"
|
||||
|
||||
start on (net-device-up
|
||||
and local-filesystems
|
||||
and runlevel [2345])
|
||||
stop on runlevel [016]
|
||||
|
||||
respawn
|
||||
respawn limit 10 5
|
||||
|
||||
script
|
||||
if [ -f "/etc/default/etcd" ]; then
|
||||
. /etc/default/etcd
|
||||
fi
|
||||
|
||||
chdir /var/etcd
|
||||
exec /usr/local/bin/etcd >>/var/log/etcd.log 2>&1
|
||||
end script
|
||||
24
etcd-2.0/provision.sh
Normal file
24
etcd-2.0/provision.sh
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get etcd download
|
||||
curl -L https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.tar.gz -o etcd-v2.0.9-linux-amd64.tar.gz
|
||||
|
||||
# Expand the download
|
||||
tar xzvf etcd-v2.0.9-linux-amd64.tar.gz
|
||||
|
||||
# Move etcd and etcdctl to /usr/local/bin
|
||||
cd etcd-v2.0.9-linux-amd64
|
||||
sudo mv etcd /usr/local/bin/
|
||||
sudo mv etcdctl /usr/local/bin/
|
||||
cd ..
|
||||
|
||||
# Remove etcd download and directory
|
||||
rm etcd-v2.0.9-linux-amd64.tar.gz
|
||||
rm -rf etcd-v2.0.9-linux-amd64
|
||||
|
||||
# Create directories needed by etcd
|
||||
sudo mkdir /var/etcd
|
||||
|
||||
# Copy files into the correct locations; requires shared folders
|
||||
sudo cp /vagrant/etcd.conf /etc/init/etcd.conf
|
||||
sudo cp /vagrant/$HOSTNAME.override /etc/init/etcd.override
|
||||
16
etcd-2.0/servers.yml
Normal file
16
etcd-2.0/servers.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: etcd-01
|
||||
box: slowe/ubuntu-trusty-x64
|
||||
ram: 512
|
||||
vcpu: 1
|
||||
priv_ip: 192.168.101.101
|
||||
- name: etcd-02
|
||||
box: slowe/ubuntu-trusty-x64
|
||||
ram: 512
|
||||
vcpu: 1
|
||||
priv_ip: 192.168.101.102
|
||||
- name: etcd-03
|
||||
box: slowe/ubuntu-trusty-x64
|
||||
ram: 512
|
||||
vcpu: 1
|
||||
priv_ip: 192.168.101.103
|
||||
Loading…
Reference in a new issue