Skip to content

Commit

Permalink
Merge pull request #118 from kloia/karpenter-windows-container
Browse files Browse the repository at this point in the history
Karpenter-windows-container
  • Loading branch information
ahmetayd authored Nov 30, 2023
2 parents 668386d + ad850bb commit da779bd
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 3 deletions.
194 changes: 192 additions & 2 deletions aws-eks-addons/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,6 @@ resource "kubectl_manifest" "karpenter_stateless_provisioner" {
]
}



resource "kubectl_manifest" "karpenter_node_template" {
count = var.deploy_karpenter ? 1 : 0
yaml_body = <<-YAML
Expand Down Expand Up @@ -758,3 +756,195 @@ resource "kubectl_manifest" "karpenter_node_template" {
helm_release.karpenter[0]
]
}

resource "kubectl_manifest" "karpenter_windows_with_aws_cni" {
count = var.karpenter_windows_support ? 1 : 0
yaml_body = <<YAML
apiVersion: v1
kind: ConfigMap
metadata:
name: amazon-vpc-cni
namespace: kube-system
data:
enable-windows-ipam: "true"
YAML
depends_on = [helm_release.karpenter]
}

resource "kubectl_manifest" "karpenter_stateless_windows2019_provisioner" {
count = var.karpenter_windows_support ? 1 : 0
yaml_body = yamlencode({
apiVersion: "karpenter.sh/v1alpha5"
kind: "Provisioner"
metadata: {
name: "stateless-windows2019-provisioner"
}
spec: {
ttlSecondsAfterEmpty = 30
providerRef = {
name = "windows2019"
}
limits = {
resources = {
cpu = var.stateless_total_cpu_limit
}
}
requirements: [
{
key = "karpenter.sh/capacity-type"
operator = "In"
values = var.stateless_windows_capacity_types
},
{
key = "node.kubernetes.io/instance-type"
operator = "In"
values = var.stateless_windows_instance_types
},
{
key = "topology.kubernetes.io/zone"
operator = "In"
values = var.stateless_instance_zones
},
{
key = "kubernetes.io/arch"
operator = "In"
values = var.stateless_windows_arch_types
},
{
key = "kubernetes.io/os"
operator = "In"
values = [
"windows",
]
},
]
}
})
depends_on = [
helm_release.karpenter[0]
]
}

resource "kubectl_manifest" "karpenter_stateless_windows2022_provisioner" {
count = var.karpenter_windows_support ? 1 : 0
yaml_body = yamlencode({
apiVersion: "karpenter.sh/v1alpha5"
kind: "Provisioner"
metadata: {
name: "stateless-windows2022-provisioner"
}
spec: {
ttlSecondsAfterEmpty = 30
providerRef = {
name = "windows2022"
}
limits = {
resources = {
cpu = var.stateless_total_cpu_limit
}
}
requirements: [
{
key = "karpenter.sh/capacity-type"
operator = "In"
values = var.stateless_windows_capacity_types
},
{
key = "node.kubernetes.io/instance-type"
operator = "In"
values = var.stateless_windows_instance_types
},
{
key = "topology.kubernetes.io/zone"
operator = "In"
values = var.stateless_instance_zones
},
{
key = "kubernetes.io/arch"
operator = "In"
values = var.stateless_windows_arch_types
},
{
key = "kubernetes.io/os"
operator = "In"
values = [
"windows",
]
},
]
}
})
depends_on = [
helm_release.karpenter[0]
]
}

resource "kubectl_manifest" "karpenter_windows2019_node_template" {
count = var.karpenter_windows_support ? 1 : 0
yaml_body = <<-YAML
apiVersion: karpenter.k8s.aws/v1alpha1
kind: AWSNodeTemplate
metadata:
name: windows2019
spec:
blockDeviceMappings:
- deviceName: /dev/xvda
ebs:
volumeSize: ${var.karpenter_node_template_volume_size}
volumeType: ${var.karpenter_node_template_volume_type}
iops: ${var.karpenter_node_template_volume_iops}
deleteOnTermination: ${var.karpenter_node_template_delete_on_termination}
throughput: ${var.karpenter_node_template_throughput}
subnetSelector:
karpenter.sh/discovery: "true"
securityGroupSelector:
karpenter.sh/discovery: ${var.cluster_name}
tags:
karpenter.sh/discovery: ${var.cluster_name}
amiFamily: Windows2019
metadataOptions:
httpEndpoint: enabled
httpProtocolIPv6: disabled
httpPutResponseHopLimit: 2
httpTokens: required
YAML

depends_on = [
helm_release.karpenter[0]
]
}

resource "kubectl_manifest" "karpenter_windows2022_node_template" {
count = var.karpenter_windows_support ? 1 : 0
yaml_body = <<-YAML
apiVersion: karpenter.k8s.aws/v1alpha1
kind: AWSNodeTemplate
metadata:
name: windows2022
spec:
blockDeviceMappings:
- deviceName: /dev/xvda
ebs:
volumeSize: ${var.karpenter_node_template_volume_size}
volumeType: ${var.karpenter_node_template_volume_type}
iops: ${var.karpenter_node_template_volume_iops}
deleteOnTermination: ${var.karpenter_node_template_delete_on_termination}
throughput: ${var.karpenter_node_template_throughput}
subnetSelector:
karpenter.sh/discovery: "true"
securityGroupSelector:
karpenter.sh/discovery: ${var.cluster_name}
tags:
karpenter.sh/discovery: ${var.cluster_name}
amiFamily: Windows2022
metadataOptions:
httpEndpoint: enabled
httpProtocolIPv6: disabled
httpPutResponseHopLimit: 2
httpTokens: required
YAML

depends_on = [
helm_release.karpenter[0]
]
}
30 changes: 29 additions & 1 deletion aws-eks-addons/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -231,25 +231,42 @@ variable "stateful_capacity_types" { # +
type = list(string)
}


variable "stateless_capacity_types" {
description = "instance types"
default = ["spot"]
type = list(string)
}

variable "stateless_windows_capacity_types" {
description = "instance types"
default = ["spot"]
type = list(string)
}

variable "stateful_instance_types" {
description = "instance types"
default = ["r6a.xlarge", "r6a.2xlarge", "r6a.4xlarge","r6a.9xlarge"]
type = list(string)
}

variable "stateful_windows_instance_types" {
description = "instance types"
default = ["r6a.xlarge", "r6a.2xlarge", "r6a.4xlarge","r6a.9xlarge"]
type = list(string)
}

variable "stateless_instance_types" {
description = "instance types"
default = ["c5n.xlarge", "c5n.2xlarge", "c5n.4xlarge","c5n.9xlarge"]
type = list(string)
}

variable "stateless_windows_instance_types" {
description = "instance types"
default = ["c5n.xlarge", "c5n.2xlarge", "c5n.4xlarge","c5n.9xlarge"]
type = list(string)
}

variable "stateful_instance_zones" {
description = "instance types"
default = ["eu-west-1a"]
Expand All @@ -274,6 +291,12 @@ variable "stateless_arch_types" {
type = list(string)
}

variable "stateless_windows_arch_types" {
description = "instance types"
default = ["amd64"]
type = list(string)
}

variable "stateful_application_toleration_value" {
description = "stateful application tolerance value for scheduling"
default = "stateful-application"
Expand Down Expand Up @@ -355,4 +378,9 @@ variable "aws_lb_controller_version" {
variable "karpenter_version" {
description = "Karpenter version"
default = "v0.31.1"
}

variable "karpenter_windows_support" {
default = false
description = "Karpenter Windows Container Support"
}

0 comments on commit da779bd

Please sign in to comment.