Kubernetes create deployment unexpected SchemaError
Solution 1
After installing kubectl with brew you should run:
rm /usr/local/bin/kubectl
brew link --overwrite kubernetes-cli
And also optionally:
brew link --overwrite --dry-run kubernetes-cli
.
Solution 2
I second @rennekon's answer. I found that I had docker running on my machine which also installs kubectl
. That installation of kubectl causes this issue to show.
I took the following steps:
- uninstalled it using
brew uninstall kubectl
- reinstalled it using
brew install kubectl
- (due to symlink creation failure) I forced brew to create symlinks using
brew link --overwrite kubernetes-cli
I was then able to run my kubectl apply
commands successfully.
Solution 3
I too had the same problem. In my Mac system kubectl is running from docker which is preinstalled when I install Docker. You can check this by using below command
ls -l $(which kubectl)
which returns as
/usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectlcode.
Now we have to overwrite the symlink with kubectl which is installed using brew
rm /usr/local/bin/kubectl
brew link --overwrite kubernetes-cli
(optinal)
brew unlink kubernetes-cli && brew link kubernetes-cli
To Verify
ls -l $(which kubectl)
Solution 4
I encountered the same issue on minikube/ Windows 10 after installing Docker.
It was caused by the version mismatch of kubectl that was mentioned a couple of times already in this thread. Docker installs version 1.10 of kubectl.
You have a couple of options:
1) Make sure the path to your k8s bin is above the ones in docker
2) Replace the kubectl in 'c:\Program Files\Docker\Docker\resources\bin' with the correct one
Solution 5
Your client version is too old. In my env this version comes with Docker. I have to download new client from https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/windows/amd64/kubectl.exe and now works fine:
kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Arkadiusz Migała
Updated on July 05, 2022Comments
-
Arkadiusz Migała almost 2 years
I'm following that tutorial (https://www.baeldung.com/spring-boot-minikube) I want to create Kubernetes deployment in yaml file (simple-crud-dpl.yaml):
apiVersion: apps/v1 kind: Deployment metadata: name: simple-crud spec: selector: matchLabels: app: simple-crud replicas: 3 template: metadata: labels: app: simple-crud spec: containers: - name: simple-crud image: simple-crud:latest imagePullPolicy: Never ports: - containerPort: 8080
but when I run
kubectl create -f simple-crud-dpl.yaml
i got:error: SchemaError(io.k8s.api.autoscaling.v2beta2.MetricTarget): invalid object doesn't have additional properties
I'm using the newest version of kubectl:
kubectl version Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
I'm also using minikube locally as it's described in tutorial. Everything is working till deployment and service. I'm not able to do it.
-
Tom McKenzie about 5 yearssame, but it was
gcloud
tools which had installed their own, out-of-date relative to the cluster i was targeting, kubectl -
Admin almost 5 yearscan you explain what this is doing please?
-
PmanAce almost 5 yearsSame for me, just replaced the exe and now all is fine
-
Jogendra Kumar almost 5 yearsIts worked for me also Do you know the reason behind of this?
-
James Eby over 4 yearsFixed it for me, I just ran
where kubectl
at the command line to verify that was the version being used by default thencurl -LO https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/windows/amd64/kubectl.exe
to get the latest one. -
Nguyen Thanh over 4 yearsThanks, this worked for me!!! Also work with:
kubectl apply -f filename.yaml --validate=false
-
Vlad Nikiforov over 4 yearsSeems more relevant than the accepted answer. It answers both "what" and "why".
-
Oyeme almost 4 yearswhat's the reason for re-linking?