8
2

More than 3 years have passed since last update.

kubectl apply で SchemaError(io.k8s.api.apps.v1.DeploymentList) と出たときの対処法

Posted at

この記事はMacで開発していることを前提に書いてます

現象

  • GKEのバージョンを1.14.xにアップグレードした後にkubectl applyを実行したら、以下のようなエラーが出ました
$ kubectl apply -f deployment.yaml 
error: SchemaError(io.k8s.api.apps.v1.DeploymentList): invalid object doesn't have additional properties

原因

  • kubectlのClientバージョンが古い場合に起こるようです
  • kubectl versionで見てみます
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", Platform:"linux/amd64"}

対処法

kubectlのバージョンを上げます

  • usr/local/bin下のkubectlを削除します
  • 最新のkubectlをダウンロードして、usr/local/bin下に置きます
$ rm /usr/local/bin/kubectl
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl
$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin/kubectl

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", Platform:"linux/amd64"}

kubectlのバージョンを上げないで一時的に済ます場合は--validate=falseをつけます

$ kubectl apply -f deployment.yaml --validate=false
deployment.extensions "hoge" configured

参考URL

8
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2