Description
A deprecated API can stop being served in a later Kubernetes release. Creating or updating an object through a removed API version can fail. Check support for the resource kind and target cluster version.
Potential impact
- Deployment or operational automation can fail after a cluster upgrade.
- Changing only the version string can overlook field and default changes and produce unintended configuration.
Remediation
- Read the API migration guide for the target Kubernetes version, and migrate manifests and API clients to a supported version.
- Review required fields, selectors and defaults, and test the change before deployment. Removal of an API endpoint does not mean that stored objects are immediately deleted.
Examples
These existing excerpts show only the Deployment API and selector. apps/v1beta1 Deployments have not been served since Kubernetes 1.16. An actual deployment also needs a Pod template with labels matching the selector.
Before
yaml
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
The example uses apps/v1beta1, so clusters that no longer serve it reject the request.
After
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
The example uses apps/v1 and a selector. Supply the omitted Pod template and other required configuration consistently.