米シリコンバレーDevOps監修!上級編Terraform + AWS EKS + VPCハンズオンベストプラクティス!
Buy now
Learn more
ここから始めよう!
このコースの立ち位置
Terraformベストプラクティスの3 Layers Moduleアーキテクチャーの概要
AWS CLIの名前付きプロファイルを~/.aws/credentialsに設定する
Terraformベストプラクティスの3 Layers Moduleアーキテクチャーの概要
terraform-aws-eks-vpc-handson-jp.zip
Terraform Remote Backendに必要なリソースを3-layered Module Architectureで作成
Terraform Remote Backendを3-layered Moduleで作成する概要
Step 1: S3のRemote TF modulesを local Resource Modulesにコピー(Bottom up approach)
Step 2: Terraform Remote BackendのInfrastructure Modulesを作成
Step 3: Composition layerを作成し、必要なインプット変数のValueを定義しInfra layerにパスダウン
3つのSubnetレイヤーがあるVPCを作成(AWS完全入門コースの本番運用ベストプラクティスのチャレンジチャプターに似ている)
Step 1: VPCのRemote TF modulesを local Resource Modulesにコピー(VPCとSecurity Groupなど)
Step 2: VPCのInfrastructure Modulesを作成
Step 3: Composition layerを作成し、必要なインプット変数のValueを定義しInfra layerにパスダウン
EKS ClusterをVPC内に作成
EKSを作成するステップの概要
Step 1: EKSのRemote TF modulesを local Resource Modulesにコピー(Bottom up approach)
Step 2: EKSのInfrastructure Modulesを作成
Step 3: Composition layerを作成し、必要なインプット変数のValueを定義しInfra layerにパスダウン
Step 4: kubeconfigファイルを設定して、EKS clusterにアクセスする
EKS worker nodeにAttachされたAWS EBS Volumesを暗号化する
EBSボリュームを暗号化するステップの概要
Step 1: EBS root volumeを暗号化するAttributeをComposition layerの`local.tf`で定義
Step 2: 暗号化するためにAWS KMS Key moduleをInfra layerに作成
Step 3: AWS KMS moduleをResource layerに作成
Security: AWS IdentityのK8sへの認証(aws-auth configMap)と認可(RBAC: Clusterrolebinding)
(上級編)AWS IdentityのK8sへの認証・認可のおさらい
Step 1: まずはAWS IAM roles/users/accountsを `aws-auth` ConfigMapを使ってK8sクラスターに追加する方法
Step 2: `map_roles`ローカル変数を`data.tf`に定義、Infraレイヤーにパスダウン
Step 3: `map_roles`インプット変数をResource layerにパスダウン
Step 4: AWS IAM role `Developer`が`aws-auth` configmapに存在していないことをチェック
Step 5: Terraform apply
Step 6: `aws-auth` configmapに`Developer` AWS IAM roleが追加されていて、認証できるかチェック
Step 7: ClusterRoleBinding `k8s-developer`を作成し、K8sクラスター内でAWS Identityが認可が取れるかテスト
K8s taintとlabelをworker nodesに追加
Step 1: まずはWorker nodesの既存のtaintsとlabelsをチェック
Step 2: taintsとlabelsを追加
Step 3: Terraform apply
Step 4: マニュアルでEC2 worker nodesを再起動し、EC2にTaintとLabelをUserdataスクリプトから追加させる
K8s コントロールプレーン (Master Components)のLoggingを有効化
K8s コントロールプレーン (Master Components)のLoggingの概要
Step 1: まずはコントロールプレーンのログを有効化するための、resource moduleで必要なインプット変数を理解する
Step 2~4: `cluster_enabled_log_types`というインプット変数を、terraform.tfvarsで定義し、Infraへパス
Step 5: control planeのlogsが有効化されているかConsoleからチェック
(ベストプラクティス) Security: IRSA(IAM Role for Service Account)を使い、PodレベルのAWSへの認可を設定
IRSA(IAM Role for Service Account、またはPodレベルのIAM認可)アーキテクチャの解剖とおさらい
Step 1: まずはIRSAの3つのRequirementsを理解する
Step 2: (req1) OIDCプロバイダーを作成し、クラスターにアソシエイト
Step 3: `Composition` layerのterraform.tfvarsで、`enable_irsa`インプット変数をtrueに設定
Step 4~5: `enable_irsa`インプット変数をinfraからresource moduleへパスし、Terraform applyする
Step 6: (req2) NamespaceとServiceAccountとOIDCエンドポイントを指定したIAM assumable roleを作成
Step 7: IAM assumable roleとIAM policy modulesをinfrastructure layerで作成
Step 8: AWS Terraform module for IAMをresource module layerにコピー
Step 9: Terraform apply
Step 10: 作成されたAWS IAM roleがk8s namespaceとservice account名を含んでいるかチェック
Step 11: (req3) IAM roleをservice accountのAnnotationに追加し、IRSAをテスト
K8s worker nodesをCluster Autoscaler (CA)を使ってスケールアウト・ダウンする(AWS ASGに似ている)
Cluster Autoscalerの概要とおさらい
Step 1: (ch8で設定済み) K8sノードのlabelsとtaintsを設定
Step 2: Cluster Autoscalerのauto-discoveryをASGのTagで有効化する
Step 3: ASGのIAM パミッションを、cluster autoscalerにIRSA (Podレベル)で追加
Step 4: Cluster Autoscaler(CA)をHelm chartでインストール
Step 5: Cluster AutoscalerのIAM roleが正しいかチェック
Step 6: Metrics Serverをインストール
Step 7. CAのAuto Scalingをテスト
EFS (Elastic File System)をK8s Worker Nodes (EC2)に自動でマウントする
EFSの概要
Step 1: terraform.tfvarsで, EFSのファイルIDとマウントポイントを`/etc/fstab`ファイルに書き込むコマンドを指定する
Step 2: EFS moduleをinfrastructure layerに作成
Step 3: EFS resourceをResource layerで定義
Step 4: Terraform apply
Step 5: EFSがAuto-mountされてるかSSH接続してテスト
全てのAWSリソースをクリーンアップ
クリーンアップ
ボーナスレクチャー!
下のコメント欄にレビューを残していただけると最大20%割引クーポンを差し上げます!
Products
Course
Section
Lesson
Terraform Remote Backendを3-layered Moduleで作成する概要
Terraform Remote Backendを3-layered Moduleで作成する概要
米シリコンバレーDevOps監修!上級編Terraform + AWS EKS + VPCハンズオンベストプラクティス!
Buy now
Learn more
ここから始めよう!
このコースの立ち位置
Terraformベストプラクティスの3 Layers Moduleアーキテクチャーの概要
AWS CLIの名前付きプロファイルを~/.aws/credentialsに設定する
Terraformベストプラクティスの3 Layers Moduleアーキテクチャーの概要
terraform-aws-eks-vpc-handson-jp.zip
Terraform Remote Backendに必要なリソースを3-layered Module Architectureで作成
Terraform Remote Backendを3-layered Moduleで作成する概要
Step 1: S3のRemote TF modulesを local Resource Modulesにコピー(Bottom up approach)
Step 2: Terraform Remote BackendのInfrastructure Modulesを作成
Step 3: Composition layerを作成し、必要なインプット変数のValueを定義しInfra layerにパスダウン
3つのSubnetレイヤーがあるVPCを作成(AWS完全入門コースの本番運用ベストプラクティスのチャレンジチャプターに似ている)
Step 1: VPCのRemote TF modulesを local Resource Modulesにコピー(VPCとSecurity Groupなど)
Step 2: VPCのInfrastructure Modulesを作成
Step 3: Composition layerを作成し、必要なインプット変数のValueを定義しInfra layerにパスダウン
EKS ClusterをVPC内に作成
EKSを作成するステップの概要
Step 1: EKSのRemote TF modulesを local Resource Modulesにコピー(Bottom up approach)
Step 2: EKSのInfrastructure Modulesを作成
Step 3: Composition layerを作成し、必要なインプット変数のValueを定義しInfra layerにパスダウン
Step 4: kubeconfigファイルを設定して、EKS clusterにアクセスする
EKS worker nodeにAttachされたAWS EBS Volumesを暗号化する
EBSボリュームを暗号化するステップの概要
Step 1: EBS root volumeを暗号化するAttributeをComposition layerの`local.tf`で定義
Step 2: 暗号化するためにAWS KMS Key moduleをInfra layerに作成
Step 3: AWS KMS moduleをResource layerに作成
Security: AWS IdentityのK8sへの認証(aws-auth configMap)と認可(RBAC: Clusterrolebinding)
(上級編)AWS IdentityのK8sへの認証・認可のおさらい
Step 1: まずはAWS IAM roles/users/accountsを `aws-auth` ConfigMapを使ってK8sクラスターに追加する方法
Step 2: `map_roles`ローカル変数を`data.tf`に定義、Infraレイヤーにパスダウン
Step 3: `map_roles`インプット変数をResource layerにパスダウン
Step 4: AWS IAM role `Developer`が`aws-auth` configmapに存在していないことをチェック
Step 5: Terraform apply
Step 6: `aws-auth` configmapに`Developer` AWS IAM roleが追加されていて、認証できるかチェック
Step 7: ClusterRoleBinding `k8s-developer`を作成し、K8sクラスター内でAWS Identityが認可が取れるかテスト
K8s taintとlabelをworker nodesに追加
Step 1: まずはWorker nodesの既存のtaintsとlabelsをチェック
Step 2: taintsとlabelsを追加
Step 3: Terraform apply
Step 4: マニュアルでEC2 worker nodesを再起動し、EC2にTaintとLabelをUserdataスクリプトから追加させる
K8s コントロールプレーン (Master Components)のLoggingを有効化
K8s コントロールプレーン (Master Components)のLoggingの概要
Step 1: まずはコントロールプレーンのログを有効化するための、resource moduleで必要なインプット変数を理解する
Step 2~4: `cluster_enabled_log_types`というインプット変数を、terraform.tfvarsで定義し、Infraへパス
Step 5: control planeのlogsが有効化されているかConsoleからチェック
(ベストプラクティス) Security: IRSA(IAM Role for Service Account)を使い、PodレベルのAWSへの認可を設定
IRSA(IAM Role for Service Account、またはPodレベルのIAM認可)アーキテクチャの解剖とおさらい
Step 1: まずはIRSAの3つのRequirementsを理解する
Step 2: (req1) OIDCプロバイダーを作成し、クラスターにアソシエイト
Step 3: `Composition` layerのterraform.tfvarsで、`enable_irsa`インプット変数をtrueに設定
Step 4~5: `enable_irsa`インプット変数をinfraからresource moduleへパスし、Terraform applyする
Step 6: (req2) NamespaceとServiceAccountとOIDCエンドポイントを指定したIAM assumable roleを作成
Step 7: IAM assumable roleとIAM policy modulesをinfrastructure layerで作成
Step 8: AWS Terraform module for IAMをresource module layerにコピー
Step 9: Terraform apply
Step 10: 作成されたAWS IAM roleがk8s namespaceとservice account名を含んでいるかチェック
Step 11: (req3) IAM roleをservice accountのAnnotationに追加し、IRSAをテスト
K8s worker nodesをCluster Autoscaler (CA)を使ってスケールアウト・ダウンする(AWS ASGに似ている)
Cluster Autoscalerの概要とおさらい
Step 1: (ch8で設定済み) K8sノードのlabelsとtaintsを設定
Step 2: Cluster Autoscalerのauto-discoveryをASGのTagで有効化する
Step 3: ASGのIAM パミッションを、cluster autoscalerにIRSA (Podレベル)で追加
Step 4: Cluster Autoscaler(CA)をHelm chartでインストール
Step 5: Cluster AutoscalerのIAM roleが正しいかチェック
Step 6: Metrics Serverをインストール
Step 7. CAのAuto Scalingをテスト
EFS (Elastic File System)をK8s Worker Nodes (EC2)に自動でマウントする
EFSの概要
Step 1: terraform.tfvarsで, EFSのファイルIDとマウントポイントを`/etc/fstab`ファイルに書き込むコマンドを指定する
Step 2: EFS moduleをinfrastructure layerに作成
Step 3: EFS resourceをResource layerで定義
Step 4: Terraform apply
Step 5: EFSがAuto-mountされてるかSSH接続してテスト
全てのAWSリソースをクリーンアップ
クリーンアップ
ボーナスレクチャー!
下のコメント欄にレビューを残していただけると最大20%割引クーポンを差し上げます!