feat(ci): add CRD schema generation for kubeconform validation
Add scripts to extract OpenAPI v3 schemas from CRD definitions in all kustomize overlays and write JSON schema files to ci/crd-schemas/ for kubeconform validation. This allows kubeconform to validate CRD instances (Elasticsearch, Kibana, CNPG Cluster, VictoriaMetrics, etc.) instead of skipping or erroring on them. - ci/generate-crd-schemas.py: extracts schemas from CRD YAML on stdin - ci/generate-crd-schemas.sh: iterates overlays, pipes to Python script - ci/validate-apps.sh, ci/validate-clusters.sh: add local schema-location fallback - Makefile: add generate-schemas target - add generate-schemas step to kubeconform woodpecker pipeline so schemas
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@ KUBE_VERSION="1.33.7"
|
||||
schema_args=(
|
||||
-schema-location "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{.NormalizedKubernetesVersion}}-standalone{{.StrictSuffix}}/{{.ResourceKind}}{{.KindSuffix}}.json"
|
||||
-schema-location "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json"
|
||||
-schema-location "file://${PWD}/ci/crd-schemas/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json"
|
||||
)
|
||||
|
||||
while IFS= read -r -d "" k; do
|
||||
@@ -18,6 +19,6 @@ while IFS= read -r -d "" k; do
|
||||
-summary \
|
||||
-output pretty \
|
||||
-verbose \
|
||||
-skip CustomResourceDefinition,GpuDevicePlugin,LBNodeAgent,ServiceGroup \
|
||||
-skip GpuDevicePlugin,LBNodeAgent,ServiceGroup \
|
||||
"${schema_args[@]}"
|
||||
done < <(find apps/overlays -name kustomization.yaml -print0)
|
||||
|
||||
Reference in New Issue
Block a user