0
0
Kubernetesdevops~20 mins

Custom Resource Definitions (CRDs) in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CRD Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the primary purpose of a Custom Resource Definition (CRD) in Kubernetes?

Choose the best description of what a CRD does in a Kubernetes cluster.

AIt allows users to define new resource types that behave like built-in Kubernetes objects.
BIt automatically scales pods based on CPU usage.
CIt manages network policies between pods.
DIt schedules pods to specific nodes based on resource availability.
Attempts:
2 left
💡 Hint

Think about how Kubernetes can be extended to manage new types of objects.

💻 Command Output
intermediate
1:30remaining
What is the output of this command after creating a CRD?

You run kubectl get crds after applying a CRD manifest named widgets.example.com. What will you see?

Kubernetes
kubectl get crds
A
NAME                  CREATED AT
widgets.example.com    2024-06-01T12:00:00Z
BNo resources found in default namespace.
CError from server (NotFound): crds "widgets.example.com" not found
D
NAME                  READY   STATUS    RESTARTS   AGE
widgets.example.com    True    Running   0          5m
Attempts:
2 left
💡 Hint

Remember that CRDs are cluster-wide resources, not namespace-scoped.

Configuration
advanced
2:00remaining
Identify the error in this CRD manifest snippet

Review this CRD YAML snippet and select the option that correctly identifies the error.

Kubernetes
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: gadgets.example.com
spec:
  group: example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                size:
                  type: integer
  scope: Namespaced
  names:
    plural: gadgets
    singular: gadget
    kind: Gadget
    listKind: GadgetList
AThe 'versions' list is missing the 'subresources' field, which is mandatory.
BThe 'schema' field should be 'schema.openAPIV3Schema' under 'versions', but here it is correct.
CThe 'metadata.name' must be the plural form plus the group, which is correct here.
DThe 'scope' field value 'Namespaced' is invalid; it should be lowercase 'namespaced'.
Attempts:
2 left
💡 Hint

Check the indentation and field names carefully under 'versions'.

Troubleshoot
advanced
2:00remaining
Why does this CRD fail to create?

You apply a CRD manifest but get the error: error: unable to recognize "crd.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1". What is the cause?

AThe 'kind' field should be 'CustomResource' instead of 'CustomResourceDefinition'.
BThe CRD manifest is missing the 'metadata' section.
CThe API version 'apiextensions.k8s.io/v1beta1' is deprecated and no longer supported in recent Kubernetes versions.
DThe Kubernetes cluster does not have the CRD controller installed.
Attempts:
2 left
💡 Hint

Check the API version compatibility with your Kubernetes cluster version.

🔀 Workflow
expert
2:30remaining
Order the steps to create and use a new CRD in Kubernetes

Put these steps in the correct order to successfully create and use a new Custom Resource Definition.

A2,1,3,4
B3,1,2,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint

You must define and register the CRD before creating custom resources.