Files
argocd-apps/ci/validate-clusters.sh
T
unkinben d21d9a92d3 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
- ci/crd-schemas/: 67 generated schemas (cert-manager, cnpg, elastic, victoriametrics, argocd, gateway)
- .pre-commit-config.yaml: raise large-file limit to 2 MB for generated schemas

Run `make generate-schemas` to regenerate after CRD version changes.
2026-05-30 23:09:34 +10:00

25 lines
904 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
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
dir="$(dirname "$k")"
echo "==> kubeconform: $dir" >&2
kustomize build --enable-helm "$dir" \
| kubeconform \
-kubernetes-version "$KUBE_VERSION" \
-summary \
-output pretty \
-verbose \
-skip CustomResourceDefinition \
"${schema_args[@]}"
done < <(find clusters -name kustomization.yaml -print0)