CodeBlanks Logo Icon CodeBlanks

Challenge - CRD

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: 30

The 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

terminal
# buraya yaz

Sample solution

terminal
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

terminal
# buraya yaz

Sample solution

terminal
kubectl apply -f crd.yaml
kubectl get crd yedekler.platform.sirket.com
kubectl apply -f yedek.yaml
kubectl get yd -n magaza

Expected 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.

Question
  scope: ____
Answer
  scope: Namespaced

Explanation: It can be Namespaced or Cluster.

3 Match.

Term Meaning
group platform.sirket.com
plural yedekler
shortNames yd
kind Yedek

All lessons in Expert