From a9fb9d20bb3f95f2df3b91df7752f4ce58a8465d Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 14 Apr 2021 17:49:48 -0600 Subject: [PATCH] ceph: preserve volume claim template metadata in schema The schema generation was not generating the metadata properties under the VolumeClaimTemplate type, resulting in the properties being ignored by the api server. The preserve unknown fields tag was not working recursively on the volumeClaimTemplates since the subtypes were defined. Now we post-process the schema so we can preserve the unknown fields for the volume claim templates metadata. Signed-off-by: Travis Nielsen --- build/crds/build-crds.sh | 7 ++++--- cluster/charts/rook-ceph/templates/resources.yaml | 5 +++++ cluster/examples/kubernetes/ceph/crds.yaml | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build/crds/build-crds.sh b/build/crds/build-crds.sh index e7c72f1bf..43facd576 100755 --- a/build/crds/build-crds.sh +++ b/build/crds/build-crds.sh @@ -47,6 +47,7 @@ copy_ob_obc_crds() { generating_crds_v1() { echo "Generating v1 in crds.yaml" "$CONTROLLER_GEN_BIN_PATH" "$CRD_OPTIONS" paths="./pkg/apis/ceph.rook.io/v1" output:crd:artifacts:config="$OLM_CATALOG_DIR" + sed -i'' -e "s/\( *\)\(description: 'Standard object''s metadata. More info: https:\/\/git.k8s.io\/community\/contributors\/devel\/sig-architecture\/api-conventions.md#metadata'\)/\1\2\n\1x-kubernetes-preserve-unknown-fields: true/" cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml } generating_crds_v1alpha2() { @@ -75,13 +76,13 @@ build_helm_resources() { # add header echo "{{- if .Values.crds.enabled }}" echo "{{- if semverCompare \">=1.16.0\" .Capabilities.KubeVersion.GitVersion }}" - + # Add helm annotations to all CRDS and skip the first 4 lines of crds.yaml "$YQ_BIN_PATH" w -d'*' "$CRDS_FILE_PATH" "metadata.annotations[helm.sh/resource-policy]" keep | tail -n +5 - + # add else echo "{{- else }}" - + # add footer cat "$CRDS_BEFORE_1_16_FILE_PATH" # DO NOT REMOVE the empty line, it is necessary diff --git a/cluster/charts/rook-ceph/templates/resources.yaml b/cluster/charts/rook-ceph/templates/resources.yaml index dbb9d0397..2e37dca65 100644 --- a/cluster/charts/rook-ceph/templates/resources.yaml +++ b/cluster/charts/rook-ceph/templates/resources.yaml @@ -817,6 +817,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -971,6 +972,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -1792,6 +1794,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -2838,6 +2841,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -3003,6 +3007,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' diff --git a/cluster/examples/kubernetes/ceph/crds.yaml b/cluster/examples/kubernetes/ceph/crds.yaml index 0849be8ca..9b9d0513d 100644 --- a/cluster/examples/kubernetes/ceph/crds.yaml +++ b/cluster/examples/kubernetes/ceph/crds.yaml @@ -820,6 +820,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -974,6 +975,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -1795,6 +1797,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -2841,6 +2844,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' @@ -3006,6 +3010,7 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + x-kubernetes-preserve-unknown-fields: true type: object spec: description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims'