<p>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.</p>

<p>Is there some to do a "dry run" that would be equivalent to running <code>kubectl create --validate=true -f file.json</code>, but would just let me know that it passes validation, and not actually create it?</p>

<p>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.</p>

<p>Thanks.</p>

<p>This works for me (kubernetes 1.7 and 1.9):</p>
<pre><code>kubectl apply --validate=true --dry-run=client --filename=file.yaml
</code></pre>
