《玩转Envoy+落地自研Service+Mesh》-殷湘
玩转Envoy+落地自研Service+Mesh
- 背景
- envoy工作原理
- why envoy
- 自研servicemesh
展开查看详情
1.ሻ Envoy ៧ࣈᛔᎸ ServiceMesh ྨე რ ṛᕆຝӫਹ
2.ྨე ṛᕆຝӫਹ © syswin.com, Inc. property • 2018.01 - present რ ኼፓຽғ᭜“ฬ్ᐒտ“ଘݣኞா ࠟӱᇙᜋғBᒒᑏۖᘶᗑᶾضմӱ • 2017.04 - 2018.01 ԅ మғӞӻ App App Ձಅํ๐(ۓᘶള) • Apache ServiceComb committer ᭗ҁtoon҂ݻ๚
3.• ᙧว • ೪ғEnvoy ૡ֢ܻቘ • ჿғWhy Envoy? • ғᛔᎸServiceMesh
4. ๐ۓ۸ଃጱ ړ- ๐ᦇᦡۓӨೆړ ᓕ - ग़๐ۓᬩᖌᓕቘ ഴ - ӧᑞਧጱᗑᕶ • ᮱ᗟ܋ᕆ • ፊഴ̵᧣አ᱾᭄᪵ • ๐ݎۓሿ • ๐ۓᘠݳଶ • ᅍଶݎ • ๐ۓ᪠ኧ • ӱ॔ۓଶ • ᗑى • ᬴᩻᯿ᦶ • ӱۓຝӨᔮᕹຝᕹӞ • ෭ப • හഝӞᛘ • ۖாᯈᗝ
5. ᧘ग़ᳯ᷌Өᗑᕶፘى ړ- ๐ᦇᦡۓӨೆړ ᓕ - ग़๐ۓᬩᖌᓕቘ ഴ - ӧᑞਧጱᗑᕶ • ᮱ᗟ܋ᕆ • ፊഴ̵᧣አ᱾᭄᪵ • ๐ݎۓሿ • ๐ۓᘠݳଶ • ᅍଶݎ • ๐ۓ᪠ኧ • ӱ॔ۓଶ • ᗑى • ᬴᩻᯿ᦶ • ӱۓຝӨᔮᕹຝᕹӞ • ෭ப • හഝӞᛘ • ۖாᯈᗝ
6. ቘమጱᥴ٬ොໜ ق ฃ ଠ ᥴ٬ಅํӨᗑᕶፘىጱ ᜓӱࢫۓᴚᵞ౮౮ ඪ೮ग़ ๐ۓလቘᳯ᷌ • ፊഴ • ද (๋অӧද) ሿํդᎱ • ๐ݎۓሿ • Java • Go • ᧣አ᱾᭄᪵ • ܋ᕆӱߥۓੜ (෫ߥ) • ๐ۓ᪠ኧ • C++ • Python • ᅍଶݎ • ԟ̵ᵞ౮ᳪད֗ • ᬴᩻᯿ᦶ • C# • Nodejs • ᗑى • ݢൊ
7.᩻૱ጱᭆᨵᳯ᷌ ? ᛔୌ vs դቘ
8. ᛔୌ ᭆᨵӱۓ౮ԅݪلጱӞ᮱ړ
9. դቘ ݝݪلӫဳ᩻૱ӱۓ
10. ই ӱࢫۓᴚ = ᩻૱ᬩ០ ᭆᨵᳯ᷌ = ๐ۓလቘ
11. SDKཛྷୗғᛔୌ • զSDKጱ୵ୗ્کف๐ۓᬰᑕӾ Pod A Pod B SDK౮ԅಅํӱࢫۓᴚጱᳯ᷌ SDK SDK Socket Socket TCP/IP TCP/IP Ethernet Ethernet eth0 eth0 Network
12. ๐ۓᗑ໒ғդቘ - ӱۓ෫ఽᎣ Pod A Pod B Service Service Mesh Mesh Socket Socket Socket Socket Socket Socket TCP/IP TCP/IP TCP/IP TCP/IP TCP/IP TCP/IP Iptables Iptables Iptables Iptables Ethernet Ethernet Ethernet Ethernet Ethernet Ethernet Loopback eth0 Network eth0 Loopback ๐ۓᗑ໒ኧӫᳪದࢫᴚᨮᨱ҅ӱࢫۓᴚݝӫဳӱۓ https://github.com/istio/istio/wiki/Proxy-redirection
13. ቘమጱᥴ٬ොໜ ق ฃ ଠ ᥴ٬ಅํӨᗑᕶፘىጱ ᜓӱࢫۓᴚᵞ౮౮ ඪ೮ग़ ๐ۓလቘᳯ᷌ • ፊഴ • ද (๋অӧද) ሿํդᎱ • ๐ݎۓሿ • Java • Go • ᧣አ᱾᭄᪵ • ܋ᕆӱߥۓੜ (෫ߥ) • ๐ۓ᪠ኧ • C++ • Python • ᅍଶݎ • ԟ̵ᵞ౮ᳪད֗ • ᬴᩻᯿ᦶ • C# • Nodejs • ᗑى • ݢൊ
14. ServiceMesh = ഴګᶎ + හഝᶎ ᓕቘդቘᥢڞ ᵞӾᓕഴෆӻᔮᕹᗑᕶ դቘ᧗හഝ ஙᥡ ਡᥡ http://philcalcado.com/2017/08/03/pattern_service_mesh.html
15. ๐ۓᗑ໒ጱᄍᬰ ഴګᶎ + හഝᶎ ഴګᶎ + හഝᶎ හഝᶎ හഝᶎ හഝᶎ Istio 2016.01 2016.09 2017.05 2017.09 2017.12 Buoyant Lyft Google/IBM/Lyft Nginx Buoyant ૪ࠟአ ૪ࠟአ ࠟݢአጱഴګᶎপপ᬴
16.• ᙧว • ೪ғEnvoyૡ֢ܻቘ • Why Envoy • ᛔᎸServiceMesh
17. Envoy 7 application HTTP ๐ݎۓሿ ؋଼༄ັ 6 presentation ᨮ࣐ᤍ ᗑᕶፊഴ 5 session ᴴၞ ᧣አ᱾᭄᪵ 4 transport TCP 3 network IP ᆤෙ ၞᰁ॔ګ 2 data-link ᯿ᦶ ᅾ᯿ސ 1 physical ᩻ ۖா᪠ኧ ๐ۓᗑى/๐ۓդቘ L3/4/7 proxy ๐ۓလቘۑᚆ ඪ೮SSL HTTP2.0
18. Envoy ໐ஞ༷ஷ cluster • Clusterғᵞᗭ endpoint endpoint endpoint • EndpointғᵞᗭӾጱᜓᅩ • Listenerғᒒݗ • RouteConfigurationғ᪠ኧᥢڞ Envoy Envoy Envoy cluster listener Envoy Envoy Envoy Envoy route config endpoint endpoint endpoint Font Awesome by Dave Gandy - https://fortawesome.github.com/Font-Awesome
19. Envoy ۖாᯈᗝ Pod A • xDS: x discovery service Envoy • CDS: Clusters DS • EDS: Endpoints DS xDS HTTP2.0 cache grpc • LDS: Listeners DS ྍӥݎ • RDS: RouteConfigurations DS Envoy Pod B • ADS = LDS + LDS + CDS + EDS ਫሿഴګᶎ = ਫሿxDSᯈᗝӥݎ
20. CDSғᵞᗭ௳מ • Local cluster • in.9080 • Remote clusters reviews ratings details • reviews CDS [node.id: 10.244.1.22…] Envoy • ratings Pod CDS • [review, ratings, details] • details in.9080 [ in.9080 -> 127.0.0.1:9080, reviews -> eds, ratings -> eds, details -> eds]
21. CDSᐏֺғᆤෙ Envoy HTTP2.0 max_requests CDS "name": “reviews", "circuit_breakers": { Envoy Envoy Envoy "default": { "max_connections": 1024, "max_pending_requests": 1024, "max_requests": 1024, "max_retries": 3 } } Envoy type: EDS queue: max_pending_requests eds_cluster_config { HTTP1.1 eds_config { ads { } Envoy Envoy Envoy } max_connections service_name: “reviews" }
22. EDSғᵞᗭᜓᅩ௳מ ratings details CDS CDS • [ratings, reviews, details] reviews clusters: [ratings, reviews, details] EDS Envoy EDS[ratings, reviews, details] • ratings: [10.244.1.21:1234], • reviews: [ 10.244.2.22:9080, Pod endpoints: { 10.244.2.89:9080 ratings: […], ], reviews: […], • details: [10.244.1.23:5678], details: […] }
23. EDSᐏֺғᅍଶݎ cluster_name: "reviews" endpoints { ᨮྲֺᦇᓒ (ইӧᘍᡤAZ) lb_endpoints { v1 lb% = weight_v1 / (weight_v1 + weight_v2) endpoint { address { v2 lb% = weight_v2 / (weight_v1 + weight_v2) socket_address { address: "10.244.1.21" port_value: 9080 http://reviews:9080/ } } } 1% 99% load_balancing_weight { value: 1 } } lb_endpoints { v2 v1 endpoint { address { Envoy Envoy … } } cluster: reviews load_balancing_weight { value: 99 } }
24. LDS :1234 :5678 request • gate listener http://reviews:9080/ ratings details (http://10.244.1.22:9080) • 0.0.0.0:15001 gate LDS [node.id: 10.244.1.22…] 0.0.0.0:15001 • ingress listeners Ingress Egress 10.244.1.22:9080 0.0.0.0:1234 0.0.0.0:5678 listeners: [ • pod_ip:endpoint_port 0.0.0.0:1234 -> rds, in.9080 10.244.1.22:9080 -> in.9080, • egress listeners 0.0.0.0:5678 -> rds] request LDS • 0.0.0.0:endpoint_port http://ratings:1234/ • 0.0.0.0:1234 -> rds • 0.0.0.0:5678 -> rds in.9080 reviews 10.244.1.22:9080
25. RDSғ᪠ኧᥢڞ ratings details LDS gate ۖா᪠ኧ? listeners[…] LDS 0.0.0.0:15001 • 0.0.0.0:9080 -> 9080 • … Ingress Egress 10.244.1.22:9080 0.0.0.0:9080 RDS RDS[9080] • { 9080: [{ domain: ratings:9080, routes: {9080: […]} cluster: ratings request }, { http://ratings:9080/ domain: details:9080, cluster: details }], … } reviews
26. RDSᐏֺғ໑ഝአಁݷ᪠ኧ • አಁ = ݷJason -> reviews v2 name: 9080 virtual_hosts { cluster: reviews|v1 name: "reviews" domains: "reviews:9080" routes { match { v1 prefix: "/" headers { Envoy name: "cookie" value: "^(.*?;)?(user=jason)(;.*)?$" regex { cluster: reviews|v2 value: true } } } v2 route { cluster: "reviews|v2" Envoy } …
27. ೪ғ᧗᪠ኧၞᑕ details Envoy 10.244.1.21:9080 10.244.1.21:9080 details:9080 details 10.244.1.22:9080 10.244.1.22:9080 http://ratings:9080 ratings 9080 ऒݷ 10.244.1.10:9080 10.244.1.10:9080 15001 ᒒݗ 10.244.1.11:9080 ratings:9080 ratings 10.244.1.11:9080 reviews 10.244.1.31:5678 5678 reviews:5678 reviews 10.244.1.31:5678 10.244.1.32:5678 10.244.1.32:5678 listeners routes clusters endpoints ۖா᪠ኧ ᆤෙᴴၞ ᨮ࣐ᤍ ᩻᯿ᦶ
28.• ᙧว • Envoyૡ֢ܻቘ • ჿғWhy Envoy? • ᛔᎸServiceMesh
29. Envoy ਫ@( ێLyft) ᙧԡ ᖌಷᘏ • ᓕቘ >100ӻ๐ۓ Lyft • ᩼10,000ӻᡦ Google Istio ጱἕᦊහഝᶎ • ྯᑁ॒ቘ2ጯӡ᧗ Apple TurbineLabs • ૪فےCNCF