If you have recently updated your Kubernetes version and all of a sudden your YAML files stopped working, for Daemonset or for Deployment or maybe your Replicaset YAML file started giving the error:
no matches for kind "DaemonSet" in version "extensions/v1beta1
Then you are at the right place. If you are trying to update Kubernetes version from say 1.15.x to 1.16.+ version then you will see this error because there has been changes in the Kubernetes resource definition as Kubernetes is becoming more and more stable.
In the version 1.16.+ we should be using extensions/v1 and not v1beta anymore.
For example, here we have a Daemonset resource YAML file for Fluent Bit service:
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: logging
labels:
k8s-app: fluent-bit-logging
version: v1
kubernetes.io/cluster-service: "true"
...
...
The above file would work fine with Kubernetes version 1.15 or lower, but for the updated version you will have to change the apiVersion to extensions/v1 instead of extensions/v1beta1.
Also, for Kubernetes version 1.17 or greater there is further change and extensions/v1 should now be completely removed and instead apps/v1 should be used.
And this is not just for Daemonset but for Deployment too.
So the above code should be:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: logging
labels:
k8s-app: fluent-bit-logging
version: v1
kubernetes.io/cluster-service: "true"
...
...
Most of the developers face this issue because most of the tutorials have old YAML files and the support for extensions/v1beta1 was removed in v1.16, hence while applying the YAML configuration using the kubectl
command we get this issue.
As per the official documentation of Kubernetes (Release notes - 1.16.0)
The following APIs are no longer served by default:
-
All resources under apps/v1beta1
and apps/v1beta2
- use apps/v1
instead
-
daemonsets
, deployments
, replicasets
resources under extensions/v1beta1
- use apps/v1
instead
-
networkpolicies
resources under extensions/v1beta1
- use networking.k8s.io/v1
instead
-
podsecuritypolicies
resources under extensions/v1beta1
- use policy/v1beta1
instead
Hence, case close. This solution should fix your issue. If you have upgraded version and are facing this issue, then chances are that you must have faced the spec.selector
field missing issue too:
[SOLVED] Missing required field "selector" in Kubernetes
Conclusion:
I hope this article helps you in solving the issue. If you have any doubt, feel free to post in the comments and we will definitely help you out.
You may also like: