Skip to content

Commit

Permalink
feat(crd): add optional custom annotations to the crds (aws#7421)
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-keltio authored Dec 13, 2024
1 parent c2c347d commit e0cd8a4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ verify: tidy download ## Verify code. Includes dependencies, linting, formatting
bash -c 'source ./hack/validation/requirements.sh && injectDomainRequirementRestrictions "karpenter.k8s.aws"'
bash -c 'source ./hack/validation/labels.sh && injectDomainLabelRestrictions "karpenter.k8s.aws"'
cp pkg/apis/crds/* charts/karpenter-crd/templates
hack/mutation/crd_annotations.sh
hack/github/dependabot.sh
$(foreach dir,$(MOD_DIRS),cd $(dir) && golangci-lint run $(newline))
@git diff --quiet ||\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
{{- with .Values.additionalAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
controller-gen.kubebuilder.io/version: v0.16.5
name: ec2nodeclasses.karpenter.k8s.aws
spec:
Expand Down
3 changes: 3 additions & 0 deletions charts/karpenter-crd/templates/karpenter.sh_nodeclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
{{- with .Values.additionalAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
controller-gen.kubebuilder.io/version: v0.16.5
name: nodeclaims.karpenter.sh
spec:
Expand Down
3 changes: 3 additions & 0 deletions charts/karpenter-crd/templates/karpenter.sh_nodepools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
{{- with .Values.additionalAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
controller-gen.kubebuilder.io/version: v0.16.5
name: nodepools.karpenter.sh
spec:
Expand Down
2 changes: 2 additions & 0 deletions charts/karpenter-crd/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -- Additional annotations for the custom resource definitions.
additionalAnnotations: {}
9 changes: 9 additions & 0 deletions hack/mutation/crd_annotations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# Add additional annotations variable to the CRDS

CRDS="charts/karpenter-crd/templates/*.yaml"
for CRD in $CRDS
do
awk '{print} / annotations:/ && !n {print " {{- with .Values.additionalAnnotations }}\n {{- toYaml . | nindent 4 }}\n {{- end }}"; n++}' "$CRD" > "$CRD.new" && mv "$CRD.new" "$CRD"
done

0 comments on commit e0cd8a4

Please sign in to comment.