Skip to content
tezvyn:
Menu

What is a Custom Resource Definition?

Source: interviewEasyHow cards are made

Summary

extending the Kubernetes API.

Key points

a CRD registers a new resource kind so the API server stores and serves it like built-ins; it lets you model domain concepts declaratively.

Watch out for

confusing the CRD with the controller that acts on it.

What's really being asked

Whether you understand that Kubernetes is extensible and that a CRD adds a new first-class resource type to the API server.

The full answer

A Custom Resource Definition is itself a Kubernetes object that registers a brand-new kind of resource with the API server. It specifies an API group, one or more versions, a kind name, scope (namespaced or cluster), and an OpenAPI schema for validation. Once applied, the API server begins storing, validating, and serving instances of that new kind, and you can manage them with kubectl get, describe, and apply just like Deployments or Services, including RBAC, labels, and watches. The problem it solves is representing domain-specific or application-specific concepts declaratively inside Kubernetes, for example a Database, a Certificate, or a Backup, without modifying or recompiling Kubernetes itself. Importantly, a CRD only defines the type and stores the data; it does not by itself do anything. To give a custom resource behavior you pair it with a controller or operator that watches instances and reconciles real-world state.

The mistakes people make

Thinking a CRD includes the logic that acts on the resource, confusing the CRD with the operator, or believing you must patch the Kubernetes source to add a resource type.

What usually comes next

How does a CRD differ from an aggregated API server? How do CRDs relate to operators? How do you version a CRD schema?

A concrete example

cert-manager ships a CRD for Certificate. Applying the CRD teaches the API server about Certificate objects, so kubectl get certificates works. The CRD alone stores the desired certificate spec; cert-manager's controller watches those objects and actually issues and renews TLS certificates, demonstrating the split between the type definition and the acting controller.

Interview question

After you apply a CRD for a new Backup kind, what happens automatically without any further components?

  • a.All existing pods are restarted to pick up the new type
  • b.Kubernetes immediately starts performing backups for matching resources
  • c.The API server stores and serves Backup objects, but nothing acts on them yetCorrect
  • d.A controller is auto-generated to reconcile Backup instances
Why?

A CRD only registers the type so the API server can persist and serve instances; it adds no behavior. Acting on those objects requires a separately deployed controller or operator.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles