CodeBlanks Logo Icon CodeBlanks

What is a CRD?

Learn to define custom resources with a CRD.

What is a CRD?

A CustomResourceDefinition (CRD) adds a new resource type to the Kubernetes API. After the CRD is applied, that type is created and listed with kubectl, protected with RBAC and stored in etcd just like the built-in types. The Prometheus Operator's ServiceMonitor and cert-manager's Certificate are CRDs.

$ kubectl get crds
NAME                                     CREATED AT
certificates.cert-manager.io             2026-10-20T09:12:01Z
servicemonitors.monitoring.coreos.com    2026-10-21T14:03:44Z
yedekler.ornek.com                       2026-11-03T08:30:10Z

A CRD on its own only stores data; the part that does something based on that data is a controller (an operator, next group).

Extending the API

A type added with a CRD appears in kubectl api-resources, and kubectl explain generates documentation from the type definition. That way you can express your own platform concepts (Backup, Database, Environment) in Kubernetes's language:

$ kubectl api-resources --api-group=ornek.com
NAME       SHORTNAMES   APIVERSION     NAMESPACED   KIND
yedekler   yd           ornek.com/v1   true         Yedek
$ kubectl explain yedek.spec

Practice Explore CRDs

Write three commands: list the CRDs; list the types in the ornek.com API group; show the documentation of the yedek.spec field.

Starter code

terminal
# buraya yaz

Sample solution

terminal
kubectl get crds
kubectl api-resources --api-group=ornek.com
kubectl explain yedek.spec

Expected output

NAME                 CREATED AT
yedekler.ornek.com   2026-11-03T08:30:10Z
NAME       SHORTNAMES   APIVERSION     NAMESPACED   KIND
yedekler   yd           ornek.com/v1   true         Yedek
GROUP:      ornek.com
KIND:       Yedek
FIELD:      spec <Object>

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What happens if you only install a CRD and create a custom resource?

  • The object is stored, but without a controller processing it, no action happens Correct answer
  • Pods are created automatically
  • It errors
  • Kubernetes restarts

Explanation: CRD = data model; controller = behaviour.

2 List the types of a specific API group.

Question
kubectl api-resources ____=ornek.com
Answer
kubectl api-resources --api-group=ornek.com

Explanation: --api-group filters by group.

3 Match.

Term Meaning
CRD New type definition
custom resource An object of that type
denetleyici Behaviour
ServiceMonitor A CRD example

All lessons in Expert