Skip to content

Commit 21d6001

Browse files
committed
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. We now use 'yq' to hot-fix the CRDs, the only 'downside' is that 'yq' will not preserve the existing formatting, this is a known problem: mikefarah/yq#465 Signed-off-by: Sébastien Han <[email protected]>
1 parent 341aefc commit 21d6001

File tree

3 files changed

+3537
-3521
lines changed

3 files changed

+3537
-3521
lines changed

Diff for: build/crds/build-crds.sh

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ copy_ob_obc_crds() {
4646
generating_crds_v1() {
4747
echo "Generating v1 in crds.yaml"
4848
"$CONTROLLER_GEN_BIN_PATH" "$CRD_OPTIONS" paths="./pkg/apis/ceph.rook.io/v1" output:crd:artifacts:config="$OLM_CATALOG_DIR"
49+
$YQ_BIN_PATH w -i cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.mon.properties.stretchCluster.properties.zones.items.properties.volumeClaimTemplate.properties.metadata.x-kubernetes-preserve-unknown-fields true
50+
$YQ_BIN_PATH w -i cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.mon.properties.volumeClaimTemplate.properties.metadata.x-kubernetes-preserve-unknown-fields true
51+
$YQ_BIN_PATH w -i cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.storage.properties.volumeClaimTemplates.items.properties.metadata.x-kubernetes-preserve-unknown-fields true
52+
$YQ_BIN_PATH w -i cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.storage.properties.nodes.items.properties.volumeClaimTemplates.items.properties.metadata.x-kubernetes-preserve-unknown-fields true
53+
$YQ_BIN_PATH w -i cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.storage.properties.storageClassDeviceSets.items.properties.volumeClaimTemplates.items.properties.metadata.x-kubernetes-preserve-unknown-fields true
54+
# fixes a bug in yq: https://github.com/mikefarah/yq/issues/351 where the '---' gets removed
55+
sed -i '1i ---' cluster/olm/ceph/deploy/crds/ceph.rook.io_cephclusters.yaml
4956
}
5057

5158
generating_crds_v1alpha2() {

Diff for: cluster/charts/rook-ceph/templates/resources.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ spec:
818818
metadata:
819819
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
820820
type: object
821+
x-kubernetes-preserve-unknown-fields: true
821822
spec:
822823
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'
823824
properties:
@@ -972,6 +973,7 @@ spec:
972973
metadata:
973974
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
974975
type: object
976+
x-kubernetes-preserve-unknown-fields: true
975977
spec:
976978
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'
977979
properties:
@@ -1793,6 +1795,7 @@ spec:
17931795
metadata:
17941796
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
17951797
type: object
1798+
x-kubernetes-preserve-unknown-fields: true
17961799
spec:
17971800
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'
17981801
properties:
@@ -2839,6 +2842,7 @@ spec:
28392842
metadata:
28402843
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
28412844
type: object
2845+
x-kubernetes-preserve-unknown-fields: true
28422846
spec:
28432847
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'
28442848
properties:
@@ -3004,6 +3008,7 @@ spec:
30043008
metadata:
30053009
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
30063010
type: object
3011+
x-kubernetes-preserve-unknown-fields: true
30073012
spec:
30083013
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'
30093014
properties:

0 commit comments

Comments
 (0)