Share
Embed
Istio integrated Telepresence
Kurumi Morimoto
September 08, 2020
Transcript
68 slides
-
©2020 Wantedly, Inc. Istio integrated Telepresence Telepresence ͱ Istio Λͬͨࣗઐ༻ͷΫϥελΛ͍࣋ͬͯΔΑ͏ͳ։ൃڥͷߏங
CloudNative Days Tokyo 2020 Sep 08, 2020 - Shimpei Otsubo @potsbo, Kurumi Morimoto @morux2 -
Shimpei Otsubo @potsbo DX Squad, Wantedly, Inc. 2018 New Grads
Kubernetes Dev Tools CI / CD AuthN / Z Productivity Dvorak -
©2020 Wantedly, Inc. server.go http://localhost:8080 1 ϑΝΠϧͰ͕ͯ݁ͯ͢͠Δͱ͖։ൃ͍͢͠ มߋ͕ਖ਼͔͔ͬͨ͠ͷ ϑΟʔυόοΫ͕ૣ͍ ॻ͖͑Δ
/ ্ཱͪ͛Δ ϑΝΠϧ͕໌֬ʂ ࣗͷϥοϓτοϓ ͳͷͰ͖উखͰOK -
©2020 Wantedly, Inc. νʔϜͰͷϚΠΫϩαʔϏε։ൃʹͳΔͱ͕มΘΔ Service B Service C Service A
σϓϩΠ͕͍… Go ͷαʔϏεͳͷʹ Ruby Python Δඞཁ͕… ڞ༗ࢿݯ͖উखͰ͖ͳ͍… ࠓΫϥελͬͯฏؾ͔ͳ… -
©2020 Wantedly, Inc. 1. Fast (ϑΟʔυόοΫ͕͍) • มߋ͕ਖ਼͔͔ͬͨ͠Ͳ͏͔ͷϑΟʔυόοΫ͕͙͢ʹಘΒΕΔ 2. Dependency-Agnostic
(ࣗͷมߋʹूதͰ͖Δ) • ґଘؔΛҙࣝͤͣ, ͕ࣗมߋͨ͠αʔϏεͷΈΛ࣮ߦ͢Ε͍͍ 3. Isolated (ଞͷ։ൃऀΛؾʹͤͣ, ͖উखʹ։ൃ͍͍ͯ͠) • ଞͷ։ൃऀΛؾʹ͖ͤͣͳ࣌ʹ͖ͳΑ͏ʹ։ൃ͍͍ͯ͠ ࢲ͕ͨͪߟ͑Δཧͷ։ൃମݧ 1 ϑΝΠϧͰ݁͢Δͱ͖Կނྑ͔ͬͨͷ͔ʁ -
©2020 Wantedly, Inc. 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ • มߋͨ͠αʔϏεͱґଘ͢ΔϚΠΫϩαʔϏεDBΛશͯϩʔΧϧͰ্ཱͪ͛Δ 2. ΫϥελʹσϓϩΠ͢Δ •
ڞ༗ΫϥελͷϚΠΫϩαʔϏεΛॻ͖࣮͑ͯߦ͢Δ 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢ • ڞ༗ΫϥελͷϧʔςΟϯάΛάϩʔόϧʹมߋ͠, ϩʔΧϧʹϦΫΤετΛྲྀ͢ طଘͷ։ൃख๏ཧͷମݧͰͳ͍ͷ͔ ϚΠΫϩαʔϏε։ൃͷྺ࢙ΛৼΓฦΔ -
©2020 Wantedly, Inc. 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ ϚΠΫϩαʔϏε։ൃͷ࠷ॳͷεςοϓ Service B’ Service C
Service A @potsbo’s Laptop -
©2020 Wantedly, Inc. 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ ϚΠΫϩαʔϏε։ൃͷ࠷ॳͷεςοϓ Service B’ Service C
Service A @potsbo’s Laptop มߋ͕ਖ਼͔͔ͬͨ͠ͷ ϑΟʔυόοΫ͕ૣ͍ όάͬͯଞͷ։ൃऀ ͷ໎ʹͳΒͳ͍ -
©2020 Wantedly, Inc. 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ ϚΠΫϩαʔϏε։ൃͷ࠷ॳͷεςοϓ Service B’ Service C
Service A @potsbo’s Laptop Go ͷαʔϏεͳͷʹ Ruby Python Δඞཁ͕… ґଘπϦʔΛཧղ͢Δ ඞཁ͕͋Δ -
©2020 Wantedly, Inc. 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ ϚΠΫϩαʔϏε։ൃͷ࠷ॳͷεςοϓ Service B’ Service C
Service A @potsbo’s Laptop 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ Fast (ϑΟʔυόοΫ͕͍) • มߋ͕ਖ਼͔͔ͬͨ͠Ͳ͏͔ͷϑΟʔυόοΫ͕͙͢ʹಘΒΕΔ Dependency-Agnostic (ࣗͷมߋҎ֎ʹؾΛΔඞཁ͕͋Δ) • มߋͨ͠αʔϏεͷґଘؔΛѲ͠, ϩʔΧϧͰͯ͢ͷϓϩηεΛ্ཱͪ͛Δඞཁ͕͋Δ Isolated (ଞͷ։ൃऀΛؾʹͤͣ, ͖উख։ൃ͍͍ͯ͠) • ଞͷ։ൃऀΛؾʹ͖ͤͣͳ࣌ʹ͖ͳΑ͏ʹ։ൃ͍͍ͯ͠ ϚΠΫϩαʔϏε։ൃͷ࠷ॳͷεςοϓ -
©2020 Wantedly, Inc. 2. ΫϥελʹσϓϩΠ͢Δ ґଘؔؾʹͨ͘͠ͳ͍ʂ Service C Service A
staging cluster Service B Service B’ deploy -
©2020 Wantedly, Inc. 2. ΫϥελʹσϓϩΠ͢Δ ґଘؔؾʹͨ͘͠ͳ͍ʂ Service C Service A
staging cluster Service B Service B’ deploy ࣗͷมߋ͍ͨ͠ ϚΠΫϩαʔϏεʹूதͰ͖Δ -
©2020 Wantedly, Inc. 2. ΫϥελʹσϓϩΠ͢Δ ґଘؔؾʹͨ͘͠ͳ͍ʂ Service C Service A
staging cluster Service B Service B’ deploy ଞͷਓ͕ΫϥελͬͯΔ͔Β ࠓมߋ͕ࢼͤͳ͍ͳ… 1ߦม͚͑ͨͩͳͷʹ σϓϩΠΛͭඞཁ͕… -
©2020 Wantedly, Inc. 2. ΫϥελʹσϓϩΠ͢Δ Service C Service A staging
cluster Service B Service B’ deploy 2. ΫϥελʹσϓϩΠ͢Δ Fast (ϑΟʔυόοΫʹ͕͔͔࣌ؒΔ) • มߋ͕DockerΠϝʔδͱͯ͠Ϗϧυ͞ΕΔͷʹ͔͔ΔͷͰ, ։ൃ͕εϜʔζʹͰ͖ͳ͍ Dependency-Agnostic (ࣗͷมߋʹूதͰ͖Δ) • ґଘؔΛҙࣝͤͣ, ͕ࣗมߋͨ͠αʔϏεͷΈΛ࣮ߦ͢Ε͍͍ Isolated (ଞͷ։ൃऀʹ໎Λ͔͚Δ/ड͚Δ) • ଞͷ։ൃऀͱΫϥελͷୣ͍߹͍ʹͳΔ • ޡͬͨίʔυΛσϓϩΠͨ͠߹ʹଞͷ։ൃऀʹ໎Λ͔͚Δ/ड͚Δ ґଘؔؾʹͨ͘͠ͳ͍ʂ -
©2020 Wantedly, Inc. 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢ Service C Service A Service
B Service B’ staging cluster @potsbo’s Laptop ͏σϓϩΠΛͪͨ͘ͳ͍, มߋΛ͙͢ʹࢼ͍ͨ͠ʂ -
©2020 Wantedly, Inc. 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢ Service C Service A Service
B Service B’ staging cluster ͏σϓϩΠΛͪͨ͘ͳ͍, มߋΛ͙͢ʹࢼ͍ͨ͠ʂ @potsbo’s Laptop ॻ͖͑ΔͨͼʹΫϥελ ΛͬͯมߋΛࢼͤΔʂ -
©2020 Wantedly, Inc. 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢ @potsbo’s Laptop Service A Service
B staging cluster @morux2’s Laptop Service B’ Service C’ Service C ଞͷਓͷϦΫΤετྲྀΕ͠·͍ ໎ʹͳͬͯ͠·͏ ͏σϓϩΠΛͪͨ͘ͳ͍, มߋΛ͙͢ʹࢼ͍ͨ͠ʂ -
©2020 Wantedly, Inc. 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢ Service C Service A Service
B Service B’ staging cluster @potsbo’s Laptop ͏σϓϩΠΛͪͨ͘ͳ͍, มߋΛ͙͢ʹࢼ͍ͨ͠ʂ 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢ Fast (ϑΟʔυόοΫ͕͍) • DockerΠϝʔδΛϏϧυ͢Δख͕ؒল͚ͯ, ϑΟʔυόοΫ͕͙͢ʹಘΒΕΔ Dependency-Agnostic (ࣗͷมߋʹूதͰ͖Δ) • ґଘؔΛҙࣝͤͣ, ͕ࣗมߋͨ͠αʔϏεͷΈΛ࣮ߦ͢Ε͍͍ Isolated (ଞͷ։ൃऀʹ໎Λ͔͚Δ/ड͚Δ) • ଞͷ։ൃऀͱΫϥελͷୣ͍߹͍ʹͳΔ • ޡͬͨίʔυΛϩʔΧϧͰಈ͔ͨ͠߹ʹଞͷ։ൃऀʹ໎Λ͔͚Δ/ड͚Δ ͏σϓϩΠΛͪͨ͘ͳ͍, มߋΛ͙͢ʹࢼ͍ͨ͠ʂ -
©2020 Wantedly, Inc. Fast (ϑΟʔυόοΫ͕͍) • DockerΠϝʔδΛϏϧυ͢Δख͕ؒল͚ͯ, ϑΟʔυόοΫ͕͙͢ʹಘΒΕΔ Dependency-Agnostic (ࣗͷมߋʹूதͰ͖Δ)
• ͕ࣗมߋ͍ͨ͠෦ʹूதͰ͖Δ Isolated (ଞͷ։ൃऀΛؾʹͤͣ, ͖উख։ൃ͍͍ͯ͠) • ։ൃऀҰਓҰਓ͕ࣗઐ༻ͷΫϥελΛอ༗͍ͯ͠Δ ཧ : Telepresence͕IsolatedΛຬͨͯ͠΄͍͠ -
©2020 Wantedly, Inc. @potsbo’s Laptop Service C Service A Service
B potsbo’s staging cluster @morux2’s Laptop Service C Service A Service B morux2’s staging cluster NG : 1 ਓͣͭʹΫϥελΛ༩͑Δͷ͍ͬͨͳ͍ Service A 2 ਓͱಉ͡ͷΛ༻͍ͯ͠Δ Service B’ Service C’ -
©2020 Wantedly, Inc. άϩʔόϧʹϦΫΤετΛม͑ͣʹ, ϦΫΤετ͝ͱʹॲཧΛΓସ͑Δ @potsbo’s Laptop Service A staging
cluster @morux2’s Laptop Service B’ Service C’ Service C ࣗͷϦΫΤετ͚͕ͩϩʔΧϧʹྲྀΕͯ΄͍͠ @morux2 ࣗͷϧʔςΟϯά͚͕ͩมߋ ͞ΕΔͷͰଞਓʹ໎Λ͔͚ͳ͍ Service B -
©2020 Wantedly, Inc. ͜Ε͔ΒͷϚΠΫϩαʔϏε։ൃख๏ 1. ϩʔΧϧͰϓϩηεΛ্ཱͪ͛Δ 2. ΫϥελʹσϓϩΠ͢Δ 3. TelepresenceͰϩʔΧϧʹϦΫΤετΛྲྀ͢
4. IstioͰϦΫΤετ͝ͱʹϧʔςΟϯάΛΓସ͑Δ NEW!! -
©2020 Wantedly, Inc. 4. IstioͰϦΫΤετ͝ͱʹϧʔςΟϯάΛΓସ͑Δ IsolatedΛຬͨͨ͠ঢ়ଶͰTelepresenceΛ༻͢Δ͜ͱͰ, ཧͷ։ൃମݧʹͳΔʂ @potsbo’s Laptop Service
A Service B staging cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 -
©2020 Wantedly, Inc. @potsbo’s Laptop Service A Service B staging
cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 ࣮ͷ3εςοϓ 1 2 2 3 3 -
©2020 Wantedly, Inc. @potsbo’s Laptop Service A Service B staging
cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 ࣮ͷ3εςοϓ ᶃ ϦΫΤετͷૹ৴ऀΛϥϕϧ͚͢Δ 1 -
©2020 Wantedly, Inc. @potsbo’s Laptop Service A Service B staging
cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 ࣮ͷ3εςοϓ ᶄ ϚΠΫϩαʔϏεؒͰϦΫΤετͷૹ৴ऀใΛൖ͢Δ 2 2 -
©2020 Wantedly, Inc. @potsbo’s Laptop Service A Service B staging
cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 ࣮ͷ3εςοϓ ᶅ ૹ৴ऀใΛݟͯ, ࣗͷϦΫΤετͷΈΛϩʔΧϧʹྲྀ͢ 3 3 -
©2020 Wantedly, Inc. @potsbo’s Laptop Service A Service B staging
cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 ࣮ͷ3εςοϓ 1 2 2 3 3 ࣮ͷ3εςοϓ ᶃϦΫΤετͷૹ৴ऀΛϥϕϧ͚͢Δ ᶄϚΠΫϩαʔϏεؒͰϦΫΤετͷૹ৴ऀใΛൖ͢Δ ᶅૹ৴ऀใΛݟͯ, ࣗͷϦΫΤετͷΈΛϩʔΧϧʹྲྀ͢ -
©2020 Wantedly, Inc. @potsbo’s Laptop Service A Service B staging
cluster @morux2’s Laptop Service B’ Service C’ Service C @morux2 ࣮ͷ3εςοϓ 1 2 2 3 3 ࣮ͷ3εςοϓ ᶃૹ৴ऀใΛϦΫΤετϔομͱͯ͠༩͢Δ ᶄϚΠΫϩαʔϏεؒͰϔομΛൖ͢Δ ᶅϔομΛݟͯ, ࣗͷϦΫΤετͷΈΛϩʔΧϧʹྲྀ͢ -
©2020 Wantedly, Inc. ᶃ ҙͷΞϓϦ͔ΒಛผͳϦΫΤετϔομΛૠೖͰ͖ΔσόοάΦϓγϣϯΛ࡞ • Chrome ExtensionΛ༻͍ͯ, ϞόΠϧ /
ϒϥβ ͔Βૹ৴ऀͷϔομΛૠೖ͢Δ ᶄ αʔϏεؒͰϦΫΤετϔομΛൖ͢Δ • RubyͱGoͰϔομൖΛ࣮ݱ ᶅ ϔομͷΛݟͯ, ࣗͷϦΫΤετ͚͕ͩϩʔΧϧʹྲྀΕΔΑ͏ʹ੍ޚ͢Δ • IstioͷVirtual ServiceΛ༻͍ͯ, ϦΫΤετͷಈతͳ੍ޚΛߦ͏ ۩ମతͳ࣮ -
©2020 Wantedly, Inc. ᶃ ҙͷΞϓϦ͔ΒಛผͳϦΫΤετϔομΛૠೖͰ͖ΔσόοάΦϓγϣϯΛ࡞ • Chrome ExtensionΛ༻͍ͯ, ϞόΠϧ /
ϒϥβ ͔Βૹ৴ऀͷϔομΛૠೖ͢Δ ᶄ αʔϏεؒͰϦΫΤετϔομΛൖ͢Δ • RubyͱGoͰϔομൖΛ࣮ݱ ᶅ ϔομͷΛݟͯ, ࣗͷϦΫΤετ͚͕ͩϩʔΧϧʹྲྀΕΔΑ͏ʹ੍ޚ͢Δ • IstioͷVirtual ServiceΛ༻͍ͯ, ϦΫΤετͷಈతͳ੍ޚΛߦ͏ ۩ମతͳ࣮ -
©2020 Wantedly, Inc. webRequestBlocking permission Ͱ onBeforeSendHeaders Λࠩ͠ࠐΊ ok Chrome
Extension G Suite ͷΞΧϯτΛ͍࣋ͬͯΔਓͷΈʹ install ΛڐՄ͢Δ͜ͱ͕Ͱ͖Δ Staging ڥͷ request ʹಛผͳ header Λ͚ͭΒΕΔΑ͏ʹ͢Δ x-wantedly-sender-id: potsbo ଞͷσόοάϑϥάΛ༗ޮʹ͢ΔϘλϯͱ͔͚ͭΒΕͯศར Wantedly ʹͱͱ͋ͬͨ -
©2020 Wantedly, Inc. ᶃ ҙͷΞϓϦ͔ΒಛผͳϦΫΤετϔομΛૠೖͰ͖ΔσόοάΦϓγϣϯΛ࡞ • Chrome ExtensionΛ༻͍ͯ, ϞόΠϧ /
ϒϥβ ͔Βૹ৴ऀͷϔομΛૠೖ͢Δ ᶄ αʔϏεؒͰϦΫΤετϔομΛൖ͢Δ • RubyͱGoͰϔομൖΛ࣮ݱ ᶅ ϔομͷΛݟͯ, ࣗͷϦΫΤετ͚͕ͩϩʔΧϧʹྲྀΕΔΑ͏ʹ੍ޚ͢Δ • IstioͷVirtual ServiceΛ༻͍ͯ, ϦΫΤετͷಈతͳ੍ޚΛߦ͏ ۩ମతͳ࣮ -
©2020 Wantedly, Inc. ϦΫΤετϔομͷൖ WantedlyͷࣾϥΠϒϥϦ શϚΠΫϩαʔϏε͕͜ΕΛ͍ͬͯΔ Ruby, Golang, Node, Python
ͷ֤ݴޠ࣮͕͋Δ ֤ݴޠ࣮ʹϔομൖػߏΛՃ͍ͯͬͨ͠ servicex Log format, error collection, performance monitoring ͳͲΛ͍ͯ͠Δ servicex -
©2020 Wantedly, Inc. ϔομൖ - Ruby Rack Middleware Ͱ incoming
ͳ request ͷ header ΛಡΈऔΓ module Servicex::Context class RackMiddleware def initialize(app) @app = app end def call(env) env.each do |key, value| next unless Servicex::Context.should_propagate?(key) Servicex::Context::Store.save(key, value) end @app.call(env) ensure Servicex::Context::Store.clear! end end end ϦΫΤετฦ٫࣌ʹফ͢ Thread.current ͷ wrapper ʹΛอଘ -
©2020 Wantedly, Inc. module Servicex::Context class FaradayMiddleware < ::Faraday::Middleware def
initialize(app) @app = app end def call(env) Servicex::Context::Store.keys.each do |k| env[:request_headers][k] = Servicex::Context::Store.get(k) end @app.call(env) end end end ϔομൖ - Ruby Faraday Middleware Ͱ outgoing ͳ request ʹ header Λ༩ -
©2020 Wantedly, Inc. func ContextPropagationInterceptor() func(ctx context.Context, method string, req,
r return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.C md, _ := metadata.FromIncomingContext(ctx) for key, values := range md { if !isKeyToPropagate(key) { continue } for _, v := range values { ctx = metadata.AppendToOutgoingContext(ctx, key, v) } } return invoker(ctx, method, req, reply, cc, opts...) } } ϔομൖ - Golang Golang Ͱ gRPC Λલఏʹ͍ͯ͠ΔͷͰ ctx ʹೖ͍ͬͯΔ Outgoing ͳ request ʹ༩͢Δ͚ͩ -
©2020 Wantedly, Inc. ༨ஊ ϦΫΤετϔομͷൖ ͦͷଞͷศརͳ͍ํ υϝΠϯϩδοΫʹඥ͔ͳ͍σόοά flag ͷൖ Accept-Language
ͳͲͷϝλσʔλͷൖ ͨͩ͠ߗ͍ schema Λಋೖ͠ʹ͍͘ͷͰࣾͰ༷ܾΊΛ໖ີʹߦ͏͖ -
©2020 Wantedly, Inc. ᶃ ҙͷΞϓϦ͔ΒಛผͳϦΫΤετϔομΛૠೖͰ͖ΔσόοάΦϓγϣϯΛ࡞ • Chrome ExtensionΛ༻͍ͯ, ϞόΠϧ /
ϒϥβ ͔Βૹ৴ऀͷϔομΛૠೖ͢Δ ᶄ αʔϏεؒͰϦΫΤετϔομΛൖ͢Δ • RubyͱGoͰϔομൖΛ࣮ݱ ᶅ ϔομͷΛݟͯ, ࣗͷϦΫΤετ͚͕ͩϩʔΧϧʹྲྀΕΔΑ͏ʹ੍ޚ͢Δ • IstioͷVirtual ServiceΛ༻͍ͯ, ϦΫΤετͷಈతͳ੍ޚΛߦ͏ ۩ମతͳ࣮ -
©2020 Wantedly, Inc. Virtual ServiceServiceͷલஈͰ੍ޚΛ͢Δ ֤ServiceʹϦΫΤετ͕ಧ͘લʹ, HTTPϨΠϠʔͰͷνΣοΫΛߦ͏ custom x-wantedly-sender-id: potsbo͕ϔομʹؚ·ΕͨϦΫΤετ
default ͦΕҎ֎ͷϦΫΤετ Service A default custom Virtual Service Service B’ Virtual Service Service B -
©2020 Wantedly, Inc. ྫ @potsboͷϦΫΤετϩʔΧϧʹྲྀ͍ͨ͠ default sender-id : postbo apiVersion:
networking.istio.io/v1alpha3 kind: VirtualService spec: hosts: # Ϋϥελͷservice-bʹདྷͨϦΫΤετͷதͰ - service-b http: - match: # x-wantedly-sender-id:potsbo ͱ͍͏ϔομؚ͕·Ε͍ͯΔͷ - headers: x-wantedly-sender-id: exact: potsbo route: - destination: host: # potsboͷϥοϓτοϓʹϧʔςΟϯά͢Δ ɹɹɹɹɹɹpotsbo-laptop - route: - destination: host: ɹɹɹɹɹɹ # ͦΕҎ֎ͷϦΫΤετΫϥελͷservice-bʹૹΔ ɹɹɹɹɹɹ service-b if x-wantedly-sender-id : postbo then postbo’s laptop else Service B -
©2020 Wantedly, Inc. ྫ 2ਓ͕ಉ࣌ʹಉ͡αʔϏεΛมߋ͍ͨ͠߹ 1ͭͷVirtual Serviceʹ݅Λ·ͱΊΔ sender-id : postbo
default sender-id : morux2 apiVersion: networking.istio.io/v1alpha3 kind: VirtualService spec: hosts: - service-b http: - match: - headers: x-wantedly-sender-id: exact: potsbo route: - destination: host: ɹɹɹɹɹɹpotsbo-laptop http: - match: - headers: x-wantedly-sender-id: exact: morux2 route: - destination: host: ɹɹɹɹɹɹmorux2-laptop - route: - destination: host: ɹɹɹɹɹɹ service-b If x-wantedly-sender-id : postbo then postbo’s laptop if x-wantedly-sender-id : morux2 then morux2’s laptop else Service B -
©2020 Wantedly, Inc. ྫ 2ਓ͕ಉ࣌ʹಉ͡αʔϏεΛมߋ͍ͨ͠߹ 1ͭͷVirtual Serviceʹ݅Λ·ͱΊΔ sender-id : postbo
default sender-id : morux2 apiVersion: networking.istio.io/v1alpha3 kind: VirtualService spec: hosts: - service-b http: - match: - headers: x-wantedly-sender-id: exact: potsbo route: - destination: host: ɹɹɹɹɹɹpotsbo-laptop http: - match: - headers: x-wantedly-sender-id: exact: morux2 route: - destination: host: ɹɹɹɹɹɹmorux2-laptop - route: - destination: host: ɹɹɹɹɹɹ service-b If x-wantedly-sender-id : postbo then postbo’s laptop if x-wantedly-sender-id : morux2 then morux2’s laptop else Service B ධՁॱংΛ੍ޚͰ͖ͳ͍ͷͰ ֤ServiceʹෳͷVirtual Service͕ଘࡏ͠ͳ͍ ੍͕͋Δͱѻ͍͍͢ -
©2020 Wantedly, Inc. ΧελϜίϯτϩʔϥʔ͚͕ͩVirtual ServiceΛੜ͢Δ • ։ൃऀVirtual ServiceΛมߋ͢ΔΘΓʹϔομ݅Λίϯτϩʔϥʔʹొ͢Δ • ϔομ͕݅ొ
/ আ͞ΕΔͨͼʹΧελϜίϯτϩʔϥʔ͕Virtual ServiceΛΈཱͯ͢ Virtual ServiceΛதԝूݖతʹཧ͢Δ ։ൃऀVirtual ServiceΛฤूͤͣ, ίϯτϩʔϥʔ͕։ൃऀͷཁٻΛ·ͱΊΔ -
©2020 Wantedly, Inc. ։ൃऀϔομ݅ͷΧελϜϦιʔεΛ࡞͢Δ postbo apiVersion: vsconfig.k8s.wantedly.com/v1beta1 kind: VSConfig spec:
host: # ϧʔςΟϯάΛ੍ޚ͍ͨ͠k8sͷαʔϏε service-b service: # ϦΫΤετΛඈ͍ͨ͠ϩʔΧϧͷαʔϏε potsbo's laptop # ૹ৴ऀ͚ͩͷಛผͳϔομͷ headerName: x-wantedly-sender-id headerValue: potsbo if x-wantedly-sender-id : postbo then postbo’s laptop -
©2020 Wantedly, Inc. ΧελϜίϯτϩʔϥʔΛ༻͍ͨதԝूݖతͳཧ ϔομ͕݅CRUD͞ΕΔͨͼʹVirutal ServiceΛ 1 ͔Β࠶ੜ͢Δ Custom Controller
sender : postbo default sender : morux2 postbo default morux2 else if … then if … then else if … then if … then -
©2020 Wantedly, Inc. • ෳਓͰ 1 ͭͷϦιʔεΛ৮Βͳ͍ͷͰ, Isolated͕ຬͨ͞ΕΔ • ։ൃऀಠࣗͷϔομ݅Λ࡞͢ΔͷͰίϯϑϦΫτى͖ͳ͍
• ηϧϑώʔϦϯάͰ͖Δ • ϔομ͔݅Β 1 ํͰVirtual Serivce͕ੜ͞ΕΔͷͰ, յΕͯࣗಈͰݩʹΔ • શͯͷVirtual ServiceͰϑΥʔϚοτΛ౷Ұ͢Δ͜ͱ͕Ͱ͖Δ • ΨϕʔδίϨΫγϣϯָ͕Ͱ͋Δ • ͦΕͧΕͷϔομ໊͕݅લϝλσʔλ(ੜͳͲ)Λ࣋ͭ͜ͱ͕Ͱ͖ͯআ͕༰қͰ͋Δ ΧελϜίϯτϩʔϥʔΛ༻͍ͨதԝूݖతͳཧ ։ൃऀVirtual ServiceΛฤूͤͣ, ίϯτϩʔϥʔ͕։ൃऀͷཁٻΛ·ͱΊΔ -
©2020 Wantedly, Inc. • ෳਓ͕ಉ࣌ʹVirtual ServiceΛฤूͯ͠͠·͏ • ίϯϑϦΫτ͕ى͖ͯ, ଞͷ։ൃऀ͕ϔομ݅ΛొͰ͖ͳ͍͔͠Εͳ͍ •
ηϧϑώʔϦϯά͕Ͱ͖ͳ͍ • յΕͯ͠·ͬͨ࣌ʹ͢ͷ͕େมͰ͋Δ • શͯͷVirtual Serviceʹಉ༷ͷมߋΛՃ͍͑ͨࡍʹख͕͔͔ؒΔ • ΨϕʔδίϨΫγϣϯͷख͕͔͔ؒΔ • ΫϥελΛ༻͠ऴΘͬͨࡍʹVirtual ServiceΛݩʹ͢ͷ͕໘Ͱ͋Δ k8sͷpatchϦΫΤετΛ༻͍ͨࢄཧͩΊ͔ ӡ༻ՄೳͰ͋Δ͕͋·Γݎ࿚Ͱͳ͍, खؒଟ͔͔͘Δ -
©2020 Wantedly, Inc. ݁ہ։ൃऀମݧʁ ࣾ kubectl wrapper ͷ kube Ͱ
wrap Ͱ͖ΔΑ͏ʹ͢Δ https://speakerdeck.com/potsbo/kube-the-core-tool-at-wantedly -
©2020 Wantedly, Inc. ݁ہ։ൃऀମݧʁ kube ίϚϯυͰ؆୯ʹΫϥελΛίϐʔͰ͖Δ $ kube fork kube
ίϚϯυͰ؆୯ʹΫϥελΛίϐʔ͢Δ αʔόʔΛىಈ͢Δ $ bin/rails server Chrome ͔ΒΞΫηε Extension ͔Β sender-id Λઃఆ ͲΕ͚ͩґଘ͕͋ͬͯଞʹԿ͠ͳ͍͍ͯ͘ ͍ͭͰؾʹ͍͍ͤͣͬͯ -
©2020 Wantedly, Inc. தͰ͍ͬͯΔ͜ͱ ͦͷ Service ʹ Routing Ͱ͖Δϔομ݅ (VSConfig)
Λ࡞Δ Telepresence Λىಈ͢Δ ͦͷ Telepresence Pod ʹ Routing Ͱ͖Δ Service Λ࡞Δ ڥมΛΫϥελ͔Βμϯϩʔυ ىಈ࣌ ऴྃ࣌ Telepresence Λऴྃ ࡞ͨ͠ Service ͱ VSConfig Λআ -
©2020 Wantedly, Inc. ͱ͍࣮͑ࡍʹ… Gateway ͔ Ambassador ͷΑ͏ͳϨΠϠʔ͕ඞཁʹͳΔ ࣾͷίϯϕϯγϣϯʹै͍ͬͯͳ͍ microservice
ͷྫ֎ରԠ͕Γ͍ͯͳ͍ ඇಉظ job ͳͲͰϔομʔ్͕ΕΔࣄ͕͋Δ ΫϥελڥมΛ͏ͱRAILS_ENV Λ͏·͘Βͳ͍ͱ dev server ͕ىಈ͠ͳ͍ ࢁੵΈͳͷͰࣾάϩʔε׆ಈத Ͳͷ service ʹର͢Δ virtual service Λఆٛͨ͠ΒΑ͍͔Λ͍ͬͯΔඞཁ͕͋Δ -
©2020 Wantedly, Inc. ·ͱΊ Fast, Dependency-Agnostic, Isolated WHY Telepresence +
Istio + ϔομൖ HOW WHAT όʔνϟϧࣗઐ༻Ϋϥελͷମݧ -
©2020 Wantedly, Inc. ༨ஊ servicex, kube, istio, ϔομͳͲ طʹଞͷ՝ʹೖ͍ͯͨͨ͠Ίָͩͬͨ ٕज़ج൫ੵΈॏͶ
ͨͩ͠ઌΛݟ௨͢ͷେࣄ ࠓճͷϓϩδΣΫτͷྲྀ༻Λݟ௨্ͨ͠Ͱ ্هͷίϯϙʔωϯτ࡞͍ͬͯͨ