Skip to content

Commit

Permalink
Added support for karpenter helm (#260)
Browse files Browse the repository at this point in the history
* Karpenter Helm Chart - includes prerequisites - IAM_Role, Tagging, AWS_AUth as well

* Update values.yaml

Updated Values.yaml

* Added Dependency Chart, updated values.yaml

* Added template folder

* Removed extra Files

* Incorporated Review Comments

* Added nodePool YAML template , modified values yaml

* Added functionality to loop over different node pools

Signed-off-by: Abhishek Dubey <[email protected]>

---------

Signed-off-by: Abhishek Dubey <[email protected]>
Co-authored-by: Abhishek Dubey <[email protected]>
  • Loading branch information
hiteshmakol1 and iamabhishek-dubey authored Dec 30, 2024
1 parent b84aaf4 commit 088280e
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
68 changes: 68 additions & 0 deletions charts/karpenter/templates/node-pool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- range .Values.nodePools }}
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: {{ .name }}
spec:
template:
metadata:
labels:
{{- if .labels }}
{{- range $key, $value := .labels }}
{{ $key }}: {{ $value }}
{{- end }}
{{- else }}
{} # Empty labels object if no labels are defined
{{- end }}
annotations:
{{- if .annotations }}
{{- range $key, $value := .annotations }}
{{ $key }}: {{ $value }}
{{- end }}
{{- else }}
{} # Empty annotations object if no annotations are defined
{{- end }}
spec:
requirements:
{{- if .requirements | len }}
{{- range .requirements }}
- key: {{ .key }}
operator: {{ .operator }}
values:
{{ toYaml .values | indent 12 }}
{{- if .minValues }}
minValues: {{ .minValues }}
{{- end }}
{{- end }}
{{- else }}
[] # In case requirements is empty, an empty array will be passed
{{- end }}

taints:
{{- if .taints }}
{{- range .taints }}
- key: {{ .key }}
{{- if .value }}
value: {{ .value }}
{{- end }}
effect: {{ .effect }}
{{- end }}
{{- else }}
[] # Empty taints array if no taints are defined
{{- end }}
nodeClassRef:
group: {{ .nodeClass.group | default "karpenter.k8s.aws" }}
kind: {{ .nodeClass.kind | default "EC2NodeClass" }}
name: {{ .nodeClass.name }}
expireAfter: {{ .expireAfter | default "720h" }}
limits:
{{- if .limits.cpu }}
cpu: {{ .limits.cpu }}
{{- end }}
{{- if .limits.memory }}
memory: {{ .limits.memory }}
{{- end }}
disruption:
consolidationPolicy: {{ .disruption.consolidationPolicy | default "WhenEmptyOrUnderutilized" }}
consolidateAfter: {{ .disruption.consolidateAfter | default "1m" }}
{{- end }}
66 changes: 66 additions & 0 deletions charts/karpenter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,69 @@ karpenter:
cpu: "1"
memory: "1Gi"

# Node Pool Configuration
nodePools:
- name: default
expireAfter: 720h
labels:
billing-team: my-team
environment: production
annotations:
example.com/owner: "my-team"
example.com/maintainer: "[email protected]"
limits:
cpu: "1000"
memory: "1000Gi"
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 1m
nodeClass:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: default
taints:
- key: "example.com/special-taint"
value: "my-value"
effect: "NoSchedule"
- key: "example.com/another-taint"
effect: "NoExecute"
requirements:
- key: kubernetes.io/arch
operator: In
values:
- "amd64"
- key: kubernetes.io/os
operator: In
values:
- "linux"
- key: karpenter.sh/capacity-type
operator: In
values:
- "on-demand"
- key: karpenter.k8s.aws/instance-category
operator: In
values:
- "t"
- "m"
- "r"
minValues: 2
- key: karpenter.k8s.aws/instance-family
operator: Exists
minValues: 5
- key: karpenter.k8s.aws/instance-family
operator: In
values:
- "m5"
- "m5d"
- "c5"
- "c5d"
- "c4"
- "r4"
minValues: 3
- key: node.kubernetes.io/instance-type
operator: Exists
minValues: 10
- key: karpenter.k8s.aws/instance-generation
operator: Gt
values:
- "2"

0 comments on commit 088280e

Please sign in to comment.