CLI Reference | kapitan validate
kapitan validate
Validates the schema of compiled output. Validate options are specified in the inventory under parameters.kapitan.validate
. Supported types are:
Usage
kapitan validate
click to expand output
created schema-cache-path at ./schemas
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_secret.yml
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_service_jsonnet.yml
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_service_simple.yml
kapitan compile --validate
click to expand output
Rendered inventory (0.27s)
Compiled labels (0.23s)
Compiled removal (0.00s)
Compiled busybox (0.24s)
Compiled minikube-nginx-jsonnet (0.49s)
Compiled minikube-nginx-kadet (0.25s)
Compiled minikube-mysql (0.59s)
Compiled minikube-es (1.17s)
Compiled all-glob (1.55s)
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_secret.yml
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_service_jsonnet.yml
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_service_simple.yml
You can leverage the .kapitan
dotfile to make sure validate runs every time you run compile.
example .kapitan
...
compile:
validate: true
The validate
command will now be implied for every compile run
kapitan compile
click to expand output
Rendered inventory (0.27s)
Compiled labels (0.23s)
Compiled removal (0.00s)
Compiled busybox (0.24s)
Compiled minikube-nginx-jsonnet (0.49s)
Compiled minikube-nginx-kadet (0.25s)
Compiled minikube-mysql (0.59s)
Compiled minikube-es (1.17s)
Compiled all-glob (1.55s)
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_secret.yml
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_service_jsonnet.yml
Validation: manifest validation successful for ./compiled/minikube-mysql/manifests/mysql_service_simple.yml
Kubernetes Setup
Kubernetes has different resource kinds, for instance:
service
deployment
statefulset
Kapitan has built in support for validation of Kubernetes kinds, and automatically integrates with https://kubernetesjsonschema.dev. See github.com/instrumenta/kubernetes-json-schema for more informations.
Info
Kapitan will automatically download the schemas for Kubernetes Manifests directly from https://kubernetesjsonschema.dev
By default, the schemas are cached into ./schemas/
, which can be modified with the --schemas-path
option.
override permanently schema-path
Remember to use the .kapitan
dotfile configuration to override permanently the schema-path
location.
$ cat .kapitan
# other options abbreviated for clarity
validate:
schemas-path: custom/schemas/cache/path
Example
Refer to the mysql
example.
validate:
- type: kubernetes # mkdocs (1)!
output_paths: # mkdocs (2)!
- manifests/mysql_secret.yml
kind: secret # temporarily replaced with 'deployment' during test # mkdocs (3)!
version: 1.14.0 # optional, defaults to 1.14.0 # mkdocs (4)!
- type: kubernetes
output_paths:
- manifests/mysql_service_jsonnet.yml
- manifests/mysql_service_simple.yml
kind: service
version: 1.14.0
type
| currently only Kubernetes is supportedoutput_paths
| list of files to validatekind
| a Kubernetes resource kindversion
| a Kubernetes API version, defaults to1.14.0