API Groups

Difficulty: Advanced

Question

What are API groups in Kubernetes, and why does the API use groups and versions like apps/v1 or networking.k8s.io/v1?

Answer

API groups organise Kubernetes resources into related sets, each versioned independently, so the API can grow and change without breaking existing clients. The core (legacy) group has no name and is served at /api/v1 (Pods, Services, ConfigMaps, Secrets), while named groups are served at /apis/<group>/<version>, such as apps/v1 for Deployments or batch/v1 for Jobs. The apiVersion field in every manifest is exactly this group and version.

How a resource is identified

Every object is identified by its Group, Version, Kind (GVK). For example, a Deployment is group apps, version v1, kind Deployment. The REST path uses the resource name instead of the kind: /apis/apps/v1/namespaces/shop/deployments/cart. Controllers and client libraries work in terms of GVK and GVR (group, version, resource).

Common groups to know

Group (apiVersion)Example resources
core (v1)Pod, Service, ConfigMap, Secret, Namespace, Node, PersistentVolumeClaim
apps/v1Deployment, StatefulSet, DaemonSet, ReplicaSet
batch/v1Job, CronJob
networking.k8s.io/v1Ingress, NetworkPolicy, IngressClass
rbac.authorization.k8s.io/v1Role, ClusterRole, RoleBinding
autoscaling/v2HorizontalPodAutoscaler
policy/v1PodDisruptionBudget
apiextensions.k8s.io/v1CustomResourceDefinition

CRDs add their own groups, such as cert-manager.io/v1 or monitoring.coreos.com/v1.

Why versioning per group matters

  • Independent evolution: the batch team can promote CronJob to batch/v1 without touching apps.
  • Maturity levels: v1alpha1 (may change or vanish, off by default), v1beta1 (well tested; new beta APIs have been off by default since 1.24), and v1 (stable).
  • Deprecation policy: stable APIs are not removed within a major version. Beta APIs must stay available for a set period after deprecation before removal.
  • Conversion: the API server stores each object in one storage version in etcd and converts it to whichever version a client asks for.

Why this matters during upgrades

Many cluster upgrades break because manifests or Helm charts use removed versions:

  • extensions/v1beta1 Deployments removed in 1.16.
  • networking.k8s.io/v1beta1 Ingress removed in 1.22.
  • batch/v1beta1 CronJob and policy/v1beta1 PodSecurityPolicy removed in 1.25.
  • autoscaling/v2beta2 HPA removed in 1.26.

Before upgrading, scan manifests with tools like pluto or kubent, and check API server metrics for requests to deprecated APIs.

Groups in RBAC

RBAC rules list apiGroups. The core group is written as an empty string, so a rule for Pods uses apiGroups: [""], while a rule for Deployments uses apiGroups: ["apps"]. Getting this wrong is a common reason a Role "does nothing".

Anatomy of a Kubernetes API path. Each part of the URL maps to a field you see in manifests.
  1. /apis: Root for named groups; the core group uses /api instead.
  2. Group: apps: A family of related resources.
  3. Version: v1: Maturity and schema version of that group.
  4. Namespace: shop: Present only for namespaced resources.
  5. Resource: deployments: Plural resource name for the Kind Deployment.
  6. Name: cart: The specific object.

Code examples

Exploring groups and versions from the CLI

# All group/version pairs served by the cluster
kubectl api-versions

# Resources with their group and whether they are namespaced
kubectl api-resources --api-group=apps
kubectl api-resources --namespaced=false

# Field docs for a specific group/version
kubectl explain deployment.spec.strategy --api-version=apps/v1

# Raw REST call showing the path structure
kubectl get --raw /apis/apps/v1/namespaces/default/deployments | head -c 300

`kubectl api-resources` is the fastest way to check which group a resource belongs to before writing a manifest or an RBAC rule.

Key points

  • The core group has no name and lives at `/api/v1`; named groups live at `/apis/<group>/<version>`.
  • `apiVersion` in a manifest is `<group>/<version>`, or just `v1` for core.
  • Objects are identified by Group, Version, Kind (GVK).
  • Alpha, beta and stable versions follow a formal deprecation policy.
  • In RBAC, the core group is `""`.

Common follow-up questions

  • What is the difference between a Kind and a Resource?
  • How would you prepare a cluster upgrade when some APIs are being removed?
  • How does the API server convert between versions of the same resource?
  • How do CRDs define their own groups and versions?

Interview tips

  • Give a concrete removal example like Ingress `v1beta1` in 1.22; it shows upgrade experience.
  • Mention GVK; it is the vocabulary controllers and operators use.
  • Point out the empty-string core group in RBAC, a detail interviewers like.

Concepts covered

API Groups, Group Version Kind, API Versioning, Deprecation Policy, kubectl api-resources

More Kubernetes & Orchestration questions