Skip to content

Commit

Permalink
Fixes for karpenter deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kvvit committed Sep 25, 2024
1 parent dde6003 commit e048984
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
18 changes: 10 additions & 8 deletions terraform/modules/k8s-karpenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ locals {
karpenter = {
name = try(var.helm.release_name, "karpenter")
enabled = true
chart = try(var.helm.chart_name, "karpenter")
repository = try(var.helm.repository, "oci://public.ecr.aws/karpenter")
chart = try(var.helm.chart_name, "oci://public.ecr.aws/karpenter/karpenter")
repository = try(var.helm.repository, "")
chart_version = try(var.helm.chart_version, "1.0.0")
namespace = try(var.helm.namespace, "karpenter")
}
Expand All @@ -19,6 +19,12 @@ serviceAccount:
annotations:
eks.amazonaws.com/role-arn: ${module.this[0].iam_role_arn}
postInstallHook:
image:
repository: bitnami/kubectl
tag: "1.30"
digest: sha256:c85f429088cea9ad968752e6d59e7edbc74b5750526f9a04531dce6b37f3ac87
controller:
resources:
requests:
Expand All @@ -30,8 +36,6 @@ controller:
VALUES
}

data "aws_ecrpublic_authorization_token" "token" {}

module "this" {
count = local.karpenter.enabled ? 1 : 0

Expand Down Expand Up @@ -66,7 +70,7 @@ resource "kubectl_manifest" "ec2nodeclass_private" {
count = local.karpenter.enabled ? 1 : 0

yaml_body = <<EOF
apiVersion: karpenter.sh/v1
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
name: private
Expand Down Expand Up @@ -98,7 +102,7 @@ resource "kubectl_manifest" "ec2nodeclass_public" {
count = local.karpenter.enabled ? 1 : 0

yaml_body = <<EOF
apiVersion: karpenter.sh/v1
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
name: public
Expand Down Expand Up @@ -144,8 +148,6 @@ resource "helm_release" "this" {
version = local.karpenter.chart_version
namespace = module.namespace[count.index].name
max_history = 3
repository_username = data.aws_ecrpublic_authorization_token.token.user_name
repository_password = data.aws_ecrpublic_authorization_token.token.password

values = [
local.karpenter_values
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions terragrunt/ACCOUNT_ID/us-east-1/demo/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ eks_karpenter_nodepools:

spec:
nodeClassRef:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: private

requirements:
Expand Down Expand Up @@ -68,6 +70,7 @@ eks_karpenter_nodepools:

disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 1m

limits:
cpu: "1000"
Expand All @@ -85,6 +88,8 @@ eks_karpenter_nodepools:

spec:
nodeClassRef:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: public

taints:
Expand Down Expand Up @@ -130,6 +135,7 @@ eks_karpenter_nodepools:

disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 1m

limits:
cpu: "1000"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e048984

Please sign in to comment.