<p>I am using kubectl 1.6.4:</p>

<pre><code>$ kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:44:27Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:33:17Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>I am trying to follow along with <a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/#creating-the-frontend" rel="nofollow noreferrer">Connect a Front End to a Back End Using a Service</a>, and am attempting to create this deployment (deployment.yml):</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: frontend
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello
        tier: frontend
        track: stable
    spec:
      containers:
        - name: nginx
          image: "gcr.io/google-samples/hello-frontend:1.0"
          lifecycle:
            preStop:
              exec:
                command: ["/usr/sbin/nginx","-s","quit"]
</code></pre>

<p>Upon <code>kubectl create -f deployment.yml</code>, I get the following error:</p>

<blockquote>
  <p>error: error validating "/path/to/deployment.yml": error validating data: unexpected end of JSON input; if you choose to ignore these errors, turn validation off with --validate=false</p>
</blockquote>

<p>However, this file is valid.</p>

<p>I noticed in <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer"><code>Deployment</code>s documentation</a> that <code>Deployment</code>s before 1.6.0 used <code>apiVersion: extensions/v1beta1</code> instead of  <code>apiVersion: app/v1beta1</code>. So just for kicks I replaced <code>apiVersion: app/v1beta1</code> with <code>apiVersion: extensions/v1beta1</code>, even though I am running 1.6.4. To my surprise, it worked.</p>

<p>What's wrong? Why do I need to use the old, pre-1.6.0 <code>apiVersion</code> line even though I am on 1.6.4?</p>

<p>Try deleting <code>~/.kube/schema</code> (I deleted <code>~/.kube/cache</code> as well, but I am pretty sure that had no effect). In my case, <code>~/.kube/schema</code> had several schemas:</p>

<pre><code>$ l schema/
total 0
drwxr-xr-x  6 dmitry  staff   204B Jan  9 11:23 v1.4.7
drwxr-xr-x  8 dmitry  staff   272B Jan 11 00:13 v1.5.1
drwxr-xr-x  5 dmitry  staff   170B Jun 17 15:05 .
drwxr-xr-x  7 dmitry  staff   238B Jun 22 19:32 v1.6.4
drwxr-xr-x  5 dmitry  staff   170B Jun 22 22:47 ..
</code></pre>

<p>and kubectl was apparently using an old schema. <a href="https://github.com/kubernetes/kubernetes/issues/47937#issuecomment-310540682" rel="nofollow noreferrer">This might be a bug</a>. </p>

<p>When you delete <code>~/.kube/schema</code>, the next time you attempt to create the yml file, kubectl will repopulate that directory, but only with the latest valid schema. And it will work.</p>
