A way to get the schema using as an example secretproviderclasses.secrets-store.csi.x-k8s.io
i would use the command kubectl describe crd secretproviderclasses.secrets-store.csi.x-k8s.io
and get as a result:
Name: secretproviderclasses.secrets-store.csi.x-k8s.io
Namespace:
Labels: <none>
Annotations: controller-gen.kubebuilder.io/version: v0.9.0
helm.sh/resource-policy: keep
API Version: apiextensions.k8s.io/v1
Kind: CustomResourceDefinition
Metadata:
Creation Timestamp: 2022-10-11T15:27:15Z
Generation: 1
Managed Fields:
API Version: apiextensions.k8s.io/v1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.:
f:controller-gen.kubebuilder.io/version:
f:spec:
f:conversion:
.:
f:strategy:
f:group:
f:names:
f:kind:
f:listKind:
f:plural:
f:singular:
f:scope:
f:versions:
Manager: helm
Operation: Update
Time: 2022-10-11T15:27:15Z
API Version: apiextensions.k8s.io/v1
Fields Type: FieldsV1
fieldsV1:
f:status:
f:acceptedNames:
f:kind:
f:listKind:
f:plural:
f:singular:
f:conditions:
k:{"type":"Established"}:
.:
f:lastTransitionTime:
f:message:
f:reason:
f:status:
f:type:
k:{"type":"NamesAccepted"}:
.:
f:lastTransitionTime:
f:message:
f:reason:
f:status:
f:type:
Manager: kube-apiserver
Operation: Update
Subresource: status
Time: 2022-10-11T15:27:15Z
API Version: apiextensions.k8s.io/v1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:kubectl.kubernetes.io/last-applied-configuration:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2022-10-11T15:27:38Z
API Version: apiextensions.k8s.io/v1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:helm.sh/resource-policy:
Manager: kubectl-patch
Operation: Update
Time: 2022-10-12T16:02:53Z
Resource Version: 123907610
UID: 4a251e0a-97fc-4369-903f-9aa9a13469c1
Spec:
Conversion:
Strategy: None
Group: secrets-store.csi.x-k8s.io
Names:
Kind: SecretProviderClass
List Kind: SecretProviderClassList
Plural: secretproviderclasses
Singular: secretproviderclass
Scope: Namespaced
Versions:
Name: v1
Schema:
openAPIV3Schema:
Description: SecretProviderClass is the Schema for the secretproviderclasses API
Properties:
API Version:
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: SecretProviderClassSpec defines the desired state of SecretProviderClass
Properties:
Parameters:
Additional Properties:
Type: string
Description: Configuration for specific provider
Type: object
Provider:
Description: Configuration for provider name
Type: string
Secret Objects:
Items:
Description: SecretObject defines the desired state of synced K8s secret objects
Properties:
Annotations:
Additional Properties:
Type: string
Description: annotations of k8s secret object
Type: object
Data:
Items:
Description: SecretObjectData defines the desired state of synced K8s secret object data
Properties:
Key:
Description: data field to populate
Type: string
Object Name:
Description: name of the object to sync
Type: string
Type: object
Type: array
Labels:
Additional Properties:
Type: string
Description: labels of K8s secret object
Type: object
Secret Name:
Description: name of the K8s secret object
Type: string
Type:
Description: type of K8s secret object
Type: string
Type: object
Type: array
Type: object
Status:
Description: SecretProviderClassStatus defines the observed state of SecretProviderClass
Properties:
By Pod:
Items:
Description: ByPodStatus defines the state of SecretProviderClass as seen by an individual controller
Properties:
Id:
Description: id of the pod that wrote the status
Type: string
Namespace:
Description: namespace of the pod that wrote the status
Type: string
Type: object
Type: array
Type: object
Type: object
Served: true
Storage: true
Deprecated: true
Deprecation Warning: secrets-store.csi.x-k8s.io/v1alpha1 is deprecated. Use secrets-store.csi.x-k8s.io/v1 instead.
Name: v1alpha1
Schema:
openAPIV3Schema:
Description: SecretProviderClass is the Schema for the secretproviderclasses API
Properties:
API Version:
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: SecretProviderClassSpec defines the desired state of SecretProviderClass
Properties:
Parameters:
Additional Properties:
Type: string
Description: Configuration for specific provider
Type: object
Provider:
Description: Configuration for provider name
Type: string
Secret Objects:
Items:
Description: SecretObject defines the desired state of synced K8s secret objects
Properties:
Annotations:
Additional Properties:
Type: string
Description: annotations of k8s secret object
Type: object
Data:
Items:
Description: SecretObjectData defines the desired state of synced K8s secret object data
Properties:
Key:
Description: data field to populate
Type: string
Object Name:
Description: name of the object to sync
Type: string
Type: object
Type: array
Labels:
Additional Properties:
Type: string
Description: labels of K8s secret object
Type: object
Secret Name:
Description: name of the K8s secret object
Type: string
Type:
Description: type of K8s secret object
Type: string
Type: object
Type: array
Type: object
Status:
Description: SecretProviderClassStatus defines the observed state of SecretProviderClass
Properties:
By Pod:
Items:
Description: ByPodStatus defines the state of SecretProviderClass as seen by an individual controller
Properties:
Id:
Description: id of the pod that wrote the status
Type: string
Namespace:
Description: namespace of the pod that wrote the status
Type: string
Type: object
Type: array
Type: object
Type: object
Served: true
Storage: false
Status:
Accepted Names:
Kind: SecretProviderClass
List Kind: SecretProviderClassList
Plural: secretproviderclasses
Singular: secretproviderclass
Conditions:
Last Transition Time: 2022-10-11T15:27:15Z
Message: no conflicts found
Reason: NoConflicts
Status: True
Type: NamesAccepted
Last Transition Time: 2022-10-11T15:27:15Z
Message: the initial names have been accepted
Reason: InitialNamesAccepted
Status: True
Type: Established
Stored Versions:
v1
Events:
Which is really verbose and hard to read, so is there some command that returns a json schema with examples?
CodePudding user response:
I am not aware of something what returns you an example directly. But you could use kubectl explain
to get information about the fields of the api-resources schema:
e.g.
$ kubectl explain secretproviderclasses.secrets-store.csi.x-k8s.io
To get the fields listed in a recursive way, use:
kubectl explain secretproviderclasses.secrets-store.csi.x-k8s.io --recursive
Some operators also provide examples of their provided CRDs in the alm-examples
annotation of their ClusterServiceVersion. So maybe this could be another way for you.