DevOps Bootcamp · Lesson

Custom Resource Definitions (CRDs)

Learn how Custom Resource Definitions extend the Kubernetes API with your own resource types, the foundation that Operators build on.

Lesson 4 of 413 steps

Custom Resource Definitions (CRDs) is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 4 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

Extending the Kubernetes API

Built-in objects like Pods and Deployments are not the limit. With a Custom Resource Definition (CRD) you can teach Kubernetes entirely new resource types.

What Is a Custom Resource?

A Custom Resource (CR) is an instance of a type you defined. Once a CRD is installed, you create CRs with kubectl just like native objects.

Anatomy of a CRD

A CRD declares the new kind, its API group, version, and scope (namespaced or cluster-wide).

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: backups.data.example.com
spec:
  group: data.example.com
  scope: Namespaced
  names:
    plural: backups
    singular: backup
    kind: Backup

Defining the Schema

An OpenAPI schema validates the fields of your custom resource, rejecting invalid specs at creation time.

versions:
- name: v1
  served: true
  storage: true
  schema:
    openAPIV3Schema:
      type: object
      properties:
        spec:
          type: object
          properties:
            schedule:
              type: string
            retention:
              type: integer

Creating a Custom Resource

After the CRD is applied, you create instances of your new type.

apiVersion: data.example.com/v1
kind: Backup
metadata:
  name: nightly-db
spec:
  schedule: '0 2 * * *'
  retention: 7

Working with CRs via kubectl

Custom resources are first-class. You list, describe, and delete them with familiar commands.

kubectl get backups
kubectl describe backup nightly-db
kubectl delete backup nightly-db

Short Names and Printer Columns

You can define short names and custom table columns to make CRs pleasant to work with.

names:
  shortNames: ['bk']
additionalPrinterColumns:
- name: Schedule
  type: string
  jsonPath: .spec.schedule

CRDs Are Just Data

By itself, a CRD only stores data in etcd. Nothing acts on it. To make a Backup actually happen, you need a controller watching these resources.

The Link to Operators

An Operator is a controller plus one or more CRDs. The CRD defines the desired state; the controller continuously reconciles reality to match it. CRDs are the foundation Operators stand on.

Versioning CRDs

CRDs support multiple versions with conversion, letting you evolve your API. Exactly one version is marked as the storage version in etcd.

versions:
- name: v1beta1
  served: true
  storage: false
- name: v1
  served: true
  storage: true

When to Use CRDs

  • You want to model a domain concept declaratively (Backup, Database, Certificate)
  • You are building an Operator to automate operations
  • You want users to manage your app with familiar kubectl workflows

Quick Check

Test your CRD understanding.

Recap

You learned that CRDs extend the Kubernetes API with custom types, validated by an OpenAPI schema and managed with normal kubectl commands. A CRD alone just stores data; pairing it with a controller produces an Operator that reconciles desired state.

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “Custom Resource Definitions (CRDs)” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Custom Resource Definitions (CRDs)”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “Custom Resource Definitions (CRDs)”?

Learn how Custom Resource Definitions extend the Kubernetes API with your own resource types, the foundation that Operators build on. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.

How long does the “Custom Resource Definitions (CRDs)” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. StatefulSets for Stateful Apps
  2. DaemonSets for Node-Specific Tasks
  3. Understanding Kubernetes Operators
  4. Custom Resource Definitions (CRDs)
← Back to DevOps Bootcamp