Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Consulはなめらかか?

 Consulはなめらかか?

https://ezukatechnight.doorkeeper.jp/events/44585
E-zuka tehc night #ezuka_tech_night

KONDO Uchio

May 18, 2016
Tweet

More Decks by KONDO Uchio

Other Decks in Technology

Transcript

  1. NF

  2. #!/usr/bin/env ruby require 'json' data = STDIN.read @nodes = []

    JSON.parse(data).each do |node| if node["Checks"].find {|c| c["CheckID"] == "service:nginx" && c["Status"] == "passing" } @nodes << "#{c["Node"]["Address"]}:#{c["Service"]["Port"]}" end end template = <<ERB upstream backend_apps { <% for node in @nodes %> server <%= node %>; <% end %> } server { listen 80; # .... location / { proxy_pass http://backend_apps; } } ERB require 'erb' open("/etc/nginx/dynamic.conf", "w") do |f| f.write ERB.new(template).run(binding) end
  3. ൃՐˠߋ৽ˠϦϩʔυ  গ͚ͩ͠λΠϜϥά͕͋Δͱͳ͓Α͠ #!/bin/bash set -x ( sleep $(($RANDOM %

    30)) && \ cat | jq -r .[-1].Payload | base64 -d > /var/lib/nginx_tls_session_ticket.key && \ systemctl reload nginx && echo reload OK ) || curl -d 'channel=#XXXX' -d "message=Failed reload: $(hostname)" notifier.local/notice