Kubernetes 101 : API error : Wrong or old API version -error: unable to recognize "deployment.yaml": no matches for kind "Deployment" in version "v1" -



When trying to create a resource for example a "deployment", we run the below command: 


Below is the "deployment.yaml" file:


We get the below error:

error: unable to recognize "deployment.yaml": no matches for kind "Deployment" in version "v1

We get the error because we are using the wrong API version for the "deployment" resource.

Getting the right API version for the "deployment" resource:

We get the version of the API using the below command for the "deployment" resource:


We can see that the right version for the "deployment" resource is "apps/v1", so we replace the apiVersion with "apps/v1" and we run the "kubectl apply" command on the modified Yaml file.

Comments

Leave as a comment:

Archive