Slides for Workshop Session at Azure Antenna Sept, 2018
サービスメッシュはマイクロサービスに回復力を持たせるために非常に有効なアーキテクチャ
手法の1つであり、Istioは、このサービスメッシュの機能を実装するためのフレームワークを
提供するとても注目度の高いOSSです。このワークショップでは座学を通じてIstioの基礎を
学んでいただき、実際にハンズオンで手を動かしていただくことでIsito/サービスメッシュの
理解を深めていただきます。コンテナオーケストレーターにKubernetes(本ワークショップ
ではAzure Kubernetes Service)を利用するためKubernetesクラスタ構築も実施いただきます。
ご参加者のスキルレベルについて:
ワークショップ資料は全て GitHub に公開予定です
Kubernetes: デファクト オーケストレーター
ポータブル
Public, private, hybrid,
multi-cloud
拡張可能
Modular, pluggable,
hookable, composable
自己回復(Self-healing)
Auto-placement, auto-restart,
auto-replication, auto-scaling
https://kubernetes.io/
Master VM Master VM
Master VM
Worker
Node
Worker
Node
Worker
Node
Worker
Node
Worker
Node
Worker
Node
kubectl apiserver
Web UI
etcd
scheduler
Controller
manager
kubelet
kube proxy
Container
LBCLIコマンド
ダッシュボード
永続化データ保持のためのKVS
認証、CRUD操作
Podのノード割り当て 各種コントローラー
ノードごとの
Pod管理
Service VIPアドレスのルーティング
外部からの
アクセス
https://kubernetes.io/docs/concepts/overview/components/
全ての操作はapiserver経由で行われる
API
Container
runtime
kubelet
kube proxy
Container
ノードごとの
Pod管理
Service VIPアドレスのルーティング
Container
runtime
deployment
ReplicaSet
Pod Pod
DeploymentとReplicaSetの仕組みで、ノードの障害やアプリのクラッシュ等で
Podが足りなくなった際に自動的にPodが追加される
DeploymentはReplicaSetを管理し、ReplicaSetはPodを指
定数(Replica数)に調整・管理を行う仕組。
Podがレプリカ数より足りない場合はPodを追加し、多
い場合はをPodを削除する
Deployment
ReplicaSet
Pod
A
Pod
B
Pod
C
Deployment
ReplicaSet
Pod
A
Pod
B
Pod
C
Pod
C
Deployment
ReplicaSet V1
Pod Pod Pod
Deployment
ReplicaSet v1
Pod Pod
ReplicaSet V2
Pod
Deployment
ReplicaSet V2
Pod Pod Pod
AKSの主な特徴
Azure Container Ecosystem
IaaSPaaS
Azure services
SQL Database
Redis Cache
CosmosDB
And more!
Partner services
OpenShift
Pivotal Cloud
Foundry
Docker Enterprise
Edition
Mesosphere
DC/OS
Azure
Azure
Container
Registry
(ACR)
OSBA
Azure Kubernetes
Service (AKS)
ACS
Engine
Batch
Azure Container
Instances (ACI)
Azure Virtual
Machines
Virtual Machine
Scale Sets
(VMSS)
Service Fabric
Virtual kubelet
App Service
マイクロサービスアーキテクチャではアプリケーションが小規模の独立
したサービスで構成される。マイクロサービスは適切に構築することで
様々なメリットが得られる一方いくつかの課題に対処する必要がある
• データ一貫性・整合性の維持
• 複雑なサービス間通信
• クライアント・アプリ間の通信
• 分散アプリケーションのモニタリング
• 継続的インテグレーションとデリバリ (CI/CD)
マイクロサービスの設計: サービス間通信
https://docs.microsoft.com/ja-jp/azure/architecture/microservices/interservice-
communication
• 通信の回復性
• サービス間通信の回復力を高める設計パターン: リトライ、サーキットブレーカー
• 負荷分散
• シナリオに応じた負荷分散アルゴリズムの適用
• 分散トレース
• 1トランザクションで複数サービス呼び出しを要する処理における一連の手順全体を
再構成するための相関 ID を伝達
• サービスバージョン管理
• 各サービスの複数バージョンの管理と特定バージョンへのルーティング
• サービス間トラフィック暗号化
• TLS暗号化と相互TLS認証
• サービスメッシュはサービス間通信を処理するソフトウェア
レイヤーで、アプリに代わってネットワーク要求を送信する
ヘルパー サービス
• サービスメッシュが提供する代表的なネットワークサービス
• トラフィック制御
• 回復性、耐障害性処理
• 可視化、分散トレース
• 認証、セキュリティ機能
https://github.com/istio/istio
https://github.com/linkerd/linkerd https://github.com/runconduit/conduit
https://istio.io
https://istio.io/docs/concepts/what-is-istio/
Features for Resiliency(回復性)
Istioで利用されている主な機能
• Dynamic service discovery
• Load balancing
• TLS termination
• HTTP/2 and gRPC proxies
• Circuit breakers
• Health checks
• Staged rollouts with %-based traffic
split
• Fault injection
• Rich metrics
https://www.envoyproxy.io/
Envoy はKubernetes Pod内に
Sidecarとしてデプロイされる
“ENVOY IS AN OPEN SOURCE
EDGE AND SERVICE PROXY,
DESIGNED FOR CLOUD-NATIVE
APPLICATIONS”
https://www.envoyproxy.io/
https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/hot_restart
Azure/クラウド設計パターン/サイドカー: https://docs.microsoft.com/ja-jp/azure/architecture/patterns/sidecar
• Control Plane: Istio
• Data Plane: Envoy
• Pilot:
• Mixer:
• Citadel:
https://istio.io/docs/concepts/what-is-istio/
https://istio.io/docs/concepts/traffic-management/#discovery-and-load-balancing
Service discovery
service
Load balancing algorithm
• round robin
• Random
• weighted least request (重み付け
最少接続数)
https://istio.io/docs/concepts/traffic-management/#ingress-and-egress
https://istio.io/docs/tasks/traffic-management/request-routing/
• defines the rules that control how requests for a service are routed within an Istio
service mesh
• defines policies that apply to traffic intended for a service after routing has occurred
• configuration for load balancing, connection pool size from the sidecar, and outlier
detection settings to detect and evict unhealthy hosts from the load balancing pool
• can be used for scenarios like A/B testing, or routing to a specific version of a
service
Traffic Routing Configuration reference:
https://istio.io/docs/reference/config/istio.networking.v1alpha3/
Communication between services
https://istio.io/docs/concepts/traffic-management/#communication-between-
services
splitting traffic between versions
https://istio.io/docs/concepts/traffic-management/#splitting-traffic-between-versions
ServiceX
Reviews-Pod2
V1
Reviews-
Pod4
V3
Reviews-Pod3
V1
Reviews-Pod1
V1
Communication between services
https://istio.io/docs/concepts/traffic-management/#communication-between-
services
splitting traffic between versions
https://istio.io/docs/concepts/traffic-management/#splitting-traffic-between-versions
ServiceX
Reviews-Pod2
V1
Reviews-
Pod4
V2
Reviews-Pod3
V1
Reviews-Pod1
V1
ServiceX
Reviews-Pod2
V1
Reviews-
Pod4
V2
Reviews-Pod3
V2
Reviews-Pod1
V1
delay / abort
(user=jason)
user=jason
Istio fault injection https://istio.io/docs/tasks/traffic-management/fault-injection/
Istio - Creating circuit breaking policies
https://istio.io/docs/tasks/traffic-management/circuit-breaking.html
Polly サーキット ブレーカー ポリシーを使用した実装例
サーキット ブレーカー パターンの実装
https://docs.microsoft.com/ja-jp/dotnet/standard/microservices-architecture/implement-resilient-applications/implement-circuit-breaker-pattern
Istio Security Concept https://istio.io/docs/concepts/security/
Pilot:
Mixer: 認証・監査の管理
Citadel:
OpenTracing
OpenTracing
https://jaeger.readthedocs.io/en/stable/architecture/
•x-request-id
•x-b3-traceid
•x-b3-spanid
•x-b3-parentspanid
•x-b3-sampled
•x-b3-flags
•x-ot-span-context
https://github.com/openzipkin/b3-
propagation
https://istio.io/docs/tasks/telemetry/distributed-tracing/
SvcA-Pod
Mixer
SvcB-Pod
MixerAPIAdapter
Adapter
Adapter
Adapter
SvcB-Pod
Trace Data
Storage & UI
SvcA-Pod
Mixer
SvcB-Pod
MixerAPI
Adapter
Adapter
Adapter
Adapter
ServiceGraph
https://istio.io/docs/reference/confi
g/policy-and-telemetry/adapters/
https://istio.io/docs/tasks/telemetry/metrics-logs/
https://istio.io/docs/tasks/telemetry/using-istio-dashboard/
https://istio.io/docs/tasks/telemetry/servicegraph/
https://istio.io/docs/tasks/telemetry/fluentd/
https://github.com/yokawasa/azure-container-labs
https://github.com/yokawasa/azure-container-labs/blob/master/labs/aks-100-setup-env.md
https://github.com/yokawasa/azure-container-labs/blob/master/labs/aks-101-create-aks-cluster.md
https://github.com/yokawasa/azure-container-labs/blob/master/labs/aks-202-istio-top.md
Product
page
Mixer
Pilot
Citadel
Ingress
gateway
Review
V1
Review
V2
Review
V3
Ratings
Details
https://github.com/istio/istio/tree/master/samples/bookinfo
https://istio.io/docs/examples/bookinfo/
Istioサービスメッシュ入門

Istioサービスメッシュ入門