Sub topic 6
Migrating manifests to supported API versions
This chapter assumes you can read YAML manifests, use kubectl, and know what an Ingress is. It also assumes you have already found deprecated API usage, as covered in the previous chapter. Here you rewrite those manifests so they work on the version you are upgrading to.
Why a migration is more than a version bump
Changing the apiVersion line is sometimes enough. Often the schema changed too, and the old fields no longer exist. The Ingress is the standard example. In extensions/v1beta1, which was removed in Kubernetes 1.22, a backend looks like this:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: web
spec:
rules:
- host: example.com
http:
paths:
- path: /
backend:
serviceName: web
servicePort: 80A cluster at 1.22 or later rejects this manifest. In networking.k8s.io/v1, the backend gets a nested service block, and each path needs a pathType:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web
spec:
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80The migration workflow
- Locate the manifest in your repository, Helm chart, or generated output.
- Convert it. The
kubectl-convertplugin rewrites a manifest to a newer API version. - Review the output. The tool does not always pick the right value for new required fields.
- Validate it against a cluster running the target version, then commit.
# Requires the kubectl-convert plugin
kubectl convert -f old-ingress.yaml --output-version networking.k8s.io/v1 > new-ingress.yamlCommon errors
| Symptom | Likely cause |
|---|---|
| `no matches for kind "Ingress" in version "extensions/v1beta1"` | The manifest uses a removed API version. |
| `unknown field "serviceName"` | The `apiVersion` was updated but the old schema was kept. |
| `missing required field "pathType"` | The new version requires a field the old one did not have. |
| Helm release fails on upgrade | Old chart templates still render removed versions. Update the chart. |
Check templated sources too. Helm charts and Kustomize overlays can render a removed version even when your plain YAML files are clean. Render them with helm template or kubectl kustomize, and check the output.
Exercise
A teammate changes apiVersion: extensions/v1beta1 to networking.k8s.io/v1 in an Ingress manifest and changes nothing else. The cluster rejects it. Name two schema changes they still need to make.
Show answer
Each path needs a pathType field (for example Prefix). The backend must use the nested form, so serviceName: web and servicePort: 80 become service.name: web and service.port.number: 80.