Slide 1

Slide 1 text

コンテナ移行におけるアレコレ と使えるアレコレ(仮) 2019/07/11 #ふくばねてす node-2

Slide 2

Slide 2 text

Self-introduction 杉永良太(@transnano) ヤフー株式会社 バックエンドエンジニア(SRE) 担当:On-call system, etc 環境:BareMetal, Virtual Machine, PaaS

Slide 3

Slide 3 text

日本企業のDockerコンテナ本番導入率は1割未満 日本企業の Dockerコンテナー本番導入率は 1割未満--IDC調べ - ZDNet Japan https://japan.zdnet.com/article/35139430/

Slide 4

Slide 4 text

Cloud Native Trail Map 世界中のノウハウが詰まっている! Opsメインでは従わなくても良い https://www.slideshare.net/ToruMakabe/ops-meets-noops https://github.com/cncf/trailmap

Slide 5

Slide 5 text

https://landscape.cncf.io/

Slide 6

Slide 6 text

Service Proxy / Orchestration & Management

Slide 7

Slide 7 text

What’s Envoy ● Cloud-native high-performance edge/middle/service proxy ○ Written by C++ ● Programmable L3/L4 and L7 proxy ○ OSI参照モデル ● A side-car proxy that provides the functionality you need to create microservices ○ マイクロサービスが抱える問題をサイドカーとして解決 ● Lyftによって開発された ● Cloud Native Graduated ○ 現在6つ、Kubernetes, Prometheus, Envoy, CoreDNS, containerd, Fluentd https://landscape.cncf.io/selected=envoy

Slide 8

Slide 8 text

Feature ● Dynamic Configuration ○ Service Discovery Integration ○ Routing Configuration ○ Securing with SSL ● Observability(可観測性) ○ Log Parsing ○ Metrics Aggregation ○ Change Logging ● Deployment Models ○ Front Proxy ○ Service Mesh ○ Hosted Where You Are ● Resilience(レジリエンス/弾力性) ○ Circuit Breaking ○ Automatic Retries ○ Health Checks ○ Backpressure ● etc... Envoy単体または、サイドカーとして機能を提供

Slide 9

Slide 9 text

Side-car / Standalone ex1. https://aws.amazon.com/jp/blogs/compute/setting-up-an-envoy-front-proxy-o n-amazon-ecs/ https://docs.microsoft.com/ja-jp/azure/architecture/patterns/sidecar ex2.

Slide 10

Slide 10 text

Lyft's Envoy: From Monolith to Service Mesh 2017年頃 https://www.slideshare.net/datawire/lyfts-envoy-from-monolith-to-service-mesh-matt-klein-lyft/15

Slide 11

Slide 11 text

Advantages of comparing Envoy with other systems nginx(web server) ● Full HTTP/2 transparent proxy ○ nginx only supports HTTP/2 for downstream connections. ● Freely available advanced load balancing haproxy v1(LB) ● HTTP/2 ● Integration with a remote service discovery/global rate limiting services Amazon’s ELB(SD, LB) ● Statistics and logging ● Stability ● Advanced load balancing Linkerd v1(RPC routing proxy) ● Hot reload ● HTTP/2 and gRPC ● Low resource

Slide 12

Slide 12 text

Resilience レジリエンス/弾力性

Slide 13

Slide 13 text

Circuit Breaking ● 単位時間あたりの、timeout発生回数やエラー数などが閾値を超えた場合に 後続を切り離す ● 障害の連鎖を防ぐ役目 ● 後続がhealthyになったと判定できてら、再度アクセスを元に戻す https://developers.redhat.com/blog/2017/05/31/microservices-patterns-with-envoy-sid ecar-proxy-part-i-circuit-breaking/ https://tyk.io/docs/ensure-high-availability/circuit-breakers/

Slide 14

Slide 14 text

Automatic Retries / Rate Limits Automatic Retries Rate Limits https://medium.com/dm03514-tech-blog/sre-resiliency-bolt-on-sidecar-rate-limiting-wi th-envoy-sidecar-5381bd4a1137 https://developers.redhat.com/blog/2017/06/01/microservices-pat terns-with-envoy-proxy-part-ii-timeouts-and-retries/

Slide 15

Slide 15 text

Observability 可観測性 Logs/Traces/Metrics

Slide 16

Slide 16 text

Before Logs After Tomcat 既存システムにアクセスログを追加したい場合でも、 envoyを入れてログを有効化するだけ (gRPCやhttpでもログ形式を変更可能で、   とか良しなにやればさらに便利になる) Tomcat log log Experimental: mysql

Slide 17

Slide 17 text

Traces 代表的なトレーサー ● Jaeger ● Zipkin ServiceA ServiceB ServiceC ServiceA ServiceB ServiceC 200ms 100ms 300ms サービスの関係や処理時間などがわかる Envoyを使うと、透過的なトレースが可能 https://github.com/jaegertracing/artwork https://zipkin.io/

Slide 18

Slide 18 text

Trace Detail View ● 例)Jaeger spans trace

Slide 19

Slide 19 text

Metrics ● Envoy自体にもStatistics(stats)と言う統計情報がある ○ Downstream 着信接続/要求に関するstats ○ Upstream 発信接続/要求に関するstats ○ Server Envoyサーバのstats https://prometheus.io/

Slide 20

Slide 20 text

Others

Slide 21

Slide 21 text

Security / Authentication Security ● Terminating SSL / TLS ● Forcing insecure traffic to HTTPS Authentication ● RBAC

Slide 22

Slide 22 text

Service Discovery Integration ● 設定ファイルによる静的な設定 ● xDS configuration API(RESTまたはgRPCのAPIによる設定) ○ Endpoint Discovery Service (EDS) API ○ Cluster discovery service (CDS) API ○ Route discovery service (RDS) API ○ Listener discovery service (LDS) API ○ Secret discovery service (SDS) API ● Consul: Service Discovery

Slide 23

Slide 23 text

Envoy Tips ● CentOS 6/7ではそのままだと動かない!requires glibc >= 2.18 ○ とは言っても最新の glibc_2.29とかではpythonのバージョンがあがりビルドできない ○ ビルドはめちゃくちゃ時間かかります。 (私がC経験がないので長いと思ってしまう ) ○ 2.18をリンクさせた人も 1年以上動作実績ありとのこと ○ Amazon linuxもRH系なので同じこと ● Ubuntuはそのまま動くぞ Running Envoy on CentOS 6/7 — Joey Bratton

Slide 24

Slide 24 text

Summary

Slide 25

Slide 25 text

Lyft's Envoy: From Monolith to Service Mesh 2017年頃 https://www.slideshare.net/datawire/lyfts-envoy-from-monolith-to-service-mesh-matt-klein-lyft/15

Slide 26

Slide 26 text

Summary ● マイクロサービス時に必要になる機能が揃っている ● サイドカーとして、サービス本体の改造なしに機能追加が可能 ○ VMでもBMでも使える

Slide 27

Slide 27 text

用語 1. Downstream: App⇔Envoy間通信 2. Upstream: Envoyと外の通信 3. Cluster: EnvoyがUpstreamに接続するホストグループ 4. Endpoint: Cluster内にあるメンバーの1つで、Upstreamのホスト 5. Listener: DownstreamがEnvoyに接続するための情報で、アドレス・ ポートやUNIXドメインソケットを指定 6. Route: URLやHTTPヘッダからどのClusterに接続するかの経路情報 App Envoy Service 1 2 3 4 5

Slide 28

Slide 28 text

Appendix ● Envoy (Envoy proxy)、Istio とは? - Qiita ● "Building Fault Tolerant Microservices" というプレゼンがとても良かった話 - Qiita ● Building Fault Tolerant Microservices ● Envoyでサービスメッシュを作ろう - Qiita ● EnvoyとAmazon ECS Service Discoveryを利用したgRPCの負荷分散 – PSYENCE:MEDIA ● Running Envoy on CentOS 6/7 — Joey Bratton ● How to Condemn Your Microservices Architecture to Fail Before You Even Start ● Setting Up an Envoy Front Proxy on Amazon ECS ● Microservices Patterns With Envoy Sidecar Proxy, Part I: Circuit Breaking ● Circuit Breakerの効用をEnvoy + Gatlingで検証してみた ● Envoy Proxyに入門した ● cncf/trailmap: TrailMap files from the cncf/landscape repo ● Ops meets NoOps ● DevLOVE X 20190623 B CloudNative Sue ● SRE: Resiliency: Bolt on Rate Limiting using Envoy - Dm03514 Tech Blog - Medium ● Microservices Patterns With Envoy Proxy, Part II: Timeouts and Retries - Red Hat Developer Blog