Flux CLI plugin for Kubernetes schema extraction and manifests validation.
Note
This repository is in early development and the plugin system is not yet available in a stable release of Flux. The instructions for installing and using the plugin will be added here when RFC-0013 has been implemented and released in Flux 2.9 or later.
The extract command reads Kubernetes CustomResourceDefinition YAML and writes one JSON Schema file per CRD version.
The input can be a bare CRD, a List of CRDs, or a multi-document YAML stream.
Generate schemas for every CRD installed in a cluster:
kubectl get crds -o yaml > crds.yaml
flux-schema extract crds.yaml -d ./schemasBy default, files are named {{ .Kind }}-{{ .GroupPrefix }}-{{ .Version }}.json. The output is compatible with
kubeconform and kubeval, making this command a drop-in replacement for kubeconform's
openapi2jsonschema.py script.
Note that the generated schemas apply the following OpenAPI → JSON Schema transformations:
- Objects with
propertiesare closed withadditionalProperties: false, except under nodes marked withx-kubernetes-preserve-unknown-fields: true, which stay open so free-form maps validate correctly. - Integer-or-string fields are rewritten to
oneOf: [{type: string}, {type: integer}]. Both the legacyformat: int-or-stringand the structuralx-kubernetes-int-or-string: trueforms are recognized.
You can supply --output-format with a Go template to change the layout, e.g. the
CRDs-catalog per-group-directory layout:
flux-schema extract crds.yaml \
--output-format '{{ .Group }}/{{ .Kind }}_{{ .Version }}.json'Template variables (all lowercased at render time):
| Variable | Example |
|---|---|
.Group |
source.toolkit.fluxcd.io |
.GroupPrefix |
source |
.Kind |
gitrepository |
.Version |
v1 |
Nested directories referenced by --output-format are created automatically.