Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable auto-mode on eks #442

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,43 @@ resource "aws_eks_cluster" "cluster" {
}
}
}
# Compute Config (conditional setup for Auto Mode)
dynamic "compute_config" {
for_each = var.eks_auto_mode_enabled ? [1] : []
content {
enabled = true
node_pools = ["system"]
sohanyadav marked this conversation as resolved.
Show resolved Hide resolved
node_role_arn = aws_iam_role.node.arn
}
}
# Kubernetes Network Config (Auto Mode specific)
dynamic "kubernetes_network_config" {
for_each = var.eks_auto_mode_enabled ? [1] : []
content {
elastic_load_balancing {
enabled = true
}
}
}
# Storage Config (Auto Mode specific)
dynamic "storage_config" {
for_each = var.eks_auto_mode_enabled ? [1] : []
content {
block_storage {
enabled = true
}
}
}

enabled_cluster_log_types = var.cluster_logging

depends_on = [
aws_iam_role_policy_attachment.cluster-AmazonEKSClusterPolicy,
aws_iam_role_policy_attachment.cluster-AmazonEKSServicePolicy,
aws_iam_role_policy_attachment.cluster_AmazonEKSComputePolicy,
aws_iam_role_policy_attachment.cluster_AmazonEKSBlockStoragePolicy,
aws_iam_role_policy_attachment.cluster_AmazonEKSLoadBalancingPolicy,
aws_iam_role_policy_attachment.cluster_AmazonEKSNetworkingPolicy,
]

tags = local.tags
Expand Down Expand Up @@ -104,6 +136,26 @@ resource "aws_iam_role_policy_attachment" "cluster-AmazonEKSServicePolicy" {
role = aws_iam_role.cluster.name
}

resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSComputePolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSComputePolicy"
role = aws_iam_role.cluster.name
}

resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSLoadBalancingPolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSLoadBalancingPolicy"
role = aws_iam_role.cluster.name
}

resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSNetworkingPolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSNetworkingPolicy"
role = aws_iam_role.cluster.name
}

resource "aws_iam_role_policy_attachment" "cluster_AmazonEKSBlockStoragePolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSBlockStoragePolicy"
role = aws_iam_role.cluster.name
}

resource "helm_release" "calico" {
count = var.calico_enabled ? 1 : 0

Expand Down
5 changes: 5 additions & 0 deletions node_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ resource "aws_iam_role_policy_attachment" "node-AmazonEC2ContainerRegistryReadOn
role = aws_iam_role.node.name
}

resource "aws_iam_role_policy_attachment" "node_AmazonEKSWorkerNodeMinimalPolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodeMinimalPolicy"
role = aws_iam_role.node.name
}

resource "aws_iam_role_policy_attachment" "node_role_policies" {
count = length(var.node_role_policies)
policy_arn = var.node_role_policies[count.index]
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,8 @@ variable "s3_csi_bucket_names" {
default = [""]
}

variable "eks_auto_mode_enabled" {
description = "Enable Auto Mode for EKS cluster"
type = bool
default = true
}
Loading