Before creating an object in Kubernetes (Service, ReplicationController, etc.), I'd like to test that the JSON or YAML specification of the object is valid. But I don't want to actually create the object.
Is there some to do a "dry run" that would be equivalent to running kubectl create --validate=true -f file.json
, but would just let me know that it passes validation, and not actually create it?
Ideally, it would be great if I could do this via API, and not require the use of kubectl. But I could make it work if it required me to use kubectl.
Thanks.
This works for me (kubernetes 1.7 and 1.9):
kubectl apply --validate=true --dry-run=client --filename=file.yaml
Some kubectl commands support a --dry-run
flag (like kubectl run, kubectl expose, and kubectl rolling-update).
There is an issue open to add the --dry-run
flag to more commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With