AWS EKS(Kubernetes)リソースを作成するTerraformモジュール
ここで定義されたモジュールを構成および利用するための包括的なドキュメントスイート、およびEKS(EKS管理対象ノードグループ、自己管理対象ノードグループ、Fargateプロファイルを含む)および/またはKubernetes機能に関するドキュメントの提供に努めていることに注意してください。 、使用法などは、それぞれのソースに任せたほうがよいでしょう。
一般的なアドオン/コントローラーのデプロイを容易にするために、サービスアカウント(IRSA)サブモジュールのIAMロールが作成されました。ユーザーは、IRSAに必要なフェデレーションロールの前提条件を使用してカスタムIAMロールを作成し、アドオン/コントローラーに必要な関連ポリシーを見つけて作成する代わりに、数行のコードでIRSAロールとポリシーを作成できます。terraform-aws-iam/examples/iam-role-for-service-accounts
IRSAサブモジュールをこの(
terraform-aws-eks)モジュールと組み合わせて使用する方法の例については、ディレクトリを参照してください。
現在サポートされているアドオン/コントローラーポリシーには、次のものがあります。
プロジェクトに追加されるサポートされているアドオン/コントローラーポリシーの現在のリストについては、terraform-aws-iam / modules/iam-role-for-service-accountsを参照してください。
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 18.0"
cluster_name = "my-cluster"
cluster_version = "1.21"
cluster_endpoint_private_access = true
cluster_endpoint_public_access = true
cluster_addons = {
coredns = {
resolve_conflicts = "OVERWRITE"
}
kube-proxy = {}
vpc-cni = {
resolve_conflicts = "OVERWRITE"
}
}
cluster_encryption_config = [{
provider_key_arn = "ac01234b-00d9-40f6-ac95-e42345f78b00"
resources = ["secrets"]
}]
vpc_id = "vpc-1234556abcdef"
subnet_ids = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
# Self Managed Node Group(s)
self_managed_node_group_defaults = {
instance_type = "m6i.large"
update_launch_template_default_version = true
iam_role_additional_policies = [
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
]
}
self_managed_node_groups = {
one = {
name = "mixed-1"
max_size = 5
desired_size = 2
use_mixed_instances_policy = true
mixed_instances_policy = {
instances_distribution = {
on_demand_base_capacity = 0
on_demand_percentage_above_base_capacity = 10
spot_allocation_strategy = "capacity-optimized"
}
override = [
{
instance_type = "m5.large"
weighted_capacity = "1"
},
{
instance_type = "m6i.large"
weighted_capacity = "2"
},
]
}
}
}
# EKS Managed Node Group(s)
eks_managed_node_group_defaults = {
disk_size = 50
instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
}
eks_managed_node_groups = {
blue = {}
green = {
min_size = 1
max_size = 10
desired_size = 1
instance_types = ["t3.large"]
capacity_type = "SPOT"
}
}
# Fargate Profile(s)
fargate_profiles = {
default = {
name = "default"
selectors = [
{
namespace = "default"
}
]
}
}
# aws-auth configmap
manage_aws_auth_configmap = true
aws_auth_roles = [
{
rolearn = "arn:aws:iam::66666666666:role/role1"
username = "role1"
groups = ["system:masters"]
},
]
aws_auth_users = [
{
userarn = "arn:aws:iam::66666666666:user/user1"
username = "user1"
groups = ["system:masters"]
},
{
userarn = "arn:aws:iam::66666666666:user/user2"
username = "user2"
groups = ["system:masters"]
},
]
aws_auth_accounts = [
"777777777777",
"888888888888",
]
tags = {
Environment = "dev"
Terraform = "true"
}
}
バグ修正と改善に貢献してくれたコミュニティに感謝します!参加方法については、以下をご覧ください。
名前 | バージョン |
---|---|
テラフォーム | > = 0.13.1 |
aws | > = 3.72 |
kubernetes | > = 2.10 |
tls | > = 3.0 |
名前 | バージョン |
---|---|
aws | > = 3.72 |
kubernetes | > = 2.10 |
tls | > = 3.0 |
名前 | ソース | バージョン |
---|---|---|
eks_managed_node_group | ./modules/eks-managed-node-group | 該当なし |
fargate_profile | ./modules/fargate-profile | 該当なし |
self_managed_node_group | ./modules/self-managed-node-group | 該当なし |
名前 | 説明 | タイプ | デフォルト | 必須 |
---|---|---|---|---|
attach_cluster_encryption_policy | 提供された暗号化キーを利用するためにクラスターIAMロールに追加のポリシーを添付するかどうかを示します | bool |
true |
いいえ |
aws_auth_accounts | aws-authconfigmapに追加するアカウントマップのリスト | list(any) |
[] |
いいえ |
aws_auth_fargate_profile_pod_execution_role_arns | aws-authconfigmapに追加するFargateプロファイルポッド実行ロールARNのリスト | list(string) |
[] |
いいえ |
aws_auth_node_iam_role_arns_non_windows | aws-authconfigmapに追加するWindowsベース以外のノードIAMロールARNのリスト | list(string) |
[] |
いいえ |
aws_auth_node_iam_role_arns_windows | aws-authconfigmapに追加するWindowsベースのノードIAMロールARNのリスト | list(string) |
[] |
いいえ |
aws_auth_roles | aws-authconfigmapに追加するロールマップのリスト | list(any) |
[] |
いいえ |
aws_auth_users | aws-authconfigmapに追加するユーザーマップのリスト | list(any) |
[] |
いいえ |
cloudwatch_log_group_kms_key_id | KMSキーARNが設定されている場合、このキーは対応するロググループを暗号化するために使用されます。KMSキーに適切なキーポリシーがあることを確認してください(https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html) | string |
null |
いいえ |
cloudwatch_log_group_retention_in_days | ログイベントを保持する日数。デフォルトの保持-90日 | number |
90 |
いいえ |
cluster_additional_security_group_ids | クラスタコントロールプレーンにアタッチする、外部で作成された追加のセキュリティグループIDのリスト | list(string) |
[] |
いいえ |
cluster_addons | クラスターを有効にするクラスターアドオン構成のマップ。アドオン名は、マップキーにすることも、次のように設定することもできます。name |
any |
{} |
いいえ |
cluster_enabled_log_types | 有効にする必要のあるコントロールプレーンログのリスト。詳細については、Amazon EKSコントロールプレーンロギングのドキュメント(https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html)を参照してください。 | list(string) |
[ |
いいえ |
cluster_encryption_config | クラスタの暗号化構成を含む構成ブロック | list(object({ |
[] |
いいえ |
cluster_encryption_policy_description | 作成されたクラスター暗号化ポリシーの説明 | string |
"Cluster encryption policy to allow cluster role to utilize CMK provided" |
いいえ |
cluster_encryption_policy_name | 作成されたクラスター暗号化ポリシーで使用する名前 | string |
null |
いいえ |
cluster_encryption_policy_path | クラスター暗号化ポリシーパス | string |
null |
いいえ |
cluster_encryption_policy_tags | 作成されたクラスター暗号化ポリシーに追加する追加のタグのマップ | map(string) |
{} |
いいえ |
cluster_encryption_policy_use_name_prefix | cluster_encryption_policy_nameクラスタ暗号化ポリシー名( )をプレフィックスとして使用するかどうかを決定します |
string |
true |
いいえ |
cluster_endpoint_private_access | AmazonEKSプライベートAPIサーバーエンドポイントが有効になっているかどうかを示します | bool |
false |
いいえ |
cluster_endpoint_public_access | AmazonEKSパブリックAPIサーバーエンドポイントが有効になっているかどうかを示します | bool |
true |
いいえ |
cluster_endpoint_public_access_cidrs | AmazonEKSパブリックAPIサーバーエンドポイントにアクセスできるCIDRブロックのリスト | list(string) |
[ |
いいえ |
cluster_iam_role_dns_suffix | 現在のパーティションのベースDNSドメイン名(たとえば、AWS Commercialのamazonaws.com、AWS Chinaのamazonaws.com.cn) | string |
null |
いいえ |
cluster_identity_providers | クラスターを有効にするためのクラスターIDプロバイダー構成のマップ。注-これはIRSAとは異なります/別です | any |
{} |
いいえ |
cluster_ip_family | Kubernetesポッドとサービスアドレスの割り当てに使用されるIPファミリー。有効な値はipv4(デフォルト)と ipv6です。クラスターを作成するときにのみIPファミリーを指定できます。この値を変更すると、新しいクラスターが強制的に作成されます。 |
string |
null |
いいえ |
cluster_name | EKSクラスターの名前 | string |
"" |
いいえ |
cluster_security_group_additional_rules | 作成されたクラスターセキュリティグループに追加する追加のセキュリティグループルールのリスト。ソースとして設定source_node_security_group = trueするための内部ルールを設定します node_security_group |
any |
{} |
いいえ |
cluster_security_group_description | 作成されたクラスターセキュリティグループの説明 | string |
"EKS cluster security group" |
いいえ |
cluster_security_group_id | クラスタに接続する既存のセキュリティグループID。create_cluster_security_group=の場合に必要 false |
string |
"" |
いいえ |
cluster_security_group_name | 作成されたクラスターセキュリティグループで使用する名前 | string |
null |
いいえ |
cluster_security_group_tags | 作成されたクラスターセキュリティグループに追加する追加のタグのマップ | map(string) |
{} |
いいえ |
cluster_security_group_use_name_prefix | Determines whether cluster security group name (cluster_security_group_name) is used as a prefix |
string |
true |
no |
cluster_service_ipv4_cidr | The CIDR block to assign Kubernetes service IP addresses from. If you don't specify a block, Kubernetes assigns addresses from either the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks | string |
null |
no |
cluster_tags | A map of additional tags to add to the cluster | map(string) |
{} |
no |
cluster_timeouts | Create, update, and delete timeout configurations for the cluster | map(string) |
{} |
no |
cluster_version | Kubernetes <major>.<minor>version to use for the EKS cluster (i.e.: 1.21) |
string |
null |
no |
create | Controls if EKS resources should be created (affects nearly all resources) | bool |
true |
no |
create_aws_auth_configmap | Determines whether to create the aws-auth configmap. NOTE - this is only intended for scenarios where the configmap does not exist (i.e. - when using only self-managed node groups). Most users should use manage_aws_auth_configmap |
bool |
false |
no |
create_cloudwatch_log_group | Determines whether a log group is created by this module for the cluster logs. If not, AWS will automatically create one if logging is enabled | bool |
true |
no |
create_cluster_primary_security_group_tags | Indicates whether or not to tag the cluster's primary security group. This security group is created by the EKS service, not the module, and therefore tagging is handled after cluster creation | bool |
true |
no |
create_cluster_security_group | Determines if a security group is created for the cluster or use the existing cluster_security_group_id |
bool |
true |
no |
create_cni_ipv6_iam_policy | Determines whether to create an AmazonEKS_CNI_IPv6_Policy |
bool |
false |
no |
create_iam_role | Determines whether a an IAM role is created or to use an existing IAM role | bool |
true |
no |
create_node_security_group | Determines whether to create a security group for the node groups or use the existing node_security_group_id |
bool |
true |
no |
custom_oidc_thumbprints | Additional list of server certificate thumbprints for the OpenID Connect (OIDC) identity provider's server certificate(s) | list(string) |
[] |
no |
eks_managed_node_group_defaults | Map of EKS managed node group default configurations | any |
{} |
no |
eks_managed_node_groups | Map of EKS managed node group definitions to create | any |
{} |
no |
enable_irsa | Determines whether to create an OpenID Connect Provider for EKS to enable IRSA | bool |
true |
no |
fargate_profile_defaults | Map of Fargate Profile default configurations | any |
{} |
no |
fargate_profiles | Map of Fargate Profile definitions to create | any |
{} |
no |
iam_role_additional_policies | Additional policies to be added to the IAM role | list(string) |
[] |
no |
iam_role_arn | Existing IAM role ARN for the cluster. Required if create_iam_roleis set to false |
string |
null |
no |
iam_role_description | Description of the role | string |
null |
no |
iam_role_name | Name to use on IAM role created | string |
null |
no |
iam_role_path | Cluster IAM role path | string |
null |
no |
iam_role_permissions_boundary | ARN of the policy that is used to set the permissions boundary for the IAM role | string |
null |
no |
iam_role_tags | A map of additional tags to add to the IAM role created | map(string) |
{} |
no |
iam_role_use_name_prefix | Determines whether the IAM role name (iam_role_name) is used as a prefix |
bool |
true |
no |
manage_aws_auth_configmap | Determines whether to manage the aws-auth configmap | bool |
false |
no |
node_security_group_additional_rules | List of additional security group rules to add to the node security group created. Set source_cluster_security_group = trueinside rules to set the cluster_security_groupas source |
any |
{} |
no |
node_security_group_description | Description of the node security group created | string |
"EKS node shared security group" |
no |
node_security_group_id | 作成されたノードグループに接続する既存のセキュリティグループのID | string |
"" |
いいえ |
node_security_group_name | 作成されたノードセキュリティグループで使用する名前 | string |
null |
いいえ |
node_security_group_tags | 作成されたノードセキュリティグループに追加する追加のタグのマップ | map(string) |
{} |
いいえ |
node_security_group_use_name_prefix | node_security_group_nameノードセキュリティグループ名( )をプレフィックスとして使用するかどうかを決定します |
string |
true |
いいえ |
openid_connect_audiences | IRSAプロバイダーに追加するOpenIDConnectオーディエンスクライアントIDのリスト | list(string) |
[] |
いいえ |
prefix_separator | リソース名のプレフィックスと生成されたタイムスタンプの間に使用する区切り文字 | string |
"-" |
いいえ |
putin_khuylo | プーチンがウクライナの主権と領土保全を尊重しないことに同意しますか?詳細:https ://en.wikipedia.org/wiki/Putin_khuylo ! | bool |
true |
いいえ |
self_managed_node_group_defaults | 自己管理ノードグループのデフォルト構成のマップ | any |
{} |
いいえ |
self_managed_node_groups | 作成する自己管理ノードグループ定義のマップ | any |
{} |
いいえ |
サブネットID | EKSクラスター(ENI)がノード/ノードグループとともにプロビジョニングされるサブネットIDのリスト。ノードグループは、ノードグループ構成内から異なるサブネットIDのセット内に展開できます | list(string) |
[] |
いいえ |
タグ | すべてのリソースに追加するタグのマップ | map(string) |
{} |
いいえ |
vpc_id | クラスタとそのノードがプロビジョニングされるVPCのID | string |
null |
いいえ |
名前 | 説明 |
---|---|
aws_auth_configmap_yaml | [var.manage_aws_auth_configmap非推奨-use]クラスターノードグループ/ファーゲートプロファイルで使用されるロールを含むベースaws-authconfigmapのフォーマットされたyaml出力 |
cloudwatch_log_group_arn | 作成されたcloudwatchロググループのArn |
cloudwatch_log_group_name | 作成されたcloudwatchロググループの名前 |
cluster_addons | 有効になっているすべてのEKSクラスターアドオンの属性マップのマップ |
cluster_arn | クラスタのAmazonリソース名(ARN) |
cluster_certificate_authority_data | クラスタとの通信に必要なBase64でエンコードされた証明書データ |
cluster_endpoint | KubernetesAPIサーバーのエンドポイント |
cluster_iam_role_arn | EKSクラスターのIAMロールARN |
cluster_iam_role_name | EKSクラスターのIAMロール名 |
cluster_iam_role_unique_id | IAMの役割を識別する安定した一意の文字列 |
cluster_id | EKSクラスターの名前/ID。クラスターの準備が整うまで、クラスターの作成をブロックします |
cluster_identity_providers | 有効になっているすべてのEKSIDプロバイダーの属性マップのマップ |
cluster_oidc_issuer_url | OpenIDConnectIDプロバイダーのEKSクラスター上のURL |
cluster_platform_version | クラスターのプラットフォームバージョン |
cluster_primary_security_group_id | クラスター用にAmazonEKSによって作成されたクラスターセキュリティグループ。管理対象ノードグループは、このセキュリティグループをコントロールプレーンからデータプレーンへの通信に使用します。EKSコンソールでは「クラスタセキュリティグループ」と呼ばれます |
cluster_security_group_arn | クラスタセキュリティグループのAmazonResourceName(ARN) |
cluster_security_group_id | クラスタセキュリティグループのID |
cluster_status | EKSクラスターのステータス。、、、CREATINGのいずれ ACTIVEか DELETING FAILED |
cluster_version | クラスタのKubernetesバージョン |
eks_managed_node_groups | 作成されたすべてのEKS管理対象ノードグループの属性マップのマップ |
eks_managed_node_groups_autoscaling_group_names | EKS管理対象ノードグループによって作成された自動スケーリンググループ名のリスト |
fargate_profiles | 作成されたすべてのEKSファーゲートプロファイルの属性マップのマップ |
node_security_group_arn | ノード共有セキュリティグループのAmazonResourceName(ARN) |
node_security_group_id | ノード共有セキュリティグループのID |
oidc_provider | OpenID Connect IDプロバイダー(先頭のない発行者URL https://) |
oidc_provider_arn | OIDCプロバイダーのARNenable_irsa = true |
self_managed_node_groups | 作成されたすべての自己管理ノードグループの属性マップのマップ |
self_managed_node_groups_autoscaling_group_names | 自己管理ノードグループによって作成された自動スケーリンググループ名のリスト |
Apache2ライセンス。詳細については、ライセンスを参照してください。