I am using kubectl 1.6.4:
$ 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"}
I am trying to follow along with Connect a Front End to a Back End Using a Service, and am attempting to create this deployment (deployment.yml):
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"]
Upon kubectl create -f deployment.yml
, I get the following error:
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
However, this file is valid.
I noticed in Deployment
s documentation that Deployment
s before 1.6.0 used apiVersion: extensions/v1beta1
instead of apiVersion: app/v1beta1
. So just for kicks I replaced apiVersion: app/v1beta1
with apiVersion: extensions/v1beta1
, even though I am running 1.6.4. To my surprise, it worked.
What's wrong? Why do I need to use the old, pre-1.6.0 apiVersion
line even though I am on 1.6.4?
Try deleting ~/.kube/schema
(I deleted ~/.kube/cache
as well, but I am pretty sure that had no effect). In my case, ~/.kube/schema
had several schemas:
$ 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 ..
and kubectl was apparently using an old schema. This might be a bug.
When you delete ~/.kube/schema
, 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.