Sub topic 2
API groups, versions, and alpha/beta/stable levels
This chapter assumes you know basic kubectl usage, core objects such as Pods, Deployments, and Ingress, and how to read YAML manifests. It explains how the apiVersion field is built and what the alpha, beta, and stable levels promise. Later chapters use this model to explain deprecations.
How an apiVersion is built
Every manifest starts with apiVersion and kind. The apiVersion has two parts: an API group and a version, joined by a slash.
| apiVersion | Group | Version |
|---|---|---|
| `apps/v1` | `apps` | `v1` |
| `networking.k8s.io/v1` | `networking.k8s.io` | `v1` |
| `batch/v1` | `batch` | `v1` |
| `v1` | core (no name) | `v1` |
The core group has no name, so objects such as Pods and Services use only v1. Groups let the project add and retire APIs separately. A group can serve several versions of the same resource at once.
Maturity levels
The version string tells you how much the API can change.
| Level | Example | Default state | Promise |
|---|---|---|---|
| Alpha | `v1alpha1` | Off by default | May change or vanish without notice. May be buggy. |
| Beta | `v1beta1`, `v2beta2` | Varies by API and release | Schema is mostly settled. Details can still change. |
| Stable | `v1`, `v2` | On | Kept for many releases and covered by the deprecation policy. |
Alpha APIs are not served unless an administrator turns them on. Do not use them in production clusters. Beta APIs were once enabled by default, but this has changed. Newer beta APIs are generally off by default, so check the release notes for the version you run.
Stable versions are the target. When a stable version replaces a beta one, the beta version is deprecated and later removed.
A version change can change the schema
A newer version is not always the same object with a new label. The Ingress resource shows this. The old form used extensions/v1beta1, which was removed in Kubernetes 1.22.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: web
spec:
rules:
- host: example.com
http:
paths:
- path: /
backend:
serviceName: web
servicePort: 80The stable form is in networking.k8s.io/v1. It needs a pathType and a nested backend.service block.
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: 80Changing only the apiVersion line would leave an invalid manifest. The chapter on migration covers how to convert such files safely.
Seeing what your cluster serves
The API server lists every group and version it serves. Run this against your cluster.
kubectl api-versions | sortThe output varies by cluster and release. Look for beta entries such as v1beta1 or v2beta2. They are the ones most likely to be deprecated.
Exercise
A manifest has apiVersion: batch/v1beta1 and kind: CronJob. Name the group, the version, and the maturity level. Should you expect this to be served by every current cluster?
Show answer
The group is batch, the version is v1beta1, and the maturity level is beta. You should not expect it to be served. A stable batch/v1 exists for CronJob, and beta versions that have been replaced are deprecated and then removed. Check kubectl api-versions on the target cluster and the release notes before you rely on it.