diff --git a/.gitignore b/.gitignore index 54c68c85..b17ce3bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ .vagrant/ log/ -user-data -config.rb diff --git a/Vagrantfile b/Vagrantfile index a88fc51d..93c7de77 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -46,7 +46,8 @@ end Vagrant.configure("2") do |config| # always use Vagrants insecure key - config.ssh.insert_key = false + config.ssh.insert_key = true + config.ssh.forward_agent = true config.vm.box = "coreos-%s" % $update_channel if $image_version != "current" @@ -120,8 +121,9 @@ Vagrant.configure("2") do |config| vb.cpus = vm_cpus end - ip = "172.17.8.#{i+100}" + ip = "172.19.8.#{i+100}" config.vm.network :private_network, ip: ip + config.vm.network "public_network", bridge: "em1" # Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM. #config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp'] diff --git a/Vagrantfile.orig b/Vagrantfile.orig new file mode 100644 index 00000000..a88fc51d --- /dev/null +++ b/Vagrantfile.orig @@ -0,0 +1,143 @@ +# -*- mode: ruby -*- +# # vi: set ft=ruby : + +require 'fileutils' + +Vagrant.require_version ">= 1.6.0" + +CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data") +CONFIG = File.join(File.dirname(__FILE__), "config.rb") + +# Defaults for config options defined in CONFIG +$num_instances = 1 +$instance_name_prefix = "core" +$update_channel = "alpha" +$image_version = "current" +$enable_serial_logging = false +$share_home = false +$vm_gui = false +$vm_memory = 1024 +$vm_cpus = 1 +$shared_folders = {} +$forwarded_ports = {} + +# Attempt to apply the deprecated environment variable NUM_INSTANCES to +# $num_instances while allowing config.rb to override it +if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"] + $num_instances = ENV["NUM_INSTANCES"].to_i +end + +if File.exist?(CONFIG) + require CONFIG +end + +# Use old vb_xxx config variables when set +def vm_gui + $vb_gui.nil? ? $vm_gui : $vb_gui +end + +def vm_memory + $vb_memory.nil? ? $vm_memory : $vb_memory +end + +def vm_cpus + $vb_cpus.nil? ? $vm_cpus : $vb_cpus +end + +Vagrant.configure("2") do |config| + # always use Vagrants insecure key + config.ssh.insert_key = false + + config.vm.box = "coreos-%s" % $update_channel + if $image_version != "current" + config.vm.box_version = $image_version + end + config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/%s/coreos_production_vagrant.json" % [$update_channel, $image_version] + + ["vmware_fusion", "vmware_workstation"].each do |vmware| + config.vm.provider vmware do |v, override| + override.vm.box_url = "http://%s.release.core-os.net/amd64-usr/%s/coreos_production_vagrant_vmware_fusion.json" % [$update_channel, $image_version] + end + end + + config.vm.provider :virtualbox do |v| + # On VirtualBox, we don't have guest additions or a functional vboxsf + # in CoreOS, so tell Vagrant that so it can be smarter. + v.check_guest_additions = false + v.functional_vboxsf = false + end + + # plugin conflict + if Vagrant.has_plugin?("vagrant-vbguest") then + config.vbguest.auto_update = false + end + + (1..$num_instances).each do |i| + config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config| + config.vm.hostname = vm_name + + if $enable_serial_logging + logdir = File.join(File.dirname(__FILE__), "log") + FileUtils.mkdir_p(logdir) + + serialFile = File.join(logdir, "%s-serial.txt" % vm_name) + FileUtils.touch(serialFile) + + ["vmware_fusion", "vmware_workstation"].each do |vmware| + config.vm.provider vmware do |v, override| + v.vmx["serial0.present"] = "TRUE" + v.vmx["serial0.fileType"] = "file" + v.vmx["serial0.fileName"] = serialFile + v.vmx["serial0.tryNoRxLoss"] = "FALSE" + end + end + + config.vm.provider :virtualbox do |vb, override| + vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"] + vb.customize ["modifyvm", :id, "--uartmode1", serialFile] + end + end + + if $expose_docker_tcp + config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true + end + + $forwarded_ports.each do |guest, host| + config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true + end + + ["vmware_fusion", "vmware_workstation"].each do |vmware| + config.vm.provider vmware do |v| + v.gui = vm_gui + v.vmx['memsize'] = vm_memory + v.vmx['numvcpus'] = vm_cpus + end + end + + config.vm.provider :virtualbox do |vb| + vb.gui = vm_gui + vb.memory = vm_memory + vb.cpus = vm_cpus + end + + ip = "172.17.8.#{i+100}" + config.vm.network :private_network, ip: ip + + # Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM. + #config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp'] + $shared_folders.each_with_index do |(host_folder, guest_folder), index| + config.vm.synced_folder host_folder.to_s, guest_folder.to_s, id: "core-share%02d" % index, nfs: true, mount_options: ['nolock,vers=3,udp'] + end + + if $share_home + config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp'] + end + + if File.exist?(CLOUD_CONFIG_PATH) + config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data" + config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true + end + + end + end +end diff --git a/config.rb b/config.rb new file mode 100644 index 00000000..32237449 --- /dev/null +++ b/config.rb @@ -0,0 +1,92 @@ +# Size of the CoreOS cluster created by Vagrant +$num_instances=1 + +# Used to fetch a new discovery token for a cluster of size $num_instances +$new_discovery_url="https://discovery.etcd.io/new?size=#{$num_instances}" + +# To automatically replace the discovery token on 'vagrant up', uncomment +# the lines below: +# +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 + + # Fix for YAML.load() converting reboot-strategy from 'off' to `false` + if data['coreos']['update'].key? 'reboot-strategy' + if data['coreos']['update']['reboot-strategy'] == false + data['coreos']['update']['reboot-strategy'] = 'off' + end + end + + yaml = YAML.dump(data) + File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") } +end +# + +# +# coreos-vagrant is configured through a series of configuration +# options (global ruby variables) which are detailed below. To modify +# these options, first copy this file to "config.rb". Then simply +# uncomment the necessary lines, leaving the $, and replace everything +# after the equals sign.. + +# Change basename of the VM +# The default value is "core", which results in VMs named starting with +# "core-01" through to "core-${num_instances}". +#$instance_name_prefix="core" + +# Change the version of CoreOS to be installed +# To deploy a specific version, simply set $image_version accordingly. +# For example, to deploy version 709.0.0, set $image_version="709.0.0". +# The default value is "current", which points to the current version +# of the selected channel +#$image_version = "current" + +# Official CoreOS channel from which updates should be downloaded +$update_channel='stable' +#$update_channel='alpha' + +# Log the serial consoles of CoreOS VMs to log/ +# Enable by setting value to true, disable with false +# WARNING: Serial logging is known to result in extremely high CPU usage with +# VirtualBox, so should only be used in debugging situations +#$enable_serial_logging=false + +# Enable port forwarding of Docker TCP socket +# Set to the TCP port you want exposed on the *host* machine, default is 2375 +# If 2375 is used, Vagrant will auto-increment (e.g. in the case of $num_instances > 1) +# You can then use the docker tool locally by setting the following env var: +# export DOCKER_HOST='tcp://127.0.0.1:2375' +#$expose_docker_tcp=2375 + +# Enable NFS sharing of your home directory ($HOME) to CoreOS +# It will be mounted at the same path in the VM as on the host. +# Example: /Users/foobar -> /Users/foobar +#$share_home=false + +# Customize VMs +$vm_gui = false +$vm_memory = 512 +$vm_cpus = 1 + +# Share additional folders to the CoreOS VMs +# For example, +# $shared_folders = {'/path/on/host' => '/path/on/guest', '/home/foo/app' => '/app'} +# or, to map host folders to guest folders of the same name, +# $shared_folders = Hash[*['/home/foo/app1', '/home/foo/app2'].map{|d| [d, d]}.flatten] +#$shared_folders = {} +#$shared_folders = {'/Users/kcyeu/Desktop/git/coreos-vagrant' => '/home/core/vagrant'} +$shared_folders = {'/home/kcyeu/git/coreos-vagrant' => '/home/core/vagrant'} + +# Enable port forwarding from guest(s) to host machine, syntax is: { 80 => 8080 }, auto correction is enabled by default. +#$forwarded_ports = {} diff --git a/coreos-screenrc b/coreos-screenrc new file mode 100644 index 00000000..e7d76c4c --- /dev/null +++ b/coreos-screenrc @@ -0,0 +1,15 @@ +sessionname coreos +hardstatus alwayslastline '%{= bw} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})' +setenv PROMPT_COMMAND /usr/bin/true +#setenv VAGRANT_COMMAND /usr/local/bin/vagrant +screen -t bash bash + +screen -t core-01 bash +stuff "vagrant ssh core-01 " + +screen -t core-02 bash +stuff "vagrant ssh core-02 " + +screen -t core-03 bash +stuff "vagrant ssh core-03 " + diff --git a/demo-screenrc b/demo-screenrc new file mode 100644 index 00000000..cebfe023 --- /dev/null +++ b/demo-screenrc @@ -0,0 +1,15 @@ +sessionname coreos +hardstatus alwayslastline '%{= bw} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})' +setenv PROMPT_COMMAND /usr/bin/true +#setenv VAGRANT_COMMAND /usr/local/bin/vagrant +screen -t bash bash + +screen -t core-01 bash +stuff "ssh -A core@172.19.8.101 " + +screen -t core-02 bash +stuff "ssh -A core@172.19.8.102 " + +screen -t core-03 bash +stuff "ssh -A core@172.19.8.103 " + diff --git a/docker/nginx-lb/Dockerfile b/docker/nginx-lb/Dockerfile new file mode 100644 index 00000000..35aa7df4 --- /dev/null +++ b/docker/nginx-lb/Dockerfile @@ -0,0 +1,27 @@ +FROM nginx:latest +MAINTAINER Kuo-Cheng Yeu + +ENV DEBIAN_FRONTEND noninteractive + +# Silently install basic packages +RUN apt-get -qq update && apt-get -qqy install \ + nginx \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* \ +&& mkdir -p /usr/local/bin \ +&& mkdir -p /etc/confd/conf.d /etc/confd/templates \ +&& rm /etc/nginx/conf.d/default.conf + +# add confd +ADD https://github.com/kelseyhightower/confd/releases/download/v0.10.0/confd-0.10.0-linux-amd64 /usr/local/bin/confd + +# add template, config, and script +ADD assets/nginx.toml /etc/confd/conf.d/nginx.toml +ADD assets/nginx.tmpl /etc/confd/templates/nginx.tmpl +ADD assets/confd-watch /usr/local/bin/confd-watch + +RUN chmod +x /usr/local/bin/* + +CMD ["bash"] + + diff --git a/docker/nginx-lb/assets/confd-watch b/docker/nginx-lb/assets/confd-watch new file mode 100644 index 00000000..a921c456 --- /dev/null +++ b/docker/nginx-lb/assets/confd-watch @@ -0,0 +1,29 @@ +#!/bin/bash + +set -eo pipefail + +# etcd2 use IANA-assigned port 2379 and 2380, but port 4001 and 7001 are +# still available for compatibility +export ETCD_PORT=${ETCD_PORT:-4001} +export HOST_IP=${HOST_IP:-172.17.8.1} +export ETCD=$HOST_IP:$ETCD_PORT + +echo "[nginx] booting container. ETCD: $ETCD." + +# Make initial configuration every 5 seconds until successful +until confd -onetime -node $ETCD -config-file /etc/confd/conf.d/nginx.toml; do + echo "[nginx] waiting for confd to create initial nginx configuration." + sleep 5 +done + +# Polling `confd` process for changes every 10 seconds +confd -interval 10 -node $ETCD -config-file /etc/confd/conf.d/nginx.toml & +echo "[nginx] confd is now monitoring etcd for changes..." + +# Start the Nginx service using the generated config +echo "[nginx] starting nginx service..." +service nginx start + +# Follow the logs to allow the script to continue running +tail -f /var/log/nginx/*.log + diff --git a/docker/nginx-lb/assets/nginx.tmpl b/docker/nginx-lb/assets/nginx.tmpl new file mode 100644 index 00000000..c8e4f13e --- /dev/null +++ b/docker/nginx-lb/assets/nginx.tmpl @@ -0,0 +1,23 @@ +log_format upstreamlog '[$time_local] $remote_addr passed to: $upstream_addr: $request Upstream Response Time: $upstream_response_time Request time: $request_time'; + +upstream www_pool { +{{ range getvs "/services/redis-workbench/*" }} + server {{ . }}:80; +{{ end }} +} + +server { + listen 80 default_server; + listen [::]:80 default_server ipv6only=on; + + access_log /var/log/nginx/access.log upstreamlog; + + location / { + proxy_pass http://www_pool; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + diff --git a/docker/nginx-lb/assets/nginx.toml b/docker/nginx-lb/assets/nginx.toml new file mode 100644 index 00000000..6a9889bf --- /dev/null +++ b/docker/nginx-lb/assets/nginx.toml @@ -0,0 +1,21 @@ +[template] + +# The name of the template that will be used to render the application's configuration file +# Confd will look in `/etc/conf.d/templates` for these files by default +src = "nginx.tmpl" + +# The location to place the rendered configuration file +dest = "/etc/nginx/conf.d/app.conf" + +# The etcd keys or directory to watch. This is where the information to fill in +# the template will come from. +keys = [ "/services/redis-workbench" ] + +# File ownership and mode information +owner = "root" +mode = "0644" + +# These are the commands that will be used to check whether the rendered config is +# valid and to reload the actual service once the new config is in place +check_cmd = "/usr/sbin/nginx -t" +reload_cmd = "/usr/sbin/service nginx reload" diff --git a/units/instances/mysql@1.service b/units/instances/mysql@1.service new file mode 120000 index 00000000..c16067db --- /dev/null +++ b/units/instances/mysql@1.service @@ -0,0 +1 @@ +../templates/mysql@.service \ No newline at end of file diff --git a/units/instances/mysql@2.service b/units/instances/mysql@2.service new file mode 120000 index 00000000..c16067db --- /dev/null +++ b/units/instances/mysql@2.service @@ -0,0 +1 @@ +../templates/mysql@.service \ No newline at end of file diff --git a/units/instances/redis-db@1.service b/units/instances/redis-db@1.service new file mode 120000 index 00000000..4894930a --- /dev/null +++ b/units/instances/redis-db@1.service @@ -0,0 +1 @@ +../templates/redis-db@.service \ No newline at end of file diff --git a/units/instances/redis-db@2.service b/units/instances/redis-db@2.service new file mode 120000 index 00000000..4894930a --- /dev/null +++ b/units/instances/redis-db@2.service @@ -0,0 +1 @@ +../templates/redis-db@.service \ No newline at end of file diff --git a/units/instances/redis-workbench@1.service b/units/instances/redis-workbench@1.service new file mode 120000 index 00000000..bc68eddc --- /dev/null +++ b/units/instances/redis-workbench@1.service @@ -0,0 +1 @@ +../templates/redis-workbench@.service \ No newline at end of file diff --git a/units/instances/redis-workbench@2.service b/units/instances/redis-workbench@2.service new file mode 120000 index 00000000..bc68eddc --- /dev/null +++ b/units/instances/redis-workbench@2.service @@ -0,0 +1 @@ +../templates/redis-workbench@.service \ No newline at end of file diff --git a/units/instances/www-discovery@1.service b/units/instances/www-discovery@1.service new file mode 120000 index 00000000..4558ad85 --- /dev/null +++ b/units/instances/www-discovery@1.service @@ -0,0 +1 @@ +../templates/www-discovery@.service \ No newline at end of file diff --git a/units/instances/www-discovery@2.service b/units/instances/www-discovery@2.service new file mode 120000 index 00000000..4558ad85 --- /dev/null +++ b/units/instances/www-discovery@2.service @@ -0,0 +1 @@ +../templates/www-discovery@.service \ No newline at end of file diff --git a/units/single/nginx_lb.service b/units/single/nginx_lb.service new file mode 100644 index 00000000..d88387d5 --- /dev/null +++ b/units/single/nginx_lb.service @@ -0,0 +1,30 @@ +[Unit] +Description=Nginx load balancer for web server backends + +Requires=etcd2.service +Requires=docker.service + +After=etcd2.service +After=docker.service + +[Service] +TimeoutStartSec=0 +KillMode=none + +# Get CoreOS environmental variables +EnvironmentFile=/etc/environment + +# Pre-start and Start +ExecStartPre=-/usr/bin/docker kill redis-workbench-lb +ExecStartPre=-/usr/bin/docker rm redis-workbench-lb +ExecStartPre=/usr/bin/docker pull kcyeu/redis-workbench-lb +ExecStart=/usr/bin/docker run --name redis-workbench-lb \ +-p ${COREOS_PUBLIC_IPV4}:80:80 \ +-e HOST_IP=${COREOS_PRIVATE_IPV4} \ +kcyeu/redis-workbench-lb /usr/local/bin/confd-watch + +# Stop +ExecStop=/usr/bin/docker stop redis-workbench-lb + +[X-Fleet] +Conflicts=redis-workbench@*.service diff --git a/units/single/redis-db.service b/units/single/redis-db.service new file mode 100644 index 00000000..9a6491c7 --- /dev/null +++ b/units/single/redis-db.service @@ -0,0 +1,20 @@ +[Unit] +Description=Redis Database Service +Requires=docker.service + +After=docker.service + +[Service] +TimeoutStartSec=0 +KillMode=none + +ExecStartPre=-/usr/bin/docker kill redis-db +ExecStartPre=-/usr/bin/docker rm redis-db +ExecStartPre=/usr/bin/docker pull redis:latest +ExecStart=/usr/bin/docker run --name redis-db redis + +# Stop +ExecStop=/usr/bin/docker stop redis-db + +[X-Fleet] +Conflicts=redis-db.service diff --git a/units/single/redis-workbench.service b/units/single/redis-workbench.service new file mode 100644 index 00000000..c77a6410 --- /dev/null +++ b/units/single/redis-workbench.service @@ -0,0 +1,25 @@ +[Unit] +Description=Redis Workbench Service +Requires=docker.service +Requires=redis-db.service + +After=docker.service +After=redis-db.service + +[Service] +TimeoutStartSec=0 +KillMode=none + +EnvironmentFile=/etc/environment + +ExecStartPre=-/usr/bin/docker kill redis-workbench +ExecStartPre=-/usr/bin/docker rm redis-workbench +ExecStartPre=/usr/bin/docker pull kcyeu/redis-workbench:latest +ExecStart=/usr/bin/docker run --name redis-workbench -p 80:80 --link redis-db:redis kcyeu/redis-workbench + +# Stop +ExecStop=/usr/bin/docker stop redis-workbench + +[X-Fleet] +MachineOf=redis-db.service +Conflicts=redis-workbench.service diff --git a/units/templates/mysql@.service b/units/templates/mysql@.service new file mode 100644 index 00000000..fc2aad96 --- /dev/null +++ b/units/templates/mysql@.service @@ -0,0 +1,19 @@ +[Unit] +Description=MySQL Database Service +Requires=docker.service + +After=docker.service + +[Service] +TimeoutStartSec=0 +KillMode=none + +ExecStartPre=-/usr/bin/docker kill mysql.%i +ExecStartPre=-/usr/bin/docker rm mysql.%i +ExecStartPre=/usr/bin/docker pull mysql:5.5 +ExecStart=/usr/bin/docker run --name mysql.%i -e MYSQL_ROOT_PASSWORD=foobar -p 3306:3306 mysql + +ExecStop=/usr/bin/docker stop mysql.%i + +[X-Fleet] +Conflicts=mysql@*.service diff --git a/units/templates/redis-db@.service b/units/templates/redis-db@.service new file mode 100644 index 00000000..49ae9cc3 --- /dev/null +++ b/units/templates/redis-db@.service @@ -0,0 +1,19 @@ +[Unit] +Description=Redis Database Service +Requires=docker.service + +After=docker.service + +[Service] +TimeoutStartSec=0 +KillMode=none + +ExecStartPre=-/usr/bin/docker kill redis-db.%i +ExecStartPre=-/usr/bin/docker rm redis-db.%i +ExecStartPre=/usr/bin/docker pull redis:latest +ExecStart=/usr/bin/docker run --name redis-db.%i redis + +ExecStop=/usr/bin/docker stop redis-db.%i + +[X-Fleet] +Conflicts=redis-db@*.service diff --git a/units/templates/redis-workbench@.service b/units/templates/redis-workbench@.service new file mode 100644 index 00000000..7446f595 --- /dev/null +++ b/units/templates/redis-workbench@.service @@ -0,0 +1,26 @@ +[Unit] +Description=Redis Workbench Service +Requires=docker.service +Requires=redis-db@%i.service + +After=docker.service +After=redis-db@%i.service + +[Service] +TimeoutStartSec=0 +KillMode=none + +# Get CoreOS environmental variables +EnvironmentFile=/etc/environment + +ExecStartPre=-/usr/bin/docker kill redis-workbench.%i +ExecStartPre=-/usr/bin/docker rm redis-workbench.%i +ExecStartPre=/usr/bin/docker pull kcyeu/redis-workbench:latest +ExecStart=/usr/bin/docker run --name redis-workbench.%i --link redis-db.%i:redis kcyeu/redis-workbench + +# Stop +ExecStop=/usr/bin/docker stop redis-workbench.%i + +[X-Fleet] +MachineOf=redis-db@%i.service +Conflicts=redis-workbench@*.service diff --git a/units/templates/www-discovery@.service b/units/templates/www-discovery@.service new file mode 100644 index 00000000..2d96cf66 --- /dev/null +++ b/units/templates/www-discovery@.service @@ -0,0 +1,29 @@ +[Unit] +Description=Announce WWW on instance %i +BindsTo=redis-workbench@%i.service + +Requires=etcd2.service +Requires=redis-workbench@%i.service + +After=etcd2.service +After=redis-workbench@%i.service + +[Service] +TimeoutStartSec=0 + +ExecStart=/bin/bash -a -c '\ + while true; do \ + curl -f $(/usr/bin/docker inspect --format=\'{{.NetworkSettings.IPAddress}}\' redis-workbench.%i) > /dev/null 2>&1; \ + if [ $? -eq 0 ]; then \ + etcdctl set /services/redis-workbench/%i $(/usr/bin/docker inspect --format=\'{{.NetworkSettings.IPAddress}}\' redis-workbench.%i) --ttl 30; \ + else \ + etcdctl rm /services/redis-workbench/%i; \ + fi; \ + sleep 10; \ + done' + +# Stop +ExecStop=/usr/bin/etcdctl rm /services/redis-workbench/%i + +[X-Fleet] +MachineOf=redis-workbench@%i.service diff --git a/user-data b/user-data new file mode 100644 index 00000000..1974a232 --- /dev/null +++ b/user-data @@ -0,0 +1,46 @@ +#cloud-config + +--- +coreos: + etcd2: + discovery: https://discovery.etcd.io/0d54809ae62a17b2cf9163b75a7f2316 + 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 + fleet: + public-ip: $public_ipv4 + metadata: region=tw-north + flannel: + interface: $public_ipv4 + etcd_prefix: /coreos.com/network + locksmith: + endpoint: $private_ipv4:4001 + update: + reboot-strategy: 'off' + units: + - name: etcd2.service + command: start + - name: fleet.service + command: start + - name: flanneld.service + drop-ins: + - name: 50-network-config.conf + content: | + [Service] + ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }' + command: start + - name: docker-tcp.socket + command: start + enable: true + content: | + [Unit] + Description=Docker Socket for the API + + [Socket] + ListenStream=2375 + Service=docker.service + BindIPv6Only=both + + [Install] + WantedBy=sockets.target diff --git a/user-data.coreos b/user-data.coreos new file mode 100644 index 00000000..0a09888f --- /dev/null +++ b/user-data.coreos @@ -0,0 +1,48 @@ +#cloud-config + +--- +coreos: + etcd2: + discovery: https://discovery.etcd.io/536ce895ede896ac6c73522bcfde48f5 + 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 + fleet: + public-ip: $public_ipv4 + metadata: region=tw-north + flannel: + interface: $public_ipv4 + etcd_prefix: /coreos.com/network + locksmith: + endpoint: $private_ipv4:4001 + update: + reboot-strategy: 'off' + units: + - name: etcd2.service + command: start + - name: fleet.service + command: start + - name: flanneld.service + drop-ins: + - name: 50-network-config.conf + content: | + [Service] + ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }' + command: start + - name: docker-tcp.socket + command: start + enable: true + content: | + [Unit] + Description=Docker Socket for the API + + [Socket] + ListenStream=2375 + Service=docker.service + BindIPv6Only=both + + [Install] + WantedBy=sockets.target +ssh_authorized_keys: +- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5JbddijN84NT3xe2PAVKNGrsn4Amijd4pDIha3C2jhMbVkkHYRhRfguXqUP0uMrhw0EHjaBMkCm3tCfO5np60ntoyuY+JeR+DJ+QD6w3qSEIPREEZ3Fio9oQ1gL5tvcBiY0eDtggI7v4qTSQkLtfGnHHZdkxtt5jSS3GmOPAe5/5KvY0CnIh3bhoIGbagsWutW7gqtar4wyqsBqy6JysUKGAh4QHiUWD40pW2yUThJR/19sPktNtZi2bc2cc9vh2Ec31HrZRdyeK+Dz4b6H68T95MR5OfrU04oYYVjU9cJBOZ/Yhpq+UY1sA7FhrLSYLkV0PirPiVX36ACM8qZN8R