mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-12 21:35:15 +01:00
feat!: Replace the use of aws-auth configmap with EKS cluster access entry (#2858)
* feat: Replace `resolve_conflicts` with `resolve_conflicts_on_create`/`delete`; raise MSV of AWS provider to `v5.0` to support * fix: Replace dynamic DNS suffix for `sts:AssumeRole` API calls for static suffix * feat: Add module tag * feat: Align Karpenter permissions with Karpenter v1beta1/v0.32 permissions from upstream * refactor: Move `aws-auth` ConfigMap functionality to its own sub-module * chore: Update examples * feat: Add state `moved` block for Karpenter Pod Identity role re-name * fix: Correct variable `create` description * feat: Add support for cluster access entries * chore: Bump MSV of Terraform to `1.3` * fix: Replace defunct kubectl provider with an updated forked equivalent * chore: Update and validate examples for access entry; clean up provider usage * docs: Correct double redundant variable descriptions * feat: Add support for Cloudwatch log group class argument * fix: Update usage tag placement, fix Karpenter event spelling, add upcoming changes section to upgrade guide * feat: Update Karpenter module to generalize naming used and align policy with the upstream Karpenter policy * feat: Add native support for Windows based managed nodegroups similar to AL2 and Bottlerocket * feat: Update self-managed nodegroup module to use latest features of ASG * docs: Update and simplify docs * fix: Correct variable description for AMI types * fix: Update upgrade guide with changes; rename Karpenter controller resource names to support migrating for users * docs: Complete upgrade guide docs for migration and changes applied * Update examples/karpenter/README.md Co-authored-by: Anton Babenko <anton@antonbabenko.com> * Update examples/outposts/README.md Co-authored-by: Anton Babenko <anton@antonbabenko.com> * Update modules/karpenter/README.md Co-authored-by: Anton Babenko <anton@antonbabenko.com> --------- Co-authored-by: Anton Babenko <anton@antonbabenko.com>
This commit is contained in:
@@ -36,21 +36,28 @@ $ terraform apply
|
||||
|
||||
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
|
||||
|
||||
```bash
|
||||
# Necessary to avoid removing Terraform's permissions too soon before its finished
|
||||
# cleaning up the resources it deployed inside the clsuter
|
||||
terraform state rm 'module.eks.aws_eks_access_entry.this["cluster_creator_admin"]' || true
|
||||
terraform destroy
|
||||
```
|
||||
|
||||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
## Requirements
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.57 |
|
||||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.10 |
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
||||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.20 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.57 |
|
||||
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.10 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
||||
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.20 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -80,7 +87,7 @@ Note that this example may create resources which cost money. Run `terraform des
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| <a name="output_aws_auth_configmap_yaml"></a> [aws\_auth\_configmap\_yaml](#output\_aws\_auth\_configmap\_yaml) | Formatted yaml output for base aws-auth configmap containing roles used in cluster node groups/fargate profiles |
|
||||
| <a name="output_access_entries"></a> [access\_entries](#output\_access\_entries) | Map of access entries created and their attributes |
|
||||
| <a name="output_cloudwatch_log_group_arn"></a> [cloudwatch\_log\_group\_arn](#output\_cloudwatch\_log\_group\_arn) | Arn of cloudwatch log group created |
|
||||
| <a name="output_cloudwatch_log_group_name"></a> [cloudwatch\_log\_group\_name](#output\_cloudwatch\_log\_group\_name) | Name of cloudwatch log group created |
|
||||
| <a name="output_cluster_addons"></a> [cluster\_addons](#output\_cluster\_addons) | Map of attribute maps for all EKS cluster addons enabled |
|
||||
|
||||
@@ -2,21 +2,9 @@ provider "aws" {
|
||||
region = var.region
|
||||
}
|
||||
|
||||
provider "kubernetes" {
|
||||
host = module.eks.cluster_endpoint
|
||||
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
|
||||
|
||||
exec {
|
||||
api_version = "client.authentication.k8s.io/v1beta1"
|
||||
command = "aws"
|
||||
# Note: `cluster_id` is used with Outposts for auth
|
||||
args = ["eks", "get-token", "--cluster-id", module.eks.cluster_id, "--region", var.region]
|
||||
}
|
||||
}
|
||||
|
||||
locals {
|
||||
name = "ex-${basename(path.cwd)}"
|
||||
cluster_version = "1.27" # Required by EKS on Outposts
|
||||
cluster_version = "1.29"
|
||||
|
||||
outpost_arn = element(tolist(data.aws_outposts_outposts.this.arns), 0)
|
||||
instance_type = element(tolist(data.aws_outposts_outpost_instance_types.this.instance_types), 0)
|
||||
@@ -41,6 +29,10 @@ module "eks" {
|
||||
cluster_endpoint_public_access = false # Not available on Outpost
|
||||
cluster_endpoint_private_access = true
|
||||
|
||||
# Gives Terraform identity admin access to cluster which will
|
||||
# allow deploying resources (EBS storage class) into the cluster
|
||||
enable_cluster_creator_admin_permissions = true
|
||||
|
||||
vpc_id = data.aws_vpc.this.id
|
||||
subnet_ids = data.aws_subnets.this.ids
|
||||
|
||||
@@ -49,9 +41,6 @@ module "eks" {
|
||||
outpost_arns = [local.outpost_arn]
|
||||
}
|
||||
|
||||
# Local clusters will automatically add the node group IAM role to the aws-auth configmap
|
||||
manage_aws_auth_configmap = true
|
||||
|
||||
# Extend cluster security group rules
|
||||
cluster_security_group_additional_rules = {
|
||||
ingress_vpc_https = {
|
||||
|
||||
@@ -47,6 +47,15 @@ output "cluster_primary_security_group_id" {
|
||||
value = module.eks.cluster_primary_security_group_id
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Access Entry
|
||||
################################################################################
|
||||
|
||||
output "access_entries" {
|
||||
description = "Map of access entries created and their attributes"
|
||||
value = module.eks.access_entries
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# KMS Key
|
||||
################################################################################
|
||||
@@ -200,12 +209,3 @@ output "self_managed_node_groups_autoscaling_group_names" {
|
||||
description = "List of the autoscaling group names created by self-managed node groups"
|
||||
value = module.eks.self_managed_node_groups_autoscaling_group_names
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Additional
|
||||
################################################################################
|
||||
|
||||
output "aws_auth_configmap_yaml" {
|
||||
description = "Formatted yaml output for base aws-auth configmap containing roles used in cluster node groups/fargate profiles"
|
||||
value = module.eks.aws_auth_configmap_yaml
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ locals {
|
||||
|
||||
module "ssm_bastion_ec2" {
|
||||
source = "terraform-aws-modules/ec2-instance/aws"
|
||||
version = "~> 4.2"
|
||||
version = "~> 5.5"
|
||||
|
||||
name = "${local.name}-bastion"
|
||||
|
||||
@@ -56,7 +56,7 @@ module "ssm_bastion_ec2" {
|
||||
rm terraform_${local.terraform_version}_linux_amd64.zip 2> /dev/null
|
||||
|
||||
# Install kubectl
|
||||
curl -LO https://dl.k8s.io/release/v1.27.0/bin/linux/amd64/kubectl
|
||||
curl -LO https://dl.k8s.io/release/v1.29.0/bin/linux/amd64/kubectl
|
||||
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||
|
||||
# Remove default awscli which is v1 - we want latest v2
|
||||
@@ -80,7 +80,7 @@ module "ssm_bastion_ec2" {
|
||||
|
||||
module "bastion_security_group" {
|
||||
source = "terraform-aws-modules/security-group/aws"
|
||||
version = "~> 4.0"
|
||||
version = "~> 5.0"
|
||||
|
||||
name = "${local.name}-bastion"
|
||||
description = "Security group to allow provisioning ${local.name} EKS local cluster on Outposts"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
required_version = ">= 1.3"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = ">= 4.57"
|
||||
version = ">= 5.34"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
required_version = ">= 1.3"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = ">= 4.57"
|
||||
version = ">= 5.34"
|
||||
}
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = ">= 2.10"
|
||||
version = ">= 2.20"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user