Skip to content

Commit

Permalink
Merge pull request #10 from fiverr/no_other_requirements_if_instanceT…
Browse files Browse the repository at this point in the history
…ypes

No other requirements if instance types
  • Loading branch information
nadavbuc authored Apr 24, 2024
2 parents e3e925a + a881c6b commit d13b245
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 108 deletions.
2 changes: 1 addition & 1 deletion charts/karpenter_nodes/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: karpenter_nodes
version: 1.0.0
version: 1.0.1
description: A Helm chart for generating NodeClasses and NodePools for Karpenter
maintainers:
- name: nadavbuc
1 change: 1 addition & 0 deletions charts/karpenter_nodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Note - Most of the values can be overridden per nodegroup (If not specified, it
| `instances.cores` | Allowed cores per instance (`"4"`, `"8"`) | `List(String(int))` | x ||
| `instances.capacityType` | `spot`, `on-demand` (can use both on single provisioner) | `List(String)` | x ||
| `instances.operatingSystems` | Allowed operating systems (`"linux"`, `"windows"`) | `List(String)` | x ||
| `instances.instanceTypes` | Explicit list of instance types to use (ie `m7i.xlarge`) This will ignore all sizing related requirements | `List(String)` | x ||
| `availabilityZones` | Availability Zones to use | `List(String)` | x ||
| `expireAfter` | Specify how long node should be up before refreshing it [Documentation](https://karpenter.sh/docs/concepts/disruption/#automated-methods) | `String` | x ||
| `weight` | Specify NodeGroup Weight (default is `1`) | `Integer` | x ||
Expand Down
2 changes: 1 addition & 1 deletion charts/karpenter_nodes/examples/argocd_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
sources:
- repoURL: 'https://opensource.fiverr.com/public_charts/'
chart: karpenter_nodes
targetRevision: 1.0.0
targetRevision: 1.0.1
helm:
valueFiles:
- $values/karpenter_nodes/eks-dev/common.yaml
Expand Down
18 changes: 0 additions & 18 deletions charts/karpenter_nodes/examples/output/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1104,24 +1104,6 @@ spec:
value: gpu
effect: NoSchedule
requirements:
- key: "karpenter.k8s.aws/instance-category"
operator: In
values:
- g
- key: "karpenter.k8s.aws/instance-cpu"
operator: In
values:
- "4"
- "8"
- "12"
- "16"
- "24"
- "32"
- "48"
- key: karpenter.k8s.aws/instance-generation
operator: Gt
values:
- "3"
- key: "topology.kubernetes.io/zone"
operator: In
values:
Expand Down
2 changes: 2 additions & 0 deletions charts/karpenter_nodes/templates/nodepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ spec:
{{- end }}
{{- end }}
requirements:
{{- if not (hasKey $v.instances "instanceTypes") }}
- key: "karpenter.k8s.aws/instance-category"
operator: In
values:
Expand All @@ -68,6 +69,7 @@ spec:
operator: Gt
values:
- {{ sub ($v.instances.minGeneration | default $.Values.instances.minGeneration) 1 | quote }}
{{- end }}
- key: "topology.kubernetes.io/zone"
operator: In
values:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
suite: test nodepool - nodes-explicittypes
templates:
- nodepool.yaml
values:
- values.yaml

tests:
- it: Verify nodes-explicittypes metadata
documentIndex: 1
asserts:
- isKind:
of: NodePool
- equal:
path: metadata.name
value: nodes-explicittypes-amd64
- equal:
path: spec.template.metadata.labels.cluster
value: eks-dev
- equal:
path: spec.template.metadata.labels.nodegroup
value: nodes-explicittypes
- equal:
path: spec.template.spec.nodeClassRef.name
value: default

- it: Verify nodes-explicittypes requirements
documentIndex: 1
asserts:
- equal:
path: spec.template.spec.requirements[0].key
value: "topology.kubernetes.io/zone"
- equal:
path: spec.template.spec.requirements[1].key
value: "kubernetes.io/arch"
- equal:
path: spec.template.spec.requirements[2].key
value: "karpenter.sh/capacity-type"
- equal:
path: spec.template.spec.requirements[3].key
value: "kubernetes.io/os"
- equal:
path: spec.template.spec.requirements[4].key
value: "karpenter.k8s.aws/instance-size"
- equal:
path: spec.template.spec.requirements[5].key
value: "node.kubernetes.io/instance-type"
- equal:
path: spec.template.spec.requirements[5].values[0]
value: t3a.large
- equal:
path: spec.template.spec.requirements[5].values[1]
value: t3a.xlarge
- isNull:
path: spec.template.spec.requirements[6]
4 changes: 2 additions & 2 deletions charts/karpenter_nodes/tests/nodepool_nodes_noclass_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ values:

tests:
- it: Verify nodes-noclass metadata
documentIndex: 1
documentIndex: 2
asserts:
- isKind:
of: NodePool
Expand All @@ -24,7 +24,7 @@ tests:
value: default

- it: Verify nodes-noclass requirements
documentIndex: 1
documentIndex: 2
asserts:
- equal:
path: spec.template.spec.requirements[0].key
Expand Down
8 changes: 4 additions & 4 deletions charts/karpenter_nodes/tests/nodepool_nodes_workers_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ values:

tests:
- it: Verify nodes-workers metadata
documentIndex: 2
documentIndex: 3
asserts:
- isKind:
of: NodePool
Expand Down Expand Up @@ -60,7 +60,7 @@ tests:


- it: Verify nodes-workers requirements
documentIndex: 2
documentIndex: 3
asserts:
- equal:
path: spec.template.spec.requirements[0].key
Expand Down Expand Up @@ -162,7 +162,7 @@ tests:


- it: Verify nodes-workers kubelet
documentIndex: 2
documentIndex: 3
asserts:
- equal:
path: spec.template.spec.kubelet.systemReserved.cpu
Expand All @@ -178,7 +178,7 @@ tests:
value: "2.2.2.2"

- it: Verify nodes-workers Options
documentIndex: 2
documentIndex: 3
asserts:
- equal:
path: spec.disruption.expireAfter
Expand Down
Loading

0 comments on commit d13b245

Please sign in to comment.