Skip to content

Commit

Permalink
Merge pull request #1 from SCT-Engineering/mcmCluster
Browse files Browse the repository at this point in the history
Updates from integration
  • Loading branch information
nangu001 committed Jul 30, 2024
2 parents 65552fb + 2b207de commit 3f6dfdb
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 31 deletions.
22 changes: 22 additions & 0 deletions EC2NodePool.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
name: default
spec:
template:
spec:
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["spot", "on-demand"]
- key: "node.kubernetes.io/instance-type"
operator: In
values: ["t3a.xlarge", "t3.xlarge", "c5.large", "m5.large", "r5.large", "m5.xlarge"]
nodeClassRef:
name: default
limits:
cpu: 1000
memory: 1000Gi
disruption:
consolidationPolicy: WhenUnderutilized
expireAfter: 24h # 30 * 24h = 720h
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ NOTE: Deploying Karpenter after deploying Istio is not recommended because it di
The module deploys Karpenter needed AWS resources, namely in IAM. It copies the Karpenter controller from the public registry to local ECR, deploys Karpenter via Helm and deploys a single default Karpenter Nodepool with EC2NodeClass.

# CHANGELOG

* 0.0.2 -- 2024-07-30
- update after removing cluster-autoscaler
- add second yaml template
- update images module
* 0.0.1 -- 2024-07-26
- Genesis/Initial development

Expand Down Expand Up @@ -71,4 +74,4 @@ The module deploys Karpenter needed AWS resources, namely in IAM. It copies the
## Outputs

No outputs.
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS -->
6 changes: 5 additions & 1 deletion copy_images.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ locals {
# map[repository:224384469011.dkr.ecr.us-gov-east-1.amazonaws.com/platform-test-1/karpenter tag:0.37.0]

module "images" {
source = "git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git/?ref=2.0.2"
source = "git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git/?ref=tf-upgrade"

profile = var.profile
application_name = var.cluster_name
image_config = local.image_config
tags = {}

enable_lifecycle_policy = true
lifecycle_policy_all = true
force_delete = true
}
29 changes: 2 additions & 27 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
# Replicating from here: https://github.e.it.census.gov/SCT-Engineering/terraform-aws-eks/tree/master/modules/karpenter
# Karpenter IRSA roles and policies
module "karpenter_resources" {
source = "git@github.e.it.census.gov:SCT-Engineering/terraform-aws-eks.git//modules/karpenter?ref=v20.8.5"
source = "git@github.e.it.census.gov:SCT-Engineering/terraform-aws-eks.git//modules/karpenter?ref=v20.20.0"

cluster_name = var.cluster_name
enable_irsa = true
Expand All @@ -32,7 +32,6 @@ resource "helm_release" "karpenter" {
depends_on = [
module.images,
]

name = "karpenter"
chart = "karpenter"
version = var.karpenter_helm_chart
Expand Down Expand Up @@ -166,29 +165,5 @@ resource "kubectl_manifest" "karpenter_NodePool" {
depends_on = [
kubectl_manifest.karpenter_EC2NodeClass,
]

yaml_body = <<YAML
apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
name: default
spec:
template:
spec:
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["spot", "on-demand"]
- key: "node.kubernetes.io/instance-type"
operator: In
values: ["t3a.xlarge", "t3.xlarge", "c5.large", "m5.large", "r5.large", "m5.xlarge"]
nodeClassRef:
name: default
limits:
cpu: 1000
memory: 1000Gi
disruption:
consolidationPolicy: WhenUnderutilized
expireAfter: 720h # 30 * 24h = 720h
YAML
yaml_body = templatefile("${path.module}/EC2NodePool.yaml.tpl", {})
}
13 changes: 13 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
################################################################################
# Module information
################################################################################

output "module_name" {
description = "The name of this module."
value = local._module_name
}

output "module_version" {
description = "The version of this module."
value = local._module_version
}
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ variable "tags" {
description = "AWS Tags to apply to appropriate resources"
type = map(string)
default = {}
}
}
4 changes: 4 additions & 0 deletions version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
_module_name = "tfmod-karpenter"
_module_version = "0.0.2"
}

0 comments on commit 3f6dfdb

Please sign in to comment.