O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Automated a workflow of the release using consul

2.581 visualizações

Publicada em

http://techcircle.connpass.com/event/12860/
でconsul watch と consul-templateを使ったLoadBalancerの切替とmaintの話をしました

Publicada em: Software
  • (Unlimited)....ACCESS WEBSITE Over for All Ebooks ................ accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M }
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes ,Download or read Ebooks here ... ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M }
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui

Automated a workflow of the release using consul

  1. 1. Automated a workflow of the release using Consul @koudaiii
  2. 2. Profile • id: koudaiii • fullname: Kodai Sakabe
  3. 3. Agenda • What is Consul? • 今日のハンズオンのおさらい • Automated a workflow of the release • Maintenance • まとめ
  4. 4. Consul
  5. 5. What is Consul? • サーバとクライアントで構成され、クラスタ を形成 • DNSとHTTPを提供 • サービスの検出と設定を自動化するためのツー ル
  6. 6. What is Consul? • Service Discovery:  • Consul クライアントは、api や mysql 等の ‘service’ を提 供し、他のクライアントはこれらサービスを検出するた めに Consul を用いることが出来る。 • Health Checking: • サービスの状態(Webであれば200)やサーバーの状態 (Memoryの使用90%)をチェックすることが出来る。
  7. 7. What is Consul? • Key/Value Store: • シンプルな HTTP API で設定、フラグを取得で き、様々な目的に利用出来る • Multi Datacenter: • 複数のデータセンタにまたがって成長しても、 Consul はスケールできる。
  8. 8. 今日のおさらい
  9. 9. ハンズオンの内容 • 障害を検知(※1)して、新しくコンテナを起動(※2) ※1 consul watchコマンドにて、nginx監視に変化があった場合、スクリプトを実行 ※2 ハンズオン内容(@_BSmile_) http://qiita.com/_BSmile_/items/fa6e6c19e05fec1bb52a Consul Server WebWeb Web Consul ServerからDocker APIを使ってコンテナ起動 _人人人人人人_ > 突然の死 <  ̄Y^Y^Y^Y^Y ̄ _人人人人人人_ >  復活  <  ̄Y^Y^Y^Y^Y ̄ 検知
  10. 10. 自動復旧というアプローチ • 突然の死(Statusがpassing以外)をConsul Serverが検知 • 新しくコンテナを起動※ • 設定を変更する(htmlを変更) • consulのmemberに参加 ※ハンズオンでは処理を簡略化させるためにコンテナからホストにアクセスしてコンテナを起動
  11. 11. Automated a workflow of the release
  12. 12. LoadBalancer切替 • consul-templateとconsul watchコマンドを使 って簡単なblue-green deploymentをする Web Web LB Consul Server consul-templateで設定書き換え Consul Agent リリース後にEvent発行して切替 *Sample code https://github.com/koudaiii/switch-sample-service
  13. 13. やっていること • consul watchコマンドでconsul-templateを実行す るようにeventを登録 • consul-templateでLoadBalancerの設定を書き換え て、プロセス再起動 • リリースが終わったらconsul エージェント側で event発報
  14. 14. Event登録と発行 * set event in consul-server # /vagrant/consul watch -type=event -name=“switch-green" ./ green.service & # /vagrant/consul watch -type=event -name=“switch-blue" ./ blue.service & * switch in consul-client # /vagrant/consul event -name=“switch-green” # /vagrant/consul event -name=“switch-blue" ※-type=eventは任意で実行。-type=serviceでStatusの変更でイベント発行することも可能。
  15. 15. 中身もシンプル $ cat green.service #!/bin/sh exec /vagrant/consul-template -consul 127.0.0.1:8500 -template "/vagrant/tmpl/green.conf:/etc/nginx/conf.d/app.conf:service nginx restart" -once ※onceを付けないとDaemonで動いてしまうため $ cat tmpl/green.conf upstream app { least_conn; {{range service "green"}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1; {{else}}server 192.168.33.10:80; # force a 502{{end}} }
  16. 16. Maintenance
  17. 17. maint • Consul 0.5のmaint オプション • このServerだけおかしいとか • ちょっと調査したいから切り離したいとか • Openssl対応とかで意図的にサービス落とすとか • メンテナンスする際に役に立つ ※このコマンドでサービス自体を落とすわけではない
  18. 18. 新しくメンテナンス情報が追加 # /vagrant/consul maint -service blue -enable #Maintenance ON # curl -s http://127.0.0.1:8500/v1/health/checks/blue | jq . [ ・・・・・・ { "Node": "blue", "CheckID": "_service_maintenance:blue", "Name": "Service Maintenance Mode", "Status": "critical", "Notes": "Maintenance mode is enabled for this service, but no reason was provided. This is a default message.", "Output": "", "ServiceID": "blue", "ServiceName": "blue" } ]
  19. 19. サービスから切り離される # dig blue.service.consul 2015/03/24 11:09:28 [WARN] dns: node 'blue' failing health check '_service_maintenance:blue: Service Maintenance Mode', dropping from service 'blue' ; <<>> DiG 9.9.5-3-Ubuntu <<>> blue.service.consul ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59887 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;blue.service.consul. IN A ・・・・・・・・ # /vagrant/consul maint -service blue -disable #Maintenance OFF
  20. 20. exec • 一括でOpenssl のVersionが知りたいとか • ちょっとした調査 • リリース作業 • メンテナンスする際に役に立つ
  21. 21. execで一括コマンド実行 consul exec [ -datacenter | -node | -service | -tag ] “Your commnad” # consul exec “uname -a” メンバー全員 # consul exec -node=“node01” “uname -a” node01サーバーのみ # consul exec -service=“web” “openssl version” WebサービスにOpensslのVerisionを聞く
  22. 22. まとめ
  23. 23. まとめ • Consul watchでサービスの検知と作業の自動化 • Consul-templateで設定内容の変更、実行 • 0.5のmaintでサービスから一時的に外せる • consul exec で範囲を指定して一括コマンドの 実行
  24. 24. 思ったところ • 一度にたくさんのことをしようとすると大変 • リリース対応や障害対応のワークフローを洗 い出しが大事かも • 洗い出しからConsulの価値を当てはめると導 入しやすいかも
  25. 25. Reference • consul https://www.consul.io/ • Go http://golang.org/doc/install • consul-template • https://github.com/hashicorp/consul-template • https://github.com/hashicorp/consul-template/releases • consul watch command • http://www.consul.io/docs/commands/watch.html • consul exec http://www.consul.io/docs/commands/exec.html • 今さらジローだけど Consul 0.5 をざっくり試す • http://qiita.com/inokappa/items/e4a373a26f0ecea0dda9

×