Kubernetes API Versions¶
π What are API Versions?¶
- Kubernetes objects (Pods, Deployments, ConfigMaps, etc.) are defined using APIs.
- Each API is grouped into API Groups and Versions.
- Example:
apiVersion: apps/v1
kind: Deployment
appsβ API groupv1β API versionDeploymentβ Kind
π Types of API Groups¶
-
Core Group (no name, just
v1) -
Examples:
Pod,Service,ConfigMap,Node. -
Usage:
apiVersion: v1 kind: Pod -
Named API Groups
-
Examples:
apps,batch,networking.k8s.io,rbac.authorization.k8s.io. -
Usage:
apiVersion: apps/v1 kind: Deployment
π·οΈ API Versioning Stages¶
Kubernetes uses semantic-like versioning for APIs:
-
Alpha (
v1alpha1,v1alpha2, β¦) -
Early stage, experimental.
- May change or be removed anytime.
-
Disabled by default (must enable explicitly).
-
Beta (
v1beta1,v1beta2, β¦) -
More stable, well-tested.
- Enabled by default.
-
Features may still change.
-
Stable (
v1) -
Fully tested, backward compatible.
- Enabled by default.
- API guarantees no breaking changes.
π How Alpha β Beta β Stable Works¶
- Feature starts as alpha (e.g.,
networking.k8s.io/v1alpha1). - After testing, moves to beta (
v1beta1). - Once finalized, becomes stable (
v1). - Older versions (
alpha/beta) are eventually deprecated & removed.
βοΈ Enabling APIs¶
- Alpha APIs β disabled by default. To enable:
--runtime-config=api/all=true
--runtime-config=apps/v1alpha1=true
π Multiple Versions of the Same API¶
- Some resources exist in multiple versions (e.g.,
Deploymentexisted asextensions/v1beta1, laterapps/v1). -
API Server has:
-
Preferred version β used by
kubectl get -o yaml. - Storage version β the version in which object is stored in
etcd. - On retrieval, API Server converts stored version β requested version transparently.
π How to Check API Versions¶
- List all API resources:
kubectl api-resources
kubectl api-versions
kubectl get crd <crd-name> -o yaml | grep versions -A 5
π What Do Versions Actually Mean?¶
- Version = maturity of the API.
v1alpha1= experimental, may break.v1beta1= stable enough for production use, but still subject to change.v1= guaranteed stability and long-term support.
πΌοΈ Layout Diagram¶
+---------------------+
| API Request |
+---------------------+
|
v
+--------------------------------------+
| kube-apiserver |
| Admission + Validation + Storage |
+--------------------------------------+
| Preferred Version | Storage Version
| |
v v
apps/v1beta1 β apps/v1 | etcd stores apps/v1
batch/v1beta1 β batch/v1|
π Key Takeaways¶
- APIs evolve: alpha β beta β stable (v1).
- Alpha = off by default, Beta & Stable = enabled by default.
- Multiple versions may exist β API Server handles conversion.
- Storage version is whatβs in etcd, but preferred version is what you interact with.
- Always check
kubectl api-resourcesandkubectl api-versionsto know whatβs available.