Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(capi-cluster): add labels and annotations to machinepool #849

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Loading