2017-06-23 20 views
2

我使用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

但是,該文件是有效的。

我注意到Deployments documentationDeployment s在1.6.0之前使用apiVersion: extensions/v1beta1而不是apiVersion: app/v1beta1。所以只是爲了踢我apiVersion: app/v1beta1apiVersion: extensions/v1beta1,即使我運行1.6.4。令我驚訝的是,它的工作。

怎麼了?爲什麼我需要使用1.6.0之前的舊版1.6.0 apiVersion系列?

回答

3

嘗試刪除~/.kube/schema(我刪除~/.kube/cache以及,但我很確定沒有影響)。就我而言,~/.kube/schema有幾個模式:

$ 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 .. 

和kubectl顯然使用的是舊的模式。 This might be a bug

當您刪除~/.kube/schema時,下次您嘗試創建yml文件時,kubectl將重新填充該目錄,但只能使用最新的有效模式。它會起作用。

相關問題