Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to do a "dry run" validation of files?

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.

like image 372
JonM Avatar asked Aug 20 '15 21:08

JonM


2 Answers

This works for me (kubernetes 1.7 and 1.9):

kubectl apply --validate=true --dry-run=client --filename=file.yaml 
like image 127
David Watzke Avatar answered Oct 05 '22 15:10

David Watzke


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.

like image 34
CJ Cullen Avatar answered Oct 05 '22 14:10

CJ Cullen