docker cluster
...
...
...
- name: httpd.service
command: start
enable: true
content: |
[Unit]
Description=httpd
Requires=docker.service
After=docker.service
[Service]
ExecStart=/usr/bin/docker run -d -p 80:80 --name own-httpd httpd
[Install]
WantedBy=multi-user.target
temp
cat user-data
#cloud-config
---
coreos:
etcd:
discovery: https://discovery.etcd.io/d90bc0dcab88d7b5e5e7504ed1df1890
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
etcd2:
advertise-client-urls: http://$public_ipv4:2379
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
listen-peer-urls: http://$private_ipv4:2380,http://$private_ipv4:7001
discovery: https://discovery.etcd.io/d90bc0dcab88d7b5e5e7504ed1df1890
fleet:
public-ip: $public_ipv4
flannel:
interface: $public_ipv4
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
cat confg.rb
$num_instances=3
$new_discovery_url="https://discovery.etcd.io/new?size=#{$num_instances}"
if File.exists?('user-data') && ARGV[0].eql?('up')
require 'open-uri'
require 'yaml'
token = open($new_discovery_url).read
data = YAML.load(IO.readlines('user-data')[1..-1].join)
if data['coreos'].key? 'etcd'
data['coreos']['etcd']['discovery'] = token
end
if data['coreos'].key? 'etcd2'
data['coreos']['etcd2']['discovery'] = token
end
yaml = YAML.dump(data)
File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") }
end
$update_channel='beta'
$expose_docker_tcp=2375
# Customize VMs
$vm_gui = true
#$vm_memory = 1024
#$vm_cpus = 1