I’ve run into this error while going through one of the Kubernetes courses on LinkedIn Learning where exercise files were not updated. Basically on attempt to create deployment from YAML file with the following command:
kubectl create -f testdeployment.yaml
You may get the following error:
error: resource mapping not found for name: "SampleApp" namespace: "" from "testdeplyoment.yaml": no matches for kind "Deployment" in version "apps/v1beta1" ensure CRDs are installed first
Immediately one can say that something is not OK within YAML file, but it is not super obvious what exactly at first glance. Here goes deployment YAML file which allows to reproduce this error:
Now the cause of this error is use of deprecated API version – starting from Kubernetes 1.16 deployment in the extensions/v1beta1, apps/v1beta1, and apps/v1beta2 API versions is no longer served and you have to switch to use of apps/v1 instead (source). So to fix this error you just have to change apiVersion value to apps/v1. You can possible run into this or similar error when trying to leverage some old YAML definition and it may come in handy to know how to fix this. Based on the list of deprecated APIs removed in 1.16 you can get this error while trying to deploy NetworkPolicy or PodSecurityPolicy against extensions/v1beta1, DaemonSet against extensions/v1beta1 or extensions/v1beta2, Deployment against extensions/v1beta1, apps/v1beta1, and apps/v1beta2 API versions and couple of other resource types.