Istio on GKEやってみる

Table of Contents

tldr

GKEでIstioやってみました

Let’s get started

terraform でクラスタ立ち上げ

istioctlのインストール

export ISTIO_VERSION=1.1.2 curl -L -O https://github.com/istio/istio/releases/download//istio--osx.tar.gz tar xzf istio–osx.tar.gz cp istio-/bin/istioctl /usr/local/bin/ istioctl version

同じバージョンをインストールする

サンプルアプリをインストール

https://cloud.google.com/kubernetes-engine/docs/tutorials/installing-istio#step_3_deploy_the_bookinfo_sample_application

機能を試す

https://istio.io/docs/tasks/traffic-management/

Visualizing Your Mesh

https://istio.io/docs/tasks/telemetry/kiali/

Istio の理解

トラフィックの管理

service registry

サービスメッシュを構成する各アプリケーションやエンドポイント一覧が保存されているところ。kubernetesで言うところのサービスや外部のエンドポイントで構成される。

Virtual services

仮想的なサービス。ここでサービスとはkubernetesのサービスと概念は一緒。フィルターやルーティングを可能にする。サイドカーであるEnvoyが実際にはやる。

Routing rules

Virtual servicesに設定するルールのこと。

Destination rules

Virtual serviceが入ってくる通信に対して働く一方、Destination rulesは出ていく通信をインターセプトするルール。

Gateways

Envoyだけで構成されるコンポーネント。Ingress/Egressの役割を果たす。例えば、外部からリクエストが来た時にGatewayでまず受け取ってルーティングするときに使う。

Service entries

外部のエンドポイントをService registryに登録するための箱。本来、外部サービスはサービスメッシュの管理下ではないが、ルーティングやサーキットブレイカーを導入する際に管理下にないと困る。だからService entryとして認識させる。

Sidecars

Network resilience and testing

Virtual serviceやDestination ruleに設定を追加することで以下のような機能を実現できる。

Virtual services

  • Timeouts
  • Retries
  • Fault injection

Destination rules

  • Circuit breakers

Architecture

Istioのトラフィック管理は以下の2つのコンポーネントで実現される。

  • Pilot: the core traffic management component.
  • Envoy proxies: which enforce configurations and policies set through Pilot.

大きく分けて3つの機能を提供する。

  • Service discovery
  • Load balancing
  • Traffic routing and control

Pilot

Envoy proxies

Service discovery and load balancing

ポリシーとセキュリティ

Istio identity

以下のIdentityを認識する。

  • Kubernetes: Kubernetes service account
  • GKE/GCE: may use GCP service account
  • GCP: GCP service account
  • AWS: AWS IAM user/role account
  • On-premises (non-Kubernetes): user account, custom service account, service name, Istio service account, or GCP service account. The custom service account refers to the existing service account just like the identities that the customer’s Identity Directory manages.

Istio security vs SPIFFE

SPIFEE: サービス間認証の仕様

PKI

Kubernetes scenario
On-premises machines scenario
Node agent in Kubernetes

Best practices

Deployment guidelines
Example
How Citadel determines whether to create Service Account secrets

Authentication

Mutual TLS authentication
    Permissive mode
    Secure naming
Authentication architecture
Authentication policies
    Policy storage scope
    Target selectors
    Transport authentication
    Origin authentication
    Principal binding
Updating authentication policies

Authorization

Authorization architecture
Enabling authorization
Authorization policy
    ServiceRole
    ServiceRoleBinding
Using Istio authorization on plain TCP protocols
Authorization permissive mode
Using other authorization mechanisms

Observability

  • Metrics
  • Distributed Traces
  • Access Logs

Metrics

Proxy-level Metrics

Service-level Metrics

Control Plane Metrics

Distributed Traces

分散トレーシングは結局アプリケーション側でheaderを電波させる必要がある。

なぜ? Istioサイドカーは、関連するアプリケーションインスタンスのインバウンドとアウトバウンドの両方のリクエストを処理しますが、アウトバウンドリクエストをそれらを引き起こしたインバウンドリクエストに暗黙的に関連付ける方法はない。

Access Logs