invalid object doesn't have additional properties error

When I use kubectl to deploy a service:

$ kubectl --kubeconfig=C:\Users\xxx\.kube\config apply -f deploy.yaml --namespace=xxx
a SchemeError was raised:
EXEC(0,0): Error : SchemaError(io.k8s.api.apps.v1beta1.RollingUpdateStatefulSetStrategy): invalid object doesn't have additional properties

Seems that the issue is caused by kubectl version mismatch: Install and Set Up kubectl

You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.

Follow these steps to resolve the issue:

Check deploy.yaml

Make sure deploy.yaml is correct and the docker image can be run locally.

Check kubeconfig

Double check the right kubeconfig is specified and connect to the right cluster:

> kubectl.exe version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp: lookup k8s-cluster.io: no such host

Connect Right Server

The server is displayed after "dial tcp:": "k8s-cluster.io". If "Unable to connect to the server" is displayed, you might use a wrong kubeconfig file. Correct the config by --kubeconfig option.

Check kubectl Version & Path

One may install multiple kubectl on the same machine. If you found client version is not matched, consider specifying the right one. You can also view the current kubectl by (For Linux, command which):

> Get-Command kubectl.exe
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     kubectl.exe                                        0.0.0.0    C:\Program Files\Docker\Docker\Resources\bin\kubectl.exe

I install the Docker Desktop on Windows and the default kubectl location is C:\Program Files\Docker\Docker\Resources\bin\. So, download the matched kubectl from Install and Set Up kubectl and put it in this folder solved the problem.

Reference

Kubectl create “invalid object”