-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(NO_CARD): add default provisioner & nodeTemplate
- Loading branch information
1 parent
d0ea02a
commit b39bb84
Showing
3 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
resource "kubectl_manifest" "aws_node_template" { | ||
count = var.create && var.create_kubernetes_resources && var.create_aws_node_template ? 1 : 0 | ||
|
||
yaml_body = try(var.aws_node_template.yaml_body, <<-YAML | ||
apiVersion: karpenter.k8s.aws/v1alpha1 | ||
kind: AWSNodeTemplate | ||
metadata: | ||
name: default | ||
spec: | ||
subnetSelector: | ||
aws-ids: "${join(",", var.subnet_ids)}" | ||
securityGroupSelector: | ||
karpenter.sh/discovery: ${var.cluster_name} | ||
tags: | ||
karpenter.sh/discovery: ${var.cluster_name} | ||
YAML | ||
) | ||
|
||
depends_on = [ | ||
module.eks_blueprints_addons[0].karpenter | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
resource "kubectl_manifest" "provisioner" { | ||
count = var.create && var.create_kubernetes_resources && var.create_provisioner ? 1 : 0 | ||
|
||
yaml_body = try(var.provisioner.yaml_body, <<-YAML | ||
apiVersion: karpenter.sh/v1alpha5 | ||
kind: Provisioner | ||
metadata: | ||
name: ${var.cluster_name}-default | ||
spec: | ||
requirements: | ||
- key: "topology.kubernetes.io/zone" | ||
operator: In | ||
values: ${jsonencode(var.availability_zones)} | ||
- key: karpenter.k8s.aws/instance-category | ||
operator: In | ||
values: ["c", "m", "r"] | ||
- key: karpenter.k8s.aws/instance-generation | ||
operator: Gt | ||
values: ["2"] | ||
- key: kubernetes.io/arch | ||
operator: In | ||
values: ["arm64", "amd64"] | ||
- key: "karpenter.sh/capacity-type" # If not included, the webhook for the AWS cloud provider will default to on-demand | ||
operator: In | ||
values: ["spot", "on-demand"] | ||
kubeletConfiguration: | ||
containerRuntime: containerd | ||
maxPods: 110 | ||
limits: | ||
resources: | ||
cpu: 1000 | ||
consolidation: | ||
enabled: true | ||
providerRef: | ||
name: default | ||
ttlSecondsUntilExpired: 2592000 # 30 Days = 60 * 60 * 24 * 30 Seconds | ||
YAML | ||
) | ||
|
||
depends_on = [ | ||
module.eks_blueprints_addons[0].karpenter | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
variable "env" { | ||
description = "Environnement where the stack is running" | ||
type = string | ||
} | ||
|
||
variable "service" { | ||
description = "Service using this module" | ||
type = string | ||
} | ||
|
||
variable "cluster_name" { | ||
description = "Name of the EKS cluster" | ||
type = string | ||
} | ||
|
||
variable "cluster_endpoint" { | ||
description = "Endpoint for your Kubernetes API server" | ||
type = string | ||
} | ||
|
||
variable "cluster_version" { | ||
description = "Kubernetes `<major>.<minor>` version to use for the EKS cluster (i.e.: `1.24`)" | ||
type = string | ||
} | ||
|
||
variable "oidc_provider_arn" { | ||
description = "The ARN of the cluster OIDC Provider" | ||
type = string | ||
} | ||
|
||
variable "create" { | ||
description = "Controls if resources should be created (affects all resources)" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "karpenter" { | ||
description = "Karpenter add-on configuration values" | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "create_aws_node_template" { | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "subnet_ids" { | ||
type = list(string) | ||
} | ||
|
||
variable "aws_node_template" { | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "create_provisioner" { | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "availability_zones" { | ||
type = list(string) | ||
} | ||
|
||
variable "provisioner" { | ||
description = "Provisioner configuration values" | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "create_delay_dependencies" { | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "create_kubernetes_resources" { | ||
type = bool | ||
default = true | ||
} |