Inferensys

Glossary

Custom Resource Definition (CRD)

An extension of the Kubernetes API that allows users to define their own custom resource types, enabling the platform to manage domain-specific, declarative configurations for AI workloads.
ML engineer developing custom LLM, model architecture diagrams on screens, technical deep work environment.
KUBERNETES API EXTENSION

What is a Custom Resource Definition (CRD)?

A Custom Resource Definition (CRD) extends the Kubernetes API, allowing platform engineers to define new, domain-specific resource types that behave like native Kubernetes objects, enabling declarative management of complex AI workloads.

A Custom Resource Definition (CRD) is a Kubernetes API extension that allows users to define their own custom resource types. Once created, these custom resources are stored in the cluster's etcd database and managed by the standard API server, enabling declarative configuration for domain-specific objects like AI training jobs or inference servers.

CRDs form the backbone of the Operator pattern, where a custom controller watches for changes to these resources and reconciles the actual state with the desired state. In disconnected AI environments, CRDs allow platform teams to define resources like GPUScheduler or ModelDeployment that encapsulate complex provisioning logic without external API dependencies.

EXTENDING THE KUBERNETES API

Key Features of CRDs

Custom Resource Definitions (CRDs) are the foundational extension mechanism in Kubernetes, allowing platform engineers to model domain-specific infrastructure—such as AI training jobs or inference servers—as declarative, API-driven resources managed by native controllers.

01

Declarative Schema Definition

A CRD defines a new RESTful API endpoint in the Kubernetes API server by specifying an OpenAPI v3 schema. This schema enforces strict validation on the structure, data types, and required fields of custom resources.

  • Structural Schemas: Define the exact JSON structure, preventing malformed configuration from being persisted to etcd.
  • Pruning: Unknown fields not defined in the schema are automatically stripped, ensuring a clean, predictable spec.
  • Defaulting: Schemas can specify default values for fields, simplifying the user experience for complex AI workload configurations.
OpenAPI v3
Validation Standard
02

Custom Controllers & Reconciliation

A CRD without a controller is just a data store. The true power lies in the operator pattern, where a custom controller continuously watches for changes to custom resources and executes a reconciliation loop to drive the actual system state toward the desired state declared in the spec.

  • Level-Triggered Logic: Controllers react to the current state, not individual events, making them resilient to missed updates.
  • Idempotency: Reconciliation logic must be idempotent; running it multiple times produces the same result, ensuring stability.
  • Example: An NVIDIA GPU Operator uses a CRD to manage the lifecycle of GPU drivers and device plugins, reconciling the desired driver version with what is installed on each node.
Infinite
Reconciliation Loop
03

Versioning & Conversion

CRDs support multiple API versions simultaneously, enabling the evolution of an API without breaking existing clients. Conversion webhooks handle the translation of objects between versions on the fly.

  • Served vs. Storage Versions: A CRD can serve multiple versions (e.g., v1beta1 and v1) but stores only one version in etcd. The conversion webhook translates between the served and storage versions.
  • Round-Tripping: Conversion must be lossless; converting from v1 to v1beta1 and back to v1 must yield the identical object.
  • Deprecation: Individual versions can be deprecated with a warning message, guiding users toward the stable API.
04

Subresources for Granular Control

CRDs can expose standard Kubernetes subresources like /status and /scale to separate the specification of desired state from the reporting of observed state, a critical pattern for AI workloads.

  • Status Subresource: The controller writes observed state (e.g., 'TrainingJob is Running') to the /status endpoint, while the user writes desired state to the /spec. This prevents users from accidentally overwriting controller-managed fields.
  • Scale Subresource: Enables native integration with the Horizontal Pod Autoscaler (HPA). An AI inference CRD can expose a /scale endpoint, allowing HPA to automatically adjust the number of inference server replicas based on custom metrics like request latency.
05

Admission Control Integration

CRDs integrate seamlessly with Kubernetes admission webhooks to implement complex, stateful validation and mutation logic that goes beyond static OpenAPI schemas.

  • Validating Webhooks: Reject the creation or update of a custom resource if it violates business logic, such as ensuring an AI training job's requested GPU count does not exceed a namespace quota.
  • Mutating Webhooks: Automatically inject default configuration into a custom resource, like adding a sidecar container for a monitoring agent or injecting a pre-configured volume mount for a shared dataset.
  • CEL Validation: For simpler rules, Common Expression Language (CEL) can be embedded directly in the CRD schema for lightweight, in-process validation without a webhook call.
06

Printer Columns for CLI Visibility

CRDs can define additional printer columns to display key information when a user runs kubectl get <resource>. This transforms opaque custom resources into observable, operator-friendly entities.

  • JSONPath Columns: Map a specific field from the resource's JSON structure to a column, such as displaying the status of an AI training job (Succeeded, Failed, Running).
  • Priority and Format: Columns have a priority level (0 for standard view, 1 for wide view with -o wide), and the format can be specified (e.g., date, integer, boolean).
  • Example: A kubectl get trainingjobs command could instantly show the Job Name, Status, Age, and GPU Hours Consumed, providing immediate situational awareness to a platform engineer.
CRD ESSENTIALS

Frequently Asked Questions

Clear, technical answers to the most common questions about extending the Kubernetes API with Custom Resource Definitions for sovereign AI infrastructure.

A Custom Resource Definition (CRD) is a Kubernetes API extension that allows you to define your own custom resource types, effectively teaching the Kubernetes API server to recognize and manage domain-specific objects beyond built-in resources like Pods or Deployments. When you create a CRD, the API server registers a new RESTful endpoint at /apis/<group>/<version>/namespaces/<namespace>/<plural-name>. You then submit instances of your custom resource—called Custom Objects (COs) —as declarative YAML manifests. A custom controller watches the API server for changes to these objects and executes a reconciliation loop to drive the actual state toward the desired state declared in the object's spec. This pattern, known as the Operator Pattern, enables Kubernetes to natively manage complex, stateful AI workloads like distributed training jobs, model deployments, or GPU partitioning policies without modifying core Kubernetes code.

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.