Share
Embed
Transcript
39 slides
-
∁ੴྒ / GMO Pepabo, Inc. 2019-03-29 Cloud Native Meetup Tokyo
#7 Consul Connect and Kubernetes Integration -
TAKAISHI Ryo @r_takaishi Software Engineer @ GMO Pepabo, Inc. Belgian
Beer ☕ Tea Go, Kubernetes https://repl.info/ % Cloud Native Meetup Tokyo -
!3 • About Consul • Our background • Consul Connect
• Consul Kubernetes Integration Agenda -
• Service Discovery for connectivity • Health check, DNS, HTTP
interface • Service Segmentation for security • Secure service-to-service communication • Service Configuration for runtime configuration • KVS, Transaction, Watch !5 About Consul -
!6 About Consul app client app client client server server
server Consul Cluster 192.168.0.21 192.168.0.22 192.168.0.23 192.168.0.11 192.168.0.12 192.168.0.13 app.service.consul app health check health check health check -
!7 About Consul app client app client client server server
server Consul Cluster 192.168.0.21 192.168.0.22 192.168.0.23 192.168.0.11 192.168.0.12 192.168.0.13 app.service.consul app health check health check health check -
• IaaS্ʹConsulΫϥελʔΛߏங • nginx → rails ͷ௨৴ͳͲΛconsul-templateͰಈత੍ޚ • health-checkͱΈ߹Θͤͯɺਖ਼ৗͳϊʔυ͚ͩͿΒԼ͛Δ •
service-to-serviceͷࡍͷ໊લղܾʹConsul DNSΛ༻ !9 We use consul now!!1 -
• IaaS্ʹKubernetesΛߏங͓ͯ͠͏ͱ͍ͯ͠Δ • ͍͖ͳΓશͯҠߦ͢Δͷେมͩ͠ϦεΫߴ • طଘͷڥͱ͏·͘࿈ܞ͍ͨ͠ • → Kubernetes Integration͕͋Δ͜ͱΛΓݕূɾར༻
• → ͦͷաఔͰConnectʹ͍ͭͯݕূ !10 We try to use Kubernetes!!1 -
• v1.2(2018-06)ͰՃ • αʔϏεؒʹ͓͚Δ௨৴ͷ҉߸ԽೝՄΛߦ͏ • ҉߸Խɿ૬ޓTLS • ೝՄɿService Access Graph
!12 Consul Connect (Service Segmentation for security) -
• intentionͱ͍͏APIͱͯ͠ఏڙ͞ΕΔ • ૹ৴ݩͱૹ৴ઌɺ௨৴ͷՄ൱Λࢦఆ͢Δ • σϑΥϧτͰશαʔϏεؒͷ௨৴Λېࢭ͠ɺඞཁͳͷΛڐՄ͠ ͍ͯ͘ͱྑͦ͞͏ !13 Service Access
Graph $ consul intention create -allow source-service dest-service -
• Data Plane୲ • Sidecarͱͯ͠ `consul connect proxy` Λಈ͔͢ •
ϓϥΨϒϧʹͳ͍ͬͯͯɺEnvoyΛ͏͜ͱՄೳ !14 Sidecar Proxy $ consul connect proxy \ -http-addr=${HOST_IP}:8500 \ -service=source-service \ -upstream=“dest-service:9001” -
!15 Sidecar Proxy app Source Service’s Pod consul connect proxy
http://localhost:9001 consul cluster app Destination Service’s Pod consul connect proxy resolve `dest-service:9001` by consul API -
• consul connect proxyͷΘΓʹEnvoyΛ͑Δ • Support Envoy’s xDS configuration API
• ConsulControlPlaneͱͳΔ • v1.3.0࣌Ͱ੍͍͔ͭ͘ݶ͕͋Δ • ྫɿLayer4(TCP)ϓϩΩγͷΈαϙʔτ !16 Envoy Integration -
!17 Connect with Envoy app Source Service’s Pod envoy http://localhost:9001
consul cluster app Destination Service’s Pod envoy resolve `dest-service:9001` by Envoy xDS API -
• Build-in CAΛࡌ͍ͯ͠Δ • Hashicorp VaultͷΑ͏ͳ֎෦PKI͑Δ • Root CAͷϩʔςʔγϣϯՄೳ !18
Certification Management -
• Consul ServerΛKubernetes্Ͱಈ͔͢ • Consul ClientΛKubernetes্Ͱಈ͔͢ • ConsulͷServiceͱKubernetesͷServiceΛಉظ͢Δ • Consul
Connect Sidecar ProxyͷPodͷInjection !22 Kubernetes Integration -
• github.com/hashicorp/consul-k8s • Service SyncConnect InjectionΛఏڙ • github.com/hashicorp/consul-helm • Consul
Server/Client্هͷconsul-k8sΛhelmͰఏڙ͢Δ !23 Kubernetes Integration -
!24 Consul ServerΫϥελʔΛKubernetes্Ͱಈ͔͢ consul-server-0 Kubernetes cluster node-000 node-001 node-002 StatefulSet
consul-server-1 consul-server-2 node-003 consul-client consul-client Consul Cluster -
!25 Consul ClientΛKubernetes্Ͱಈ͔͢ consul-client-000 Kubernetes cluster node-000 node-001 node-002 DaemonSet
consul-client-001 consul-client-002 consul-server Consul Cluster -
!29 ྫɿReplica3ͷDeploymentͱServiceΛ༻ҙ͢Δ $ kubectl get svc -l app=hello-consul NAME TYPE
CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-consul NodePort 10.233.59.91 <none> 8080:31321/TCP 11m $ kubectl get pod -l app=hello-consul NAME READY STATUS RESTARTS AGE hello-consul-697658fbd5-b9sg5 1/1 Running 0 51s hello-consul-697658fbd5-p72nx 1/1 Running 0 11m hello-consul-697658fbd5-swxrd 1/1 Running 0 11m -
• Address Pod͕ಈ͍͍ͯΔNodeͷIPΞυϨε !30 ྫɿConsul DNSͰ໊લղܾͰ͖Δ $ nslookup hello-consul.service.minne.lan Server:
127.0.0.1 Address: 127.0.0.1#53 Name: hello-consul.service.minne.lan Address: 10.230.0.211 Name: hello-consul.service.minne.lan Address: 10.230.1.135 Name: hello-consul.service.minne.lan Address: 10.230.0.103 -
!31 ྫɿConsul APIͰIPΞυϨεͱPortΛऔಘͰ͖Δ $ curl -sS http://127.0.0.1:8500/v1/catalog/service/hello-consul \ | jq
-r ".[] | [.Address, .ServicePort] | @tsv" 10.230.0.211 31321 10.230.1.135 31321 10.230.0.103 31321 -
!32 Kubernetes ServiceΛConsulಉظ app Kubernetes cluster node-001 node-002 app node-000
lb consul-templateΛ༻͍ͯk8s্ͷαʔϏεΛ nginxͷconfigʹupstreamͱͯ͠ઃఆ {{ range service “app" }} server {{.Address}}:{{.Port}};{{end}} } app.service.consul -
• Kubernetes͔Β `hoge.service.consul` ͷΑ͏ͳ໊લͰConsul ্ͷαʔϏεΞΫηεͰ͖Δ • Kubernetes֎ͷConsul Cluster্ʹRDBͳͲ͕͋Δ߹ʹ͑ Δʁ !33
Consul ServiceΛKubernetes Serviceಉظ -
• istio-sidecar-injectorͷΑ͏ʹɺconsul connect proxyΛPod ʹೖͯ͘͠ΕΔ !34 Injection Consul Connect Sidecar
Proxy annotations: 'consul.hashicorp.com/connect-inject': 'true' 'consul.hashicorp.com/connect-service-upstreams': 'counting:9001' -
• Kubernetes্ͰConsulΛಈ͔͢ػೳΛఏڙ • ConsulͱKubernetesͰ૬ޓʹαʔϏεΛಉظՄೳ • Consul Connect Sidecar ProxyΛinjection͢ΔػೳΛఏڙ •
طଘͷConsulΫϥελʔͱKubernetes͕ฒߦՔಇ͍ͯ͠Δ ߹ɺ࿈ܞͤ͞Δ͜ͱͰศརʹͳΓͦ͏ !35 Kubernetes Integration·ͱΊ -
• Consul Connect • Consulͷ࣋ͭαʔϏεΛਐԽͤ͞ɺαʔϏεϝογϡԽ͢Δ • ֤αʔϏεͷ௨৴ͷՄ൱ΛઃఆͰ͖Δ • Kubernetes Integration
• ConsulΛKubernetes্Ͱಈ͔͠ɺKubernetes֎ͷConsulΫϥελͱ ࿈ܞ͢Δ !36 ·ͱΊ -
• Kubernetes, CloudNative, OpenStack, etc… • ઈࢍେืूதͳͷͰԠืͯ͘͠Εʂ !39 We are
hiring software engineer (platform) !