我使用kubectl 1.6.4:在kubectl創建我得到驗證錯誤,但我的YAML文件是有效
$ 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"}
我試圖用Connect a Front End to a Back End Using a Service跟着一起,並在嘗試創建此部署( 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"]
在kubectl create -f deployment.yml
,我得到以下錯誤:
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
但是,該文件是有效的。
我注意到Deployment
s documentationDeployment
s在1.6.0之前使用apiVersion: extensions/v1beta1
而不是apiVersion: app/v1beta1
。所以只是爲了踢我apiVersion: app/v1beta1
apiVersion: extensions/v1beta1
,即使我運行1.6.4。令我驚訝的是,它的工作。
怎麼了?爲什麼我需要使用1.6.0之前的舊版1.6.0 apiVersion
系列?