Missing OpenAPIV3 Validation for CRD
TGPSKI opened this issue · 2 comments
TGPSKI commented
Using the example template for a chaos experiment and the custom resource, I get the following Validation error on an attempted apply.
error: error validating "chaos-experiments/first.yaml": error validating data: ValidationError(ChaosToolkitExperiment): unknown field "spec" in org.chaostoolkit.v1.ChaosToolkitExperiment; if you choose to ignore these errors, turn validation off with --validate=false
Setup:
- Kubernetes 1.18 on x86_64
- 1 Master / 3 Agents
CRD:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: chaosexperiments.chaostoolkit.org
spec:
scope: Namespaced
group: chaostoolkit.org
versions:
- name: v1
served: true
storage: true
names:
kind: ChaosToolkitExperiment
plural: chaosexperiments
singular: chaosexperiment
shortNames:
- ctk
- ctks
Template:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: chaostoolkit-experiment8
namespace: chaostoolkit-run
data:
"experiment.json": |-
{
"version": "1.0.0",
"title": "Moving a file from under our feet is forgivable",
"description": "Our application should re-create a file that was removed",
"steady-state-hypothesis": {
"title": "The file must be around first",
"probes": [
{
"type": "probe",
"name": "file-must-exist",
"tolerance": true,
"provider": {
"type": "python",
"module": "os.path",
"func": "exists",
"arguments": {
"path": "/etc"
}
}
}
]
},
"method": [
{
"ref": "file-must-exist"
}
]
}
---
apiVersion: chaostoolkit.org/v1
kind: ChaosToolkitExperiment
metadata:
name: chaostoolkit-experiment8
namespace: chaostoolkit-crd
spec:
namespace: chaostoolkit-run
pod:
image: <PRIVATE_REGISTRY>/chaostoolkit:latest
imagePullSecrets:
- name: regcred
Digging into the validation error, the CRD expects a schema key in the versions array. Below is a stub showing the location of the necessary schema key.
group: chaostoolkit.org
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object