Sign In

Curriculum 4: Understanding Kubernetes Resources

The Resource Model

10 min · 15 XP

The Kubernetes Resource Model

Every object in Kubernetes -- Pods, Services, Deployments, ConfigMaps -- follows the same resource model. Understanding this model helps you navigate the API and discover resources you have not seen before.

API Groups and Versioning

Kubernetes organizes resources into API groups. Each group has a version that indicates its stability:

  • v1 -- stable, production-ready (called the "core" group)
  • v1beta1 -- feature-complete but may change
  • v1alpha1 -- experimental, not recommended for production

Core resources like Pods, Services, and Namespaces live in the core group (no group prefix). Other resources live in named groups like apps, batch, and networking.k8s.io.

GVR: Group, Version, Resource

Every resource in Kubernetes is identified by three pieces: Group, Version, and Resource (GVR). For example:

ResourceGroupVersionResource
Pod(core)v1pods
Deploymentappsv1deployments
CronJobbatchv1cronjobs
Ingressnetworking.k8s.iov1ingresses

Discovering Resources with kubectl

The api-resources command lists every resource type your cluster supports:

# List all resource types
kubectl api-resources

# Show only namespaced resources
kubectl api-resources --namespaced=true

# Show only cluster-scoped resources
kubectl api-resources --namespaced=false

# Filter by API group
kubectl api-resources --api-group=apps

The output includes the short name, API group, whether it is namespaced, and the Kind:

NAME          SHORTNAMES   APIVERSION   NAMESPACED   KIND
pods          po           v1           true         Pod
services      svc          v1           true         Service
deployments   deploy       apps/v1      true         Deployment

Exploring API Versions

To see which API versions are available in your cluster:

kubectl api-versions

This is useful when writing manifests, because you need to specify the correct apiVersion field.

Explaining Resources

The kubectl explain command is like built-in documentation:

# Explain a resource type
kubectl explain pod

# Drill into nested fields
kubectl explain pod.spec.containers

# Show all fields recursively
kubectl explain pod --recursive

Key Takeaways

  • Every Kubernetes resource belongs to an API group with a version
  • GVR (Group, Version, Resource) uniquely identifies any resource type
  • kubectl api-resources lists all available resources in your cluster
  • kubectl explain provides built-in documentation for any resource field
  • Understanding the resource model makes it easy to explore unfamiliar APIs