☑️ Prevent use of deprecated APIs in Kubernetes v1.19
Kubernetes version 1.19 stopped serving several APIs for different resource types. When deploying a resource with a deprecated API version, the Kubernetes engine will reject it.
The following resources are deprecated in version 1.19:
API version | Resource kind |
---|---|
networking.k8s.io/v1beta1 | Ingress IngressClass |
storage.k8s.io/v1beta1 | CSIDriver |
certificates.k8s.io/v1beta1 | CertificateSigningRequest |
events.k8s.io/v1beta1 | Event |
coordination.k8s.io/v1beta1 | Lease LeaseList |
apiregistration.k8s.io/v1beta1 | APIService APIServiceList |
Targeted objects by this rule (types of kind
): (See table above)
Complexity: easy (What does this mean?)
Policy as code identifier: K8S_DEPRECATED_APIVERSION_1.19
This rule will fail
If one of the deprecated API versions is used for a resource:
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
Rule output in the CLI
$ datree test *.yaml
>> File: failExample.yaml
❌ Prevent use of deprecated APIs in Kubernetes v1.19 [1 occurrence]
💡 Incorrect value for key `apiVersion` - the version of the resource you are trying to use is deprecated in k8s v1.19
How to fix this failure
Use a supported API version instead of the deprecated one:
Deprecated API version | Supported API version |
---|---|
networking.k8s.io/v1beta1 | networking.k8s.io/v1 |
storage.k8s.io/v1beta1 | storage.k8s.io/v1 |
certificates.k8s.io/v1beta1 | certificates.k8s.io/v1 |
events.k8s.io/v1beta1 | events.k8s.io/v1 |
coordination.k8s.io/v1beta1 | coordination.k8s.io/v1 |
apiregistration.k8s.io/v1beta1 | apiregistration.k8s.io/v1 |
Example:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole