Skip to content

Commit

Permalink
fix(capi-cluster): add labels and annotations to machinepool (#849)
Browse files Browse the repository at this point in the history
Signed-off-by: David van der Spek <[email protected]>
  • Loading branch information
davidspek authored Sep 14, 2023
1 parent 1696106 commit c504d31
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bootstrap/helm/cluster-api-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: cluster-api-cluster
description: A Helm chart for Kubernetes
type: application
version: 0.1.43
version: 0.1.44
appVersion: v1.24.16
11 changes: 11 additions & 0 deletions bootstrap/helm/cluster-api-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ metadata:
name: {{ .name }}
annotations:
helm.sh/resource-policy: keep
{{- if (hasKey .values "annotations") -}}
{{- toYaml (merge .values.annotations .defaultVals.annotations)| nindent 4 }}
{{- else -}}
{{- toYaml .defaultVals.annotations | nindent 4 }}
{{- end }}
labels:
{{- if (hasKey .values "labels") -}}
{{- toYaml (merge .values.labels .defaultVals.labels)| nindent 4 }}
{{- else -}}
{{- toYaml .defaultVals.labels | nindent 4 }}
{{- end }}
spec:
clusterName: {{ .ctx.Values.cluster.name }}
replicas: {{ $replicas }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ tests:
type: managed
cluster.aws.region: abc
cluster.kubernetesVersion: v1.2.3
workers.defaults.aws.labels:
test: test
workers.defaults.aws.spec.availabilityZones:
- us-east-1a
- us-east-1b
Expand All @@ -39,11 +41,78 @@ tests:
path: spec.amiType
value: AL2_x86_64
documentIndex: 0
- isSubset:
path: metadata.labels
content:
test: test
- isSubset:
path: metadata.annotations
content:
cluster.x-k8s.io/replicas-managed-by: external-autoscaler
- equal:
path: spec.diskSize
value: 50
documentIndex: 2
template: aws/machinepools.yaml
- it: test override
set:
cluster.name: test
provider: aws
type: managed
cluster.aws.region: abc
cluster.kubernetesVersion: v1.2.3
workers.defaults.aws.spec.availabilityZones:
- us-east-1a
- us-east-1b
- us-east-1c
workers.aws.small-burst-spot:
labels:
test: test
annotations:
test: test
spec:
amiType: AL2_x86_64_GPU
diskSize: 100
asserts:
- equal:
path: spec.eksNodegroupName
value: small-burst-spot
documentIndex: 22
- equal:
path: metadata.name
value: small-burst-spot
documentIndex: 23
- isSubset:
path: metadata.labels
content:
test: test
documentIndex: 22
- isSubset:
path: metadata.annotations
content:
cluster.x-k8s.io/replicas-managed-by: external-autoscaler
test: test
documentIndex: 22
- isSubset:
path: metadata.labels
content:
test: test
documentIndex: 23
- isSubset:
path: metadata.annotations
content:
cluster.x-k8s.io/replicas-managed-by: external-autoscaler
test: test
documentIndex: 23
- equal:
path: spec.diskSize
value: 100
documentIndex: 22
- equal:
path: spec.amiType
value: AL2_x86_64_GPU
documentIndex: 22
template: aws/machinepools.yaml
- it: test large-burst-spot
set:
cluster.name: test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tests:
set:
provider: gcp
type: managed
workers.defaults.gcp.labels:
test: test
asserts:
- hasDocuments:
count: 6
Expand Down Expand Up @@ -51,6 +53,14 @@ tests:
equal:
path: spec.machineType
value: e2-standard-2
- isSubset:
path: metadata.labels
content:
test: test
- isSubset:
path: metadata.annotations
content:
cluster.x-k8s.io/replicas-managed-by: external-autoscaler
- it: should have custom kubernetes version set
set:
provider: gcp
Expand All @@ -67,4 +77,3 @@ tests:
asserts:
- hasDocuments:
count: 0

0 comments on commit c504d31

Please sign in to comment.