Challenge - CRD
- Docker & Kubernetes course
- Expert
- Lesson 43/47
- 5 min
Write a CRD YAML for a custom resource.
Challenge: a Yedek CRD
In this challenge you'll define a custom resource type called Yedek for the platform team. Developers will request a database backup by writing this object:
apiVersion: platform.sirket.com/v1
kind: Yedek
metadata:
name: magaza-db
namespace: magaza
spec:
veritabani: veri-db
zamanlama: "0 2 * * *"
saklamaGun: 30The CRD's group will be platform.sirket.com, its plural name yedekler, its short name yd; the objects are namespaced.
Practice CRD header and names
Write the first part of the CRD YAML: apiextensions.k8s.io/v1, CustomResourceDefinition; name yedekler.platform.sirket.com; under spec, group: platform.sirket.com, scope: Namespaced and under names, kind: Yedek, plural: yedekler, singular: yedek, shortNames: [yd].
Starter code
# buraya yazSample solution
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: yedekler.platform.sirket.com
spec:
group: platform.sirket.com
scope: Namespaced
names:
kind: Yedek
plural: yedekler
singular: yedek
shortNames: [yd]Expected output
# crd.yaml (ilk kısım) hazır; sürüm tanımı sonraki adımda eklenecek
Practice Use the CRD
Write four commands: apply crd.yaml; see the CRD's record (kubectl get crd yedekler.platform.sirket.com); apply yedek.yaml; list the backups in magaza by the short name (kubectl get yd -n magaza).
Starter code
# buraya yazSample solution
kubectl apply -f crd.yaml
kubectl get crd yedekler.platform.sirket.com
kubectl apply -f yedek.yaml
kubectl get yd -n magazaExpected output
customresourcedefinition.apiextensions.k8s.io/yedekler.platform.sirket.com created NAME CREATED AT yedekler.platform.sirket.com 2026-11-03T08:12:40Z yedek.platform.sirket.com/magaza-db created NAME AGE magaza-db 5s
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What must this CRD's metadata.name be?
- yedekler.platform.sirket.com Correct answer
- yedek
- Yedek.platform.sirket.com
- platform.sirket.com
Explanation: The CRD name is the plural name joined with the group.
2 Make the objects namespaced.
scope: ____
scope: Namespaced
Explanation: It can be Namespaced or Cluster.
3 Match.
| Term | Meaning |
|---|---|
group |
platform.sirket.com |
plural |
yedekler |
shortNames |
yd |
kind |
Yedek |