Skip to main content

Custom Resource Definitions

Why CRDs Were Born

Picture a toolbox. Kubernetes ships with standard tools like Pods, Services, Deployments. But what if your team needs a special wrench that doesn’t exist yet? Instead of waiting for Kubernetes to invent it, you can design your own.

Custom Resource Definitions (CRDs) were born as the custom tools of Kubernetes, allowing engineers to extend the API with new resource types tailored to their applications.


The CRD Model

  • Custom Resources: User‑defined objects (e.g. Database, Queue, Cache).
  • CRDs: Define schema and behavior for those custom resources.
  • kubectl Integration: Once defined, custom resources behave like native Kubernetes objects.

Analogy: CRDs are like adding new Lego blocks to your set so you can build anything beyond the default pieces.


Global Context

  • Enterprises: Use CRDs to manage complex applications (databases, message queues, ML pipelines).
  • Cloud Providers: Operators built on CRDs manage cloud services (e.g. Prometheus Operator, MySQL Operator).
  • Community: CRDs are the foundation of Kubernetes extensibility, powering the operator ecosystem.

Hands‑On Exercise

  1. Reflect: How does this behave like a native Kubernetes object, yet extend functionality beyond built‑ins?

Create a custom resource:

apiVersion: myorg.com/v1
kind: Database
metadata:
  name: mydb
spec:
  engine: postgres
  version: "14"

Define a CRD:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: databases.myorg.com
spec:
  group: myorg.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
    shortNames:
    - db

The Hacker’s Notebook

  • CRDs are Lego blocks for custom extensions.
  • Custom resources behave like native objects.
  • Lesson for engineers: Don’t wait for Kubernetes to add features and extend it yourself.
  • Hacker’s mindset: Treat CRDs as your innovation engine. With them, you can tailor Kubernetes to any workload.

Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff ♥

Updated on Dec 30, 2025