Skip to content

Commit

Permalink
add autotaint
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavbuc committed Apr 15, 2024
1 parent d342e1e commit 4ba8f44
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
1 change: 1 addition & 0 deletions charts/karpenter_nodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Note - Most of the values can be overridden per nodegroup (If not specified, it
| `excludeInstanceSize` | Exclude specific instance sizes | `List` |||
| `headRoom` | Generate Ultra Low Priority Class for Headroom (see below) | `String` || x |
| `additionalRequirements` | add NodePool requirements which are not covered by this chart | `List(map)` |||
| `autoTaint` | add NodePool taint with `dedicated` as key and `nodepool` (`-` replaced with `_`) | `Boolean` |||

### NodeGroup Configuration
| Key Name | Description | Type | Optional? | Optional Per NodeGroup? |
Expand Down
10 changes: 2 additions & 8 deletions charts/karpenter_nodes/examples/nodegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ nodeGroups:
capacitySpread:
start: 1
end: 5
taints:
- key: "dedicated"
value: "workers"
effect: "NoSchedule"
autoTaint: true
nodes-workers-c:
nodeGroupLabel: nodes-workers
capacitySpread:
Expand All @@ -43,10 +40,7 @@ nodeGroups:
instances:
categories:
- c
taints:
- key: "dedicated"
value: "workers"
effect: "NoSchedule"
autoTaint: true
nodeClassRef:
name: nodes-workers-amd64
nodes-canary:
Expand Down
4 changes: 2 additions & 2 deletions charts/karpenter_nodes/examples/output/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1526,8 +1526,8 @@ spec:
name: nodes-workers-amd64
taints:
- key: dedicated
value: workers
effect: NoSchedule
value: nodes_workers
requirements:
- key: "karpenter.k8s.aws/instance-category"
operator: In
Expand Down Expand Up @@ -1641,8 +1641,8 @@ spec:
name: nodes-workers-amd64
taints:
- key: dedicated
value: workers
effect: NoSchedule
value: nodes_workers
requirements:
- key: "karpenter.k8s.aws/instance-category"
operator: In
Expand Down
9 changes: 8 additions & 1 deletion charts/karpenter_nodes/templates/nodepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ spec:
{{- else }}
name: {{ $k }}-{{ $v.instances.architecture | default $.Values.instances.architecture }}
{{- end }}
{{- if hasKey $v "taints" }}
{{- if or (hasKey $v "taints") ($v.autoTaint | default $.Values.autoTaint) }}
taints:
{{- if $v.autoTaint | default $.Values.autoTaint }}
- key: dedicated
effect: NoSchedule
value: {{ ($v.nodeGroupLabel | default $k) | replace "-" "_" }}
{{- end }}
{{- if hasKey $v "taints" }}
{{- range $v.taints }}
- key: {{ .key }}
value: {{ .value }}
effect: {{ .effect }}
{{- end }}
{{- end }}
{{- end }}
{{- if hasKey $v "startupTaints" }}
startupTaints:
Expand Down
4 changes: 2 additions & 2 deletions charts/karpenter_nodes/tests/nodepool_nodes_default_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tests:
value: taint1
- equal:
path: spec.template.spec.taints[0].effect
value: noSchedule
value: NoSchedule
- equal:
path: spec.template.spec.taints[1].key
value: testtaint2
Expand All @@ -45,7 +45,7 @@ tests:
value: taint2
- equal:
path: spec.template.spec.taints[1].effect
value: noSchedule
value: NoSchedule


- it: Verify nodes-default requirements
Expand Down
14 changes: 12 additions & 2 deletions charts/karpenter_nodes/tests/nodepool_nodes_workers_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tests:
value: taint1
- equal:
path: spec.template.spec.startupTaints[0].effect
value: noSchedule
value: NoSchedule
- equal:
path: spec.template.spec.startupTaints[1].key
value: testtaint2
Expand All @@ -47,7 +47,17 @@ tests:
value: taint2
- equal:
path: spec.template.spec.startupTaints[1].effect
value: noSchedule
value: NoSchedule
- equal:
path: spec.template.spec.taints[0].key
value: dedicated
- equal:
path: spec.template.spec.taints[0].value
value: nodes_workers
- equal:
path: spec.template.spec.taints[0].effect
value: NoSchedule


- it: Verify nodes-workers requirements
documentIndex: 2
Expand Down
9 changes: 5 additions & 4 deletions charts/karpenter_nodes/tests/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ nodeGroups:
testlabel2: label2
taints:
- key: testtaint1
effect: noSchedule
effect: NoSchedule
value: taint1
- key: testtaint2
effect: noSchedule
effect: NoSchedule
value: taint2
excludeFamilies:
- c6a
Expand Down Expand Up @@ -123,11 +123,12 @@ nodeGroups:
memory: "384Gi"
startupTaints:
- key: testtaint1
effect: noSchedule
effect: NoSchedule
value: taint1
- key: testtaint2
effect: noSchedule
effect: NoSchedule
value: taint2
autoTaint: true

#Default cluster Settings
clusterName: "eks-dev"
Expand Down
1 change: 1 addition & 0 deletions charts/karpenter_nodes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ instances:
operatingSystems:
- linux

autoTaint: false
## Exclude weak types of AMD instances
# excludeFamilies:
# - c6a
Expand Down

0 comments on commit 4ba8f44

Please sign in to comment.