Skip to content

Commit

Permalink
feat: allow providing own karpenter providers
Browse files Browse the repository at this point in the history
  • Loading branch information
mariogarcia committed Feb 6, 2024
1 parent 4456335 commit 75bc23e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions 1-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ variable "addons_karpenter_version" {
default = "v0.31.0"
}

variable "addons_karpenter_provisioners_path" {
type = string
description = "Karpenter's provisioners path"
}

variable "addons_argocd_version" {
type = string
description = "ArgoCD Helm Chart version"
Expand Down
1 change: 1 addition & 0 deletions 7-addons.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ module "karpenter" {
cluster_endpoint = module.cluster_eks.cluster_endpoint
cluster_oidc_provider_arn = module.cluster_eks.oidc_provider_arn
node_group_name = "inception"
provisioners_path = var.addons_karpenter_provisioners_path
}

module "eks-aws-load-balancer" {
Expand Down
11 changes: 8 additions & 3 deletions modules/karpenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ resource "time_sleep" "wait_after_helm_karpenter" {
}

resource "kubectl_manifest" "karpenter_default_node_template" {
yaml_body = templatefile("${path.module}/default-node.yaml", {
yaml_body = templatefile("${path.module}/nodes/default-node.yaml", {
cluster_name = var.cluster_name
instance_profile_name = module.karpenter.instance_profile_name
})
depends_on = [time_sleep.wait_after_helm_karpenter]
}

resource "kubectl_manifest" "karpenter_default_provider" {
yaml_body = file("${path.module}/default-provisioner.yaml")
data "kubectl_path_documents" "provisioners_path" {
pattern = var.provisioners_path != null ? "${var.provisioners_path}/*.yaml" : "${path.module}/provisioners/*.yaml"
}

resource "kubectl_manifest" "directory-yaml" {
for_each = data.kubectl_path_documents.provisioners_path.manifests
yaml_body = each.value
depends_on = [kubectl_manifest.karpenter_default_node_template]
}
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions modules/karpenter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ variable "timeout" {
type = number
description = "helm release timout (sec)"
default = 60
}

variable "provisioners_path" {
type = string
description = "path where to find provisioners' descriptors"
}

0 comments on commit 75bc23e

Please sign in to comment.