Inferensys

Glossary

Custom Resource Definition (CRD)

A Custom Resource Definition (CRD) is a Kubernetes API extension mechanism that allows users to define and manage custom objects, enabling declarative automation for complex applications like LLM inference services.
ML engineer developing custom LLM, model architecture diagrams on screens, technical deep work environment.
KUBERNETES EXTENSION

What is Custom Resource Definition (CRD)?

A Custom Resource Definition (CRD) is a Kubernetes API extension mechanism that allows users to define new resource types, enabling the platform to manage custom objects as native first-class citizens.

A Custom Resource Definition (CRD) is a Kubernetes API extension mechanism that allows users to define new resource types, enabling the platform to manage custom objects as native first-class citizens. By creating a CRD, you introduce a new Custom Resource (CR), such as an InferenceService or LLMDeployment, which can be created, updated, and deleted using standard kubectl commands. The CRD itself is a schema that defines the structure, validation rules, and API endpoints for the new resource, effectively teaching the Kubernetes API server how to handle it.

The power of a CRD is realized when paired with a custom controller or Operator. This controller runs a reconciliation loop, watching for changes to instances of the custom resource and executing logic to align the actual cluster state with the desired state declared in the resource's spec. In LLM deployment and serving, CRDs are foundational for frameworks like KServe, allowing platform teams to define declarative APIs for complex inference services that the Operator then provisions and manages automatically.

KUBERNETES EXTENSIBILITY

Key Features of Custom Resource Definitions

Custom Resource Definitions (CRDs) are the fundamental building blocks for extending the Kubernetes API, allowing users to define and manage custom objects that represent their application's unique state and configuration.

01

API Extension Mechanism

A Custom Resource Definition (CRD) is a Kubernetes API extension that allows users to define new resource types (Kinds) and add them to the cluster's API server. Once registered, these custom resources can be created, read, updated, and deleted using standard Kubernetes tools like kubectl, just like native resources such as Pods or Deployments. This transforms Kubernetes from a generic container orchestrator into a domain-specific platform for managing any declarative state.

  • Example: Defining a InferenceService CRD to represent an LLM endpoint.
  • Result: Users can run kubectl get inferenceservices to list all deployed models.
02

Declarative State Specification

A custom resource is a declarative YAML/JSON manifest that describes the desired state of a custom object. The spec field contains the user's configuration, while the status field is managed by a controller to reflect the actual state. This pattern enforces a clean separation between user intent and system reality.

  • Structure: apiVersion, kind, metadata, spec, status.
  • Example: An InferenceService spec might define the model ID, compute resources, and autoscaling rules.
03

Controller Reconciliation Loop

A custom resource is inert without a controller (often implemented as an Operator). The controller runs a continuous reconciliation loop, watching for changes to custom resources. It compares the spec (desired state) with the status (observed state) and executes imperative logic—like deploying Pods or configuring services—to drive the cluster toward the desired state. This is the core automation mechanism for CRDs.

  • Watch: The controller subscribes to API events for the custom resource.
  • Diff & Act: It computes the difference between spec and status and takes corrective actions.
  • Update Status: It writes the current observed state back to the resource's status field.
04

Schema Validation with OpenAPI

CRDs can include a structured validation schema using OpenAPI v3, which is enforced by the Kubernetes API server upon creation or update. This prevents invalid configurations from being stored. The schema defines required fields, data types, and value constraints for the spec.

  • Benefit: Catches configuration errors immediately at the API layer.
  • Example: Validating that a replicaCount field is an integer greater than zero.
  • Tooling: Schemas enable better IDE support and documentation generation.
05

Integration with Core Kubernetes Primitives

Custom resources integrate seamlessly with native Kubernetes ecosystems. They can be referenced by other resources, managed by tools like Helm, secured via RBAC, and monitored through standard APIs. This allows custom abstractions to leverage the full power of the platform.

  • RBAC: Define roles that grant permissions to create or watch custom resources.
  • Helm: Package and deploy a CRD and its controller as a single chart.
  • Service Mesh: A custom SmartRouter resource could generate Istio VirtualService configuration.
06

Foundation for Operators

CRDs are the essential data model for the Operator Pattern, a method of packaging and deploying complex, stateful applications on Kubernetes. An Operator consists of one or more CRDs (to define the application's domain) and a controller (to manage its lifecycle). This pattern is critical for LLMOps, enabling the declarative management of resources like InferenceService, LLMFineTuneJob, or PromptVersion.

  • Use Case: An LLM Serving Operator uses an InferenceService CRD to manage model deployments, autoscaling, and canary rollouts.
  • Automation: The operator handles complex operational tasks like GPU provisioning and model caching, reducing manual toil.
COMPARISON

CRD vs. Other Kubernetes Extension Mechanisms

A feature comparison of Custom Resource Definitions (CRDs) against other primary methods for extending the Kubernetes API, highlighting their respective use cases in LLM deployment and serving.

Feature / MechanismCustom Resource Definition (CRD)Aggregated API ServerCustom API Server

Primary Purpose

Define new resource types (Kinds) within the existing API server

Proxy API requests to a separate, dedicated server

Deploy a standalone API server with full control

API Path & Group

Managed under the main API server (e.g., apiextensions.k8s.io)

Registered under the main API server's aggregation layer

Operates on its own, distinct API path and group

Implementation Complexity

Low to Medium. Define a schema; controller logic is separate.

High. Requires building and operating a full API server.

Highest. Requires building and operating a full, standalone API server.

Operational Overhead

Low. Managed by the Kubernetes API server; no additional servers.

Medium. Requires deploying and managing the aggregated server.

High. Full lifecycle management of a separate API server.

Storage & Persistence

Uses etcd via the main API server. Schema-defined.

Managed by the aggregated server (can use its own storage).

Managed entirely by the custom server (full control over storage).

Validation & DefaultingDeclarative schema validation (OpenAPI v3). Mutating admission via webhooks.Implemented within the aggregated server's business logic.Fully implemented within the custom server's business logic.
Versioning & ConversionSupported via multiple versions in the CRD definition with conversion webhooks.Handled internally by the aggregated server's API logic.Handled internally by the custom server's API logic.
Common Use Case in LLM OpsDefining custom resources like 'InferenceService' or 'LLMDeployment' for an Operator.Extending the API for a complex, self-contained service (less common for pure resources).Rare. Typically for services needing complete API isolation or pre-dating CRDs.
Recommended ForExtending Kubernetes with new declarative resource types for controllers/operators.Integrating existing external services with a Kubernetes-native API facade.Legacy integration or scenarios requiring absolute control, bypassing kube-apiserver features.
CUSTOM RESOURCE DEFINITION

Frequently Asked Questions

A Custom Resource Definition (CRD) is a fundamental Kubernetes extension mechanism. These FAQs address its role in deploying and managing AI/ML workloads, particularly for LLM serving.

A Custom Resource Definition (CRD) is a Kubernetes API extension that allows users to define and manage their own custom object types, called Custom Resources (CRs), within a Kubernetes cluster. It effectively teaches the Kubernetes API server about a new kind of object, such as an InferenceService or LLMDeployment, which can then be created, updated, and deleted using standard kubectl commands, just like native resources like Pods or Deployments. CRDs are the foundational building block for creating Kubernetes Operators, which provide the automation logic to reconcile the state of these custom objects. For example, defining a ModelServing CRD lets platform engineers declare a desired model state (e.g., model ID, replicas, GPU type), and a corresponding Operator can then orchestrate the underlying Pods, Services, and configurations to realize that state.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.