AWS オンライン セミナー 2023年 夏の Amazon EKS 祭り!
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API と VPC Lattice はAmazon EKS マルチクラスターの夢を見るか?2023/08/10Kenta GotoAmazon Web Services Japan G.K.Solutions Architect
View Slide
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.• 名前§ 後藤 健汰 (Kenta Goto)• 所属§ ISV/SaaS Solutions Architect• 職歴§ SIer → Web系 (インフラエンジニア)• 趣味§ サウナ2@kennygt51自己紹介
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ3
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ4
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Soft Multi-Tenancy と Hard Multi-TenancyHard Multi-Tenancy5clusterNamespace ATenant A複数のテナントが EKS クラスター上で動作する際に、ユーザーやアプリケーションを他のテナントと分離したいSoft Multi-TenancyNamespace BTenant BNamespace CTenant Ccluster ANamespaceTenant ANamespaceTenant BNamespaceTenant Ccluster B cluster CNamespace、Role、RoleBinding などのKubernetes の機能を活用テナント間の論理的な分離を実現するテナントごとに EKS クラスターを構築クラスター単位での分離を実現する
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Soft Multi-Tenancy と Hard Multi-TenancyHard Multi-Tenancy6分離レベルや運用コストから、要件に応じて分離戦略を選定するSoft Multi-Tenancy• Kubernetes のネイティブの機能を使って論理的な分離を実現• 通常、異なるテナントの Pod がNode を共有する• nodeSelector/Affinity/Taint/Toleration などのスケジューリングの仕組みによって Node の分離を実現できるが、運用が複雑化する• 運用対象のクラスター数が最小限• クラスターを分割するため、テナント間の分離が強固になる• クラスター障害時の影響範囲を分離できる• テナント数が多い場合に、コスト増につながる• 多くのクラスターを運用する必要がある
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Soft Multi-Tenancy と Hard Multi-TenancyHard Multi-Tenancy7本資料では Hard Multi-Tenancy (マルチクラスター) にフォーカスSoft Multi-Tenancy• クラスターを分割するため、テナント間の分離が強固になる• クラスター障害時の影響範囲を分離できる• テナント数が多い場合に、コスト増につながる• 多くのクラスターを運用する必要がある• Kubernetes のネイティブの機能を使って論理的な分離を実現• 通常、異なるテナントの Pod がNode を共有する• nodeSelector/Affinity/Taint/Toleration などのスケジューリングの仕組みによって Node の分離を実現できるが、運用が複雑化する• 運用対象のクラスター数が最小限
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ8
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 9VPCモノリスアプリケーションモノリスの課題• 開発速度の遅さ• 大きなデプロイ範囲• 信頼性• 新規テクノロジーの導入• スケーラビリティ背景• モノリスアプリケーションは、機能数や複雑さに応じて様々な課題が生じうる
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 10VPCサービスAWS accountVPCサービスAWS accountVPCサービスAWS accountVPCサービスAWS account背景• 複数サービス (マイクロサービス) へ分割される• その場合、複数の VPC、複数の AWS アカウントで構成されうる
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.背景11VPCサービスAWS accountVPCAWS accountVPCAWS accountVPCAWS accountEKS ClusterサービスEKS ClusterサービスEKS ClusterサービスEKS Cluster• EKS マルチクラスター環境のケース
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.考慮点 サービス間通信の必要性12VPCサービスAWS accountVPCAWS accountVPCAWS accountVPCAWS accountEKS ClusterサービスEKS ClusterサービスEKS ClusterサービスEKS Cluster• サービス間通信の課題は多種多様疎通性の確保、ロードバランシング、認証認可、オブザーバビリティ など
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.考慮点 マルチクラスターの管理13VPCサービスAWS accountVPCAWS accountVPCAWS accountVPCAWS accountEKS ClusterサービスEKS ClusterサービスEKS ClusterサービスEKS Cluster• EKS クラスターの管理工数の肥大化サービス追加時のクラスターの構築や管理新規サービス既存のクラスターのバージョンアップ
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.まとめ14マルチクラスターの管理サービス間通信の必要性• 複数のVPC、複数の AWS アカウントにまたがるワークロード間の通信• 様々な選択肢がある中で、よりシンプルな運用を実現したい• Hard Multi-Tenancy 戦略を採用し、複数の EKS クラスターを運用する場合、クラスターの管理工数が肥大化する• クラスターの管理工数を下げたい
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.まとめ15• 複数のVPC、複数の AWS アカウントにまたがるワークロード間の通信• 様々な選択肢がある中で、よりシンプルな運用を実現したい• Hard Multi-Tenancy 戦略を採用し、複数の EKS クラスターを運用する場合、クラスターの管理工数が肥大化する• クラスターの管理工数を下げたいAmazon VPC Lattice+AWS Gateway API ControllerCluster API+Cluster API Provider AWSマルチクラスターの管理サービス間通信の必要性
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ16
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 17Amazon VPC Lattice
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Amazon VPC Lattice とは18• 接続性• アカウント、VPC をまたいだ L7 レイヤーでのサービス間接続• CIDR が重複する VPC 間での接続が可能• コンピューティングサービスの一貫性• Amazon EC2、AWS Lambda、Amazon EKS との統合• オブザーバビリティ、トラフィックコントロール• Amazon S3、Amazon CloudWatch、Amazon Kinesis Data Firehose へのメトリクス及びログの出⼒• ALB/NLB が不要なロードバランシング• セキュリティ• IAM による認証様々なサービス間通信を、特定の技術 (コンテナなど) に依存せず、Amazon VPC のネットワークサービスのみでシンプルに実現するサービスAmazon VPC Lattice
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.VPC Lattice の主要コンポーネント19ServiceDirectoryVPCサービス AEKSサービス BVPCEC2サービス CLambdaServiceDirectoryサービス• 単一のアプリケーションユニットで、1 つのサービスコンポーネントを「サービス」として定義する• リスナーやルール、ターゲットグループといったALB と似たコンポーネントから構成されるサービスネットワーク• 論理的なアプリケーション層ネットワークの境界• VPC やアカウントをまたいでクライアントとサービスを接続認証ポリシー• IAM を活用した認証ポリシー• サービスネットワークや個々のサービスに関連付けることで、アクセス制御をおこなうサービスディレクトリ• すべての「サービス」の一元化されたレジストリ• AWS RAM を通じてアカウント間で共有された「サービス」を含む
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.VPC Lattice コンポーネント間の関係20サービスネットワークAサービスネットワークBサービス#1 サービス#2 サービス#3サービス#3サービス#2サービス#1 サービス#2VPCサービスVPCサービスVPCサービスVPCサービス関連付け関連付け 関連付け関連付けVPC Lattice1. 「サービス」を作成2. 「サービスネットワーク」を作成し、サービスを「関連付け」する3. 「サービスネットワーク」を VPC に「関連付け」する
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.VPC Lattice で実現可能なネットワーク接続21• アカウントや VPC をまたいだ HTTP/S、gRPC での通信を実現• Transit Gateway や VPC Peering は不要• DNS 名によるシンプルな名前解決• ターゲットとして EC2 インスタンスや Lambda 関数、Kubernetes コンテナなど複数のリソースに対応EC2 インスタンスIP アドレス(VPC ローカル IP)Lambda 関数(VPC Lambda/非 VPC Lambda いずれも可)Kubernetesコンテナ (実体は IP アドレス)AutoScalingグループNLB ALB(internal)
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 22AWS Gateway API Controller for VPC Lattice
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Kubernetes Gateway API とは• Kubernetes Gateway API は SIG-NETWORK コミュニティを中心に開発が行われている API リソース• クラスター外部からのトラフィックを制御するためのもので、Ingress リソースが抱える各種課題の解決を目的として開発された• Ingress が基本的に単一のリソースで構成されるのに対して、Gateway は GatewayClass、Gateway、HTTPRoute といった複数のリソースから構成される• ロールによる権限分離が可能になるGatewayClassGatewayHTTPRouteServicePodCloud OperatorApplicationDeveloper
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Kubernetes Gateway API とは• Gateway API には複数の実装が存在 (※1)• Istio• NGINX Kubernetes Gateway• AWS Gateway API Controller for VPC Lattice (※2)※1 https://gateway-api.sigs.k8s.io/implementations/※2 https://github.com/aws/aws-application-networking-k8s
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.AWS Gateway API Controller for VPC Lattice とは• Kubernetes Gateway API を実装するコントローラー• AWS Gateway API Controller for VPC Lattice は Gateway API で定義されたカスタムリソースに対応する VPC Lattice のリソースを作成する• Gateway や HTTPRoute といった Kubernetes のリソースを作成することで、VPC Lattice のサービスといった AWS のリソースを作成する• EKS 上のワークロードで VPC Lattice を使う場合は、このコントローラーをクラスターにデプロイするAWS Gateway APIControllerfor VPC LatticeEKS Clusterkubectl applyVPC LatticeService NetworkServiceTarget GroupTarget作成カスタムリソース(Gateway,HTTPRoute)
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Gateway API と VPC Lattice リソースの対応GatewayClassGatewayHTTPRouteServicePodAmazon EKSService NetworkServiceTarget GroupTargetVPC LatticeKubernetes Gateway API リソースと VPC Lattice のリソースは、以下のように対応する
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.GatewayClass リソース• GatewayClass は、実際にどのようなコンポーネントでトラフィックを処理するかを定義する• Infrastructure provider (AWS など)によって事前定義される§ PersistentVolume におけるStorageClass と似た位置付け• AWS Gateway API Controller forVPC Latticeでは amazon-vpc-lattice GatewayClass がサポート
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Gateway リソース• Gateway は、GatewayClass を指定したうえで、リスナー (トラフィックを受け付けるポートやプロトコルなど) を定義する• AWS Gateway API Controller forVPC Latticeは、Gateway リソースが作成され EKS クラスターが存在する VPC をサービスネットワークに関連付ける際にサービスネットワークが存在しなかった場合に、サービスネットワークリソースを作成する
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.HTTPRoute リソース• HTTPRoute は、Gateway を指定したうえで、受信した HTTP トラフィックのバックエンドサービスへのルーティングを定義する• URL パスやリクエストヘッダーを元に転送先の Service を指定したり、weight を指定して加重ルーティングをおこなう• AWS Gateway API Controller forVPC Lattice は、指定した Serviceをターゲットグループとしてリソースを作成し、Pod の IP アドレスをターゲット IP アドレスとして登録する
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.VPC Lattice と AWS Gateway API Controller で実現できること30VPCAWS accountVPCAWS accountVPCVPC
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ31
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 32Cluster API
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.EKS クラスターの構築/管理における選択肢eksctlAWS CDKAWS CloudFormationAWS Management ConsoleTerraform
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.EKS クラスターの構築/管理における選択肢eksctlAWS CDKAWS CloudFormationAWS Management ConsoleTerraform Cluster API
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API とは• SIG-Cluster Lifecycle コミュニティで管理されているプロジェクト• 複数の Kubernetes クラスターのライフサイクル (プロビジョニング、アップグレードなど) を管理するための仕組み• Deployment や Pod などのリソースと同じく、宣言的 API を使用してクラスターのライフサイクルを管理する• 様々なインフラストラクチャで利用可能• 共通のオペレーションを定義し、デフォルトの実装を提供する。また、利用するインフラストラクチャに応じて、代替となる実装をプラグインのような形で利用できる35Cluster API
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API とは36Management ClusterkubectlUserclusterctlCluster API ControllerBootstrap providerInfrastructure providerControlPlane providerWorkload ClusterWorkload ClusterWorkload ClusterCRDs
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API とは37Management ClusterkubectlUserclusterctlWorkload ClusterWorkload ClusterWorkload ClusterCRDsCluster API ControllerBootstrap providerInfrastructure providerControlPlane providerWorkload ClusterCluster API によって管理されるKubernetes クラスターのこと
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API とは38Management ClusterkubectlUserclusterctlWorlload ClusterWorkload ClusterWorkload ClusterCRDsCluster API ControllerBootstrap providerInfrastructure providerControlPlane providerManagement ClusterWorkload Cluster を管理する Kubernetes クラスターのことKubernetes リソースが保存される
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API とは39Management ClusterkubectlUserclusterctlWorkload ClusterWorkload ClusterWorlload ClusterCRDsCluster API ControllerBootstrap providerInfrastructure providerControlPlane providerCRDCluster API の CRD によってカスタムリソースが定義されている。kubectl apply などによってリソースが登録されると、Cluster API によってWorkload Cluster が作成される
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API とは40Management ClusterkubectlUserclusterctlWorlload ClusterWorkload ClusterWorkload ClusterCRDsCluster API ControllerBootstrap providerInfrastructure providerControlPlane providerclusterctlCluster API Management Cluster を管理するためのCLI ツールManagement Cluster としての初期化などをおこなう
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API で AWS 上に クラスターを構築する• Cluster API は複数の環境 (オンプレミス、クラウド) でのクラスターの構築をサポート• 環境固有の CRD とコントローラーは Provider として切り出されている§ AWS 上でのクラスター構築もサポートしている• Cluster API Provider AWS§ AWS 上にクラスターを構築するための Provider
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 42Cluster API Provider AWS
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API Provider AWS とは43• Cluster API Provider AWS (CAPA) とは§ Cluster API を拡張する Provider• Cluster API から AWS 上に Kubernetes クラスターを構築する際に利用する§ クラスター及び関連するインフラストラクチャリソースを作成する• 2 つの異なるタイプのクラスターをサポートしている§ Amazon EC2 ベース§ Amazon EKS ベース
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Cluster API Provider AWS とは44Management ClusterkubectlUserclusterctlCore OperatorBootstrap ProviderInfrastructure ProviderControlPlane ProviderWorkload Cluster (EC2)CRDsWorkload Cluster (EKS)
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ45
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 46AWS accountAWS アカウント作成マルチ EKS クラスター作ってみた
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 47AWS accountCluster APIProviderEKS ClusterVPC管理用 EKS クラスター (Management Cluster) を構築マルチ EKS クラスター作ってみた
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 48VPCAWS accountEKS ClusterVPCEKS ClusterVPCEKS ClusterVPCEKS ClusterCluster APIProviderEKS ClusterVPCマルチ EKS クラスター作ってみた Cluster API を用いて複数のワークロード用 EKS クラスター(Workload Cluster) を構築
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 49VPCサービスAWS accountEKS ClusterVPCサービスEKS ClusterVPCサービスEKS ClusterVPCサービスEKS ClusterCluster APIProviderEKS ClusterVPC管理用クラスターの Argo CD からワークロード用クラスターにサービスをデプロイマルチ EKS クラスター作ってみた
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 50VPCサービスAWS accountEKS ClusterVPC LatticeVPCサービスEKS ClusterVPCサービスEKS ClusterVPCサービスEKS ClusterCluster APIProviderEKS ClusterVPCVPC Lattice 経由でワークロード用クラスターで稼働するサービスを繋ぐマルチ EKS クラスター作ってみた
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 51VPCサービスAWS accountEKS ClusterVPC LatticeVPCサービスEKS ClusterVPCサービスEKS ClusterVPCサービスEKS ClusterCluster APIProviderEKS ClusterVPCマルチ EKS クラスター作ってみた
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Agenda• Soft Multi-Tenancy と Hard Multi-Tenancy• マルチクラスターの考慮点• Amazon VPC Lattice と AWS Gateway API Controller for VPC Lattice• Cluster API と Cluster API Provider AWS• Amazon EKS マルチクラスターを作ってみた• まとめ52
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.本セッションのまとめ53• Kubernetes クラスター上でのテナント分離には Soft Multi-tenancy と Hard Multi-Tenancy という考え方があり、要件に応じて適切な戦略を選択する• VPC やアカウントをまたいだ マルチ EKS クラスター間の通信には様々な選択肢があり、Amazon VPC Lattice はそのひとつ§ EKS だけではなく、様々なワークロード間の通信を実現• Cluster API を用いた宣言的 API によるマルチクラスター管理という選択肢§ Kubernetes に対する深い知見を要求される• クラスター数が増えることで、考慮事項も増える• 設計段階で「本当にマルチクラスターが必要なのか」をしっかりと検討する§ Soft Multi-Tenancy で十分なケースも多い§ どういった状況でクラスターを分離する必要があるかを考慮する
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.Thank you!