2019/08/08 Thu
Cloud Native FUKUOKA #02 - connpass https://cnjp.connpass.com/event/139837/
Traffic Managementwith Istio ( with Demo )2019/08/08 Cloud Native FUKUOKA #02loftkun
View Slide
About me• @loftkun• ヤフー株式会社 SRE部• 将棋好き• 対局結果検索サイトなど公開してます• ⾳楽好き• ROCK IN JAPAN FESTIVAL ⾏きます• ピアノ習いたい• コンテナ好き、k8sは前職で使ってた、現職でも使いたい
My k8s Environment
MachineCPU Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz6Core/12ThreadsRAM 64GBOS Ubuntu 17.10k8sminikube v1.2.0 ( Kubernetes v1.15.0 )assign 12cpu & 40GB RAMkubectl v1.15.0istio v1.2.2helm v2.14.1
minikube start vm-driver=virtualboxContainerVM ( Node )MinikubeBareMetalssh -fNL 12345:192.168.99.100:12345 [email protected]192.168.3.5grafana service のnodePortが12345の場合http://localhost:12345 でアクセスできるぞ192.168.99.100192.168.3.4Minikube sshでログイン可能
minikube start vm-driver=noneContainerMinikubeBareMetal192.168.3.5( Node )grafana service のnodePortが12345の場合http://192.168.3.5:12345 でアクセスできるぞ192.168.3.4tcpdump –i docker0全Pod間の通信をキャプチャできるぞ
AgendaIntroductionHow to useBookinfoTraffic Management
IntroductionWhat is Istio?
https://istio.io/• サービスメッシュを構成するOSS• CNCF Platinum Member• Proxyコンテナ(Envoy)をSidecarとしてPod内にInjectionしてくれる• 様々な制御をkubectl applyできる(後ほどご紹介)• 便利なOSS同梱• メトリクス (Prometheus/Grafana)• トレース (Jaeger/Zipkin)• サービスメッシュグラフの可視化(Kiali)
https://github.com/cncf/trailmap
How to useInstall à Sidecar Injection à Apply traffic rules
3 stepsInstallSidecar InjectionApply traffic rules
InstallUse Helm? $ kubectl apply istio-demo.yamlCluster hastiller? $ helm template istio | kubectl apply$ helm install istioYYおすすめはHelm使⽤。パラメタ設定が楽。• incubator/istioはメンテが⽌まってるので使わない• istio.ioのdoc記載の最新版をdownloadして使おうNN
Sidecar InjectionManualistioctl kube-injectコマンドでSidecarを埋め込んだmanifestを出⼒する$ kubectl apply -f < ( istioctl kube-inject -f my-manifests.yaml )Automatic対象のnamespaceにラベルを設定しておくだけでOK!$ kubectl label ns my-ns istio-injection=enabled
Apply traffic ruleskubectl apply –f my-virtualservice.yaml• VirtualService• a set of traffic routing rules• 宛先別に様々なruleを設定できるIstio setup is done, Letʼs Traffic Management !
BookinfoIstioが提供するサンプルアプリ
Architecturehttps://istio.io/docs/examples/bookinfo/load balancing( by reviews service )
Demo
Traffic ManagementRouting, Fault Injection, etc
Request Routinghttps://istio.io/docs/examples/bookinfo/
review v1 (星なし)
Request Routing ( by header )https://istio.io/docs/examples/bookinfo/
Canary Release に使えそう︕ review v2 (⿊い星)
Fault Injection (delay )InjectedDelay : 7sechttps://istio.io/docs/examples/bookinfo/
https://istio.io/docs/examples/bookinfo/
hard-cordedTimeout : 10secInjectedDelay : 7sechttps://istio.io/docs/examples/bookinfo/
hard-cordedTimeout : 3secRetry : 1hard-cordedTimeout : 10secInjectedDelay : 7secChaos Engineering に使えそう︕ https://istio.io/docs/examples/bookinfo/
Other Traffic Managements• Traffic Shifting• Circuit Breaking• Mirroringand more !https://istio.io/docs/tasks/traffic-management/
Appendix
なぜヨット︖
いろいろ船関連だったKubernetes 操舵手(ギリシャ語)Helm 舵tiller 舵柄(かじを操作するレバー)Istio 帆(ギリシャ語)Spinnaker 大きな三角形の帆
Thank you for listening !福岡新着ITイベント@ITEventFukuoka
Appendix :commands for demowith my home k8s
ssh config• ~/.ssh/config• ログインssh my-k8s
ssh port forwardingINGRESS_HOST=192.168.99.100INGRESS_PORT=31380ssh -fNL ${INGRESS_PORT}:${INGRESS_HOST}:${INGRESS_PORT} my-k8s• ローカルの31380ポートをnode(MinikubeのVM) 内の31380ポートにforwarding• BookInfoは localhost:31380/productpage で⾒れる
ref• Request Routing• https://istio.io/docs/tasks/traffic-management/request-routing/• Fault Injection• https://istio.io/docs/tasks/traffic-management/fault-injection/
Appendix :BookInfo screenshot
review v1のレスポンス
reload
review v2のレスポンス(⿊い星)
review v3のレスポンス(⾚い星)