Inferensys

Glossary

Custom Resource Definition (CRD)

A Custom Resource Definition (CRD) is a Kubernetes extension mechanism that allows users to create and manage new types of resources, called Custom Resources, which behave like native Kubernetes objects.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
KUBERNETES EXTENSION

What is Custom Resource Definition (CRD)?

A Custom Resource Definition (CRD) is the fundamental Kubernetes extension mechanism for defining new resource types.

A Custom Resource Definition (CRD) is a Kubernetes API extension that allows users to define and manage new types of resources, called Custom Resources, which behave identically to native Kubernetes objects like Pods or Deployments. By declaring a CRD's schema via a YAML manifest, you instruct the Kubernetes API server to create a new RESTful endpoint for your custom resource, enabling standard kubectl commands for its lifecycle management. This mechanism is foundational for building Kubernetes Operators and extending the platform's declarative model to manage any application or infrastructure component.

CRDs are essential for Infrastructure as Code (IaC) and parallelized simulation infrastructure, where they model complex, domain-specific entities like simulation jobs or robotic training tasks. A Custom Resource is an instance of a CRD, storing its state in etcd. A corresponding custom controller monitors these resources and executes control loops to reconcile the actual system state with the desired state declared in the resource's spec. This pattern encapsulates operational knowledge, enabling the automation of sophisticated workflows within the cluster's native orchestration framework.

KUBERNETES EXTENSION

Key Components of a CRD

A Custom Resource Definition (CRD) is a Kubernetes extension mechanism that allows users to create and manage new types of resources, called Custom Resources, which behave like native Kubernetes objects (like Pods or Deployments). The CRD itself is a schema that defines the structure of these new resources.

01

apiVersion and kind

These are the mandatory, top-level fields that identify the resource type in the Kubernetes API.

  • apiVersion: Specifies the API group and version for the CRD (e.g., inferensys.com/v1alpha1).
  • kind: The singular, CamelCase name of the Custom Resource (e.g., ParallelSimulation). Together, they allow the Kubernetes API server to route and process requests for your custom objects.
02

metadata

This section contains identifying information about the specific instance of the Custom Resource, following the same pattern as native Kubernetes objects.

  • name: The unique identifier for this resource instance within its namespace.
  • namespace: The Kubernetes namespace where the resource is deployed (if namespaced).
  • labels and annotations: Key-value pairs for organizing, selecting, and attaching arbitrary metadata to the object.
03

spec (Specification)

The spec is the required, user-defined configuration for the desired state of the Custom Resource. It is the most critical component, defined by the schema in the CRD.

  • Example: For a ParallelSimulation CR, the spec might define fields like replicaCount: 1000, physicsEngine: "NVIDIA Isaac Sim", and trainingAlgorithm. The controller watches this section to reconcile the actual system state with this declared intent.
04

status

The status is an optional, read-only section populated by the custom controller to report the actual observed state of the system.

  • It contains information like phase: "Running", completedReplicas: 850, and lastError: "".
  • Users and other controllers query the status to understand the current condition of the resource without inspecting the underlying pods or services directly. It should never be modified by the user.
05

The CRD Schema (OpenAPI v3)

The CRD contains a formal OpenAPI v3 schema that defines the structure, data types, validation rules, and defaults for the spec and status fields.

  • Validation: Enforces that user-provided spec values are correct (e.g., replicaCount must be an integer > 0).
  • Documentation: Serves as inline API documentation for the Custom Resource.
  • Tooling Compatibility: Enables IDE autocompletion and kubectl explain functionality (kubectl explain parallelsimulation.spec.replicaCount).
06

Scope (Namespaced vs. Cluster)

A fundamental property defined in the CRD that determines the resource's visibility and isolation.

  • Namespaced: The Custom Resource exists within a specific namespace (e.g., training-sim-west). This is typical for workload-like resources.
  • Cluster-Scoped: The Custom Resource is visible across the entire cluster (e.g., a ClusterSimulationPolicy). This is used for cluster-wide configuration. The scope cannot be changed after the CRD is created.
KUBERNETES EXTENSION MECHANISM

How Does a Custom Resource Definition Work?

A Custom Resource Definition (CRD) is the fundamental Kubernetes API extension that allows users to define and manage new types of resources, called Custom Resources, which behave like native Kubernetes objects such as Pods or Deployments.

A Custom Resource Definition (CRD) is a Kubernetes API extension that defines a new, custom resource type and its schema. When applied to a cluster, it instructs the Kubernetes API server to create a new RESTful endpoint for managing instances of that resource, called Custom Resources. This mechanism allows users to extend the Kubernetes API with domain-specific objects that integrate seamlessly with native tools like kubectl and the cluster's control plane, enabling the declarative management of complex applications and infrastructure.

The power of a CRD is realized when paired with a custom controller implementing the Operator Pattern. This controller is a control loop that watches for changes to Custom Resource objects and takes action to reconcile the actual state of the system with the desired state declared in the resource's spec. This automates operational knowledge, such as deploying an application, scaling a database, or managing a complex simulation workload, by encoding human expertise into software that runs inside the Kubernetes cluster itself.

KUBERNETES EXTENSIBILITY

Common Use Cases for CRDs

Custom Resource Definitions (CRDs) are the fundamental building block for extending the Kubernetes API. They enable users to define and manage new types of resources that behave like native Kubernetes objects. This section details the primary patterns for leveraging CRDs in modern infrastructure and application management.

01

Defining Application-Specific Objects

CRDs allow teams to model their own domain concepts as first-class Kubernetes resources. This is the core use case for encapsulating complex application configurations.

  • Examples: Defining a Database resource with fields for engine, version, storage size, and backup schedules, or a ModelDeployment resource specifying framework, GPU requirements, and scaling policies.
  • Benefit: This creates a declarative API that integrates seamlessly with Kubernetes tooling (kubectl, GitOps, RBAC). Operators and controllers can then watch these custom objects and execute the necessary logic to reconcile the actual state with the declared state.
02

Implementing the Operator Pattern

CRDs are the declarative component of the Operator Pattern, which packages human operational knowledge into software. A custom controller watches the CRD instances and takes action.

  • How it works: A user creates a YAML for a custom resource (e.g., etcdCluster). The custom controller detects this new object and automatically provisions pods, configures networking, and handles backups or failover.
  • Real-world use: The Prometheus Operator defines a ServiceMonitor CRD to declaratively manage how Prometheus discovers targets. The Cert-Manager uses Certificate and Issuer CRDs to automate TLS certificate lifecycle management.
03

Orchestrating Complex Workflows & Pipelines

CRDs provide a structured way to define and manage multi-step processes, such as CI/CD pipelines, data processing jobs, or ML training runs, as Kubernetes-native objects.

  • Key Example: The Argo Workflows project defines a Workflow CRD. Each step in a pipeline becomes a Kubernetes Pod, and the workflow engine manages dependencies and execution order.
  • Advantage: This leverages Kubernetes' scheduling, resilience, and observability for workflow steps. Users can kubectl get workflows to see status, and logs are aggregated through standard Kubernetes mechanisms.
04

Managing External Services & Cloud Resources

CRDs enable the Kubernetes-native management of external infrastructure through controllers that act as a bridge to cloud provider APIs (AWS, GCP, Azure).

  • Mechanism: A controller watches for CRDs like S3Bucket or PostgreSQLInstance. When one is created, the controller calls the respective cloud API to provision the resource and updates the CRD's status field.
  • Crossplane: This project is built entirely on this concept, using Composite Resource Definitions (XRDs)—an advanced form of CRD—to define and compose cloud infrastructure. It allows declaring a full application stack (cluster, database, cache) using Kubernetes YAML.
05

Standardizing Internal Platform Configuration

Platform engineering teams use CRDs to create self-service abstractions for developers, hiding the complexity of underlying infrastructure.

  • Internal Platform as a Product: Teams can define CRDs for FeatureFlag, CanaryRelease, or Quota that enforce organizational policies and best practices.
  • Governance: Platform controllers can validate these resources, ensure compliance, and automatically generate the necessary underlying Kubernetes primitives (Deployments, ConfigMaps, NetworkPolicies). This provides a consistent, auditable interface for application teams.
06

Extending Service Mesh & Networking Rules

Service meshes like Istio and Linkerd heavily utilize CRDs to allow users to declaratively manage traffic routing, security policies, and observability settings.

  • Istio's API: It defines CRDs such as VirtualService (for routing rules), DestinationRule (for load balancing policies), and AuthorizationPolicy (for access control).
  • Impact: Network operators can apply these resources using kubectl apply, and the Istio control plane dynamically reconfigures the data plane (Envoy proxies) without requiring manual intervention or application redeployment. This decouples traffic management from application code.
KUBERNETES EXTENSIBILITY

Frequently Asked Questions

A Custom Resource Definition (CRD) is the fundamental Kubernetes extension mechanism for creating new API objects. This FAQ clarifies its purpose, mechanics, and role in modern infrastructure.

A Custom Resource Definition (CRD) is a Kubernetes API extension mechanism that allows users to define and introduce new types of resources, called Custom Resources, which behave like native Kubernetes objects such as Pods or Deployments. It works by extending the Kubernetes API server with a new schema that defines the structure (the CRD) and a controller that implements the business logic to reconcile the actual state of the system with the desired state declared in the Custom Resource. When you apply a CRD manifest, the API server creates a new RESTful endpoint (e.g., /apis/yourcompany.com/v1/yourresources). You can then create instances of your Custom Resource using YAML or JSON, and your controller watches for changes to those objects to take action.

Example CRD for a 'Database' resource:

yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: databases.yourcompany.com
spec:
  group: yourcompany.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                engine:
                  type: string
                version:
                  type: string
  scope: Namespaced
  names:
    plural: databases
    singular: database
    kind: Database
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.