diff --git a/Makefile b/Makefile index e47067ba0be4..6bf08768fb54 100644 --- a/Makefile +++ b/Makefile @@ -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 ||\ diff --git a/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml b/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml index 97917a011911..28ed4b2b0716 100644 --- a/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml +++ b/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml @@ -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: diff --git a/charts/karpenter-crd/templates/karpenter.sh_nodeclaims.yaml b/charts/karpenter-crd/templates/karpenter.sh_nodeclaims.yaml index bfe259dea177..487f12a9af1f 100644 --- a/charts/karpenter-crd/templates/karpenter.sh_nodeclaims.yaml +++ b/charts/karpenter-crd/templates/karpenter.sh_nodeclaims.yaml @@ -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: diff --git a/charts/karpenter-crd/templates/karpenter.sh_nodepools.yaml b/charts/karpenter-crd/templates/karpenter.sh_nodepools.yaml index d53ecbb85b56..200314a04025 100644 --- a/charts/karpenter-crd/templates/karpenter.sh_nodepools.yaml +++ b/charts/karpenter-crd/templates/karpenter.sh_nodepools.yaml @@ -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: diff --git a/charts/karpenter-crd/values.yaml b/charts/karpenter-crd/values.yaml new file mode 100644 index 000000000000..8d422f6cde3d --- /dev/null +++ b/charts/karpenter-crd/values.yaml @@ -0,0 +1,2 @@ +# -- Additional annotations for the custom resource definitions. +additionalAnnotations: {} diff --git a/hack/mutation/crd_annotations.sh b/hack/mutation/crd_annotations.sh new file mode 100755 index 000000000000..5882ad87bc46 --- /dev/null +++ b/hack/mutation/crd_annotations.sh @@ -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