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

Set node affinity for more pods to ensure they run on general node pool #2353

Merged
merged 9 commits into from
Mar 21, 2024
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"
Copy link
Member Author

@Adam-D-Lewis Adam-D-Lewis Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fly by, removing commented out code

"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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to pass this is as a variable rather than hard code it (as in src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/main.tf)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't think we support renaming node pools so I'm fine adding this as is.

}
}
})

# 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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't think we support renaming node pools so I'm fine adding this as is.

}
})

# 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"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't think we support renaming node pools so I'm fine adding this as is.

}
]
}
]
}
}
}
})
], 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]
}
]
}
]
}
}
}
Comment on lines +560 to +576
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good

}
}
}
Expand Down
Loading