I have a CRD definition which have a corev1.PodSpec type objectembedded. But the validation of the CRD fails when customresource is created. Following is the CRD
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: crdtest.test.com
namespace: crdtestns
spec:
group: test.com
names:
kind: crdtest
listKind: crdtestlist
plural: crdtests
singular: crdtest
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: CRDTest is the Schema for the crdtests API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CrdtestSpec defines the desired state of Crdtest
type: object
properties:
image:
type: string
count:
type: integer
minimum: 0
testarray:
type: array
items:
type: object
properties:
name:
type: string
spec:
type: PodSpec
required: ["name", "spec"]
required: ["image", "count", "testarray"]
status:
description: CrdTestStatus defines the observed state of Crdtest
type: object
type: object
required: ["spec"]
version: v1alpha1
versions:
- name: v1alpha1
- name: v1alpha1
served: true
storage: true
Applying the below CR gives error spec.testarray.spec in body must be of type PodSpec: "object"-
apiVersion: test.com/v1alpha1
kind: crdtest
metadata:
name: crdtest-operator
namespace: crdtestns
spec:
image: tst/test:v2.1
count: 2
testarray:
- name: item1
spec:
containers:
- name: test-con
image: testcon/test:v5.17
How can i validate the PodSpec object in customresource.