Skip to content

Commit

Permalink
Set node affinity for more pods to ensure they run on general node po…
Browse files Browse the repository at this point in the history
…ol (#2353)

Co-authored-by: Scott Blair <sblair@metrostar.com>
  • Loading branch information
Adam-D-Lewis and sblair-metrostar authored Mar 21, 2024
1 parent f1e37c2 commit 3b318a6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ resource "aws_eks_node_group" "main" {
]

tags = merge({
# "kubernetes.io/cluster/${var.name}" = "shared"
"k8s.io/cluster-autoscaler/node-template/label/dedicated" = var.node_groups[count.index].name
propagate_at_launch = true
}, var.tags)
Expand All @@ -69,9 +68,36 @@ data "aws_eks_cluster_auth" "main" {

resource "aws_eks_addon" "aws-ebs-csi-driver" {
# required for Kubernetes v1.23+ on AWS
addon_name = "aws-ebs-csi-driver"
cluster_name = aws_eks_cluster.main.name
resolve_conflicts = "OVERWRITE"
addon_name = "aws-ebs-csi-driver"
cluster_name = aws_eks_cluster.main.name
resolve_conflicts_on_create = "OVERWRITE"
resolve_conflicts_on_update = "OVERWRITE"

configuration_values = jsonencode({
controller = {
nodeSelector = {
"eks.amazonaws.com/nodegroup" = "general"
}
}
})

# Ensure cluster and node groups are created
depends_on = [
aws_eks_cluster.main,
aws_eks_node_group.main,
]
}

resource "aws_eks_addon" "coredns" {
addon_name = "coredns"
cluster_name = aws_eks_cluster.main.name

configuration_values = jsonencode({
nodeSelector = {
"eks.amazonaws.com/nodegroup" = "general"
}
})

# Ensure cluster and node groups are created
depends_on = [
aws_eks_cluster.main,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resource "aws_vpc" "main" {

enable_dns_support = true
enable_dns_hostnames = true
enable_classiclink = false

tags = merge({ Name = var.name }, var.tags, var.vpc_tags)
}
Expand Down
2 changes: 1 addition & 1 deletion src/_nebari/stages/infrastructure/template/aws/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.73.0"
version = "5.33.0"
}
}
required_version = ">= 1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ resource "helm_release" "autoscaler" {
clusterName = var.cluster-name
enabled = true
}

affinity = {
nodeAffinity = {
requiredDuringSchedulingIgnoredDuringExecution = {
nodeSelectorTerms = [
{
matchExpressions = [
{
key = "eks.amazonaws.com/nodegroup"
operator = "In"
values = ["general"]
}
]
}
]
}
}
}
})
], var.overrides)
}
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,23 @@ resource "kubernetes_manifest" "deployment_admission_controller" {
}
},
]
affinity = {
nodeAffinity = {
requiredDuringSchedulingIgnoredDuringExecution = {
nodeSelectorTerms = [
{
matchExpressions = [
{
key = var.node-group.key
operator = "In"
values = [var.node-group.value]
}
]
}
]
}
}
}
}
}
}
Expand Down

0 comments on commit 3b318a6

Please sign in to comment.