0
0
Kubernetesdevops~20 mins

Custom resources concept in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Custom Resources Mastery
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 in Kubernetes?

In Kubernetes, what is the main reason to create a Custom Resource?

ATo create a new namespace automatically for each deployment
BTo replace the Kubernetes API server with a custom implementation
CTo extend Kubernetes with new object types beyond built-in resources
DTo manage user authentication and authorization
Attempts:
2 left
💡 Hint

Think about how Kubernetes can be customized to manage new kinds of objects.

💻 Command Output
intermediate
1:30remaining
Output of listing Custom Resource Definitions

What is the output of the command kubectl get crd in a Kubernetes cluster with two Custom Resource Definitions named widgets.example.com and gadgets.example.com?

Kubernetes
kubectl get crd
A
NAME                   STATUS
widgets.example.com     Active
gadgets.example.com     Active
B
NAME                   CREATED AT
widgets.example.com     2024-01-01T12:00:00Z
gadgets.example.com     2024-01-02T12:00:00Z
CNo resources found in default namespace.
DError from server (NotFound): customresourcedefinitions.apiextensions.k8s.io not found
Attempts:
2 left
💡 Hint

Think about what kubectl get crd lists and the typical columns shown.

Configuration
advanced
2:30remaining
Correct YAML for defining a Custom Resource Definition

Which YAML snippet correctly defines a Custom Resource Definition (CRD) for a resource named widgets in group example.com with version v1?

A
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: widgets.example.com
spec:
  group: example.com
  versions:
  - name: v1
    served: true
    storage: true
  scope: Namespaced
  names:
    plural: widgets
    kind: Widget
B
apiVersion: v1
kind: CustomResourceDefinition
metadata:
  name: widgets.example.com
spec:
  group: example.com
  version: v1
  scope: Cluster
  names:
    plural: widgets
    kind: Widget
C
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: widgets
spec:
  group: example.com
  versions:
  - name: v1
    served: false
    storage: true
  scope: Namespaced
  names:
    plural: widgets
    kind: Widget
D
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: widgets.example.com
spec:
  group: example.com
  versions:
  - name: v1
    served: true
    storage: true
  scope: Namespaced
  names:
    plural: widgets
    singular: widget
    kind: Widget
    shortNames:
    - wdg
Attempts:
2 left
💡 Hint

Check the API version and the structure of the spec section for CRDs.

🔀 Workflow
advanced
2:00remaining
Order of steps to create and use a Custom Resource

Arrange the steps in the correct order to create and use a Custom Resource in Kubernetes.

A1,3,2,4
B3,1,2,4
C1,2,3,4
D2,1,3,4
Attempts:
2 left
💡 Hint

Think about registering the CRD before creating resources and verifying registration before usage.

Troubleshoot
expert
2:30remaining
Reason for 'no matches for kind' error when applying a Custom Resource

You applied a Custom Resource YAML manifest but got the error: error: unable to recognize "widget.yaml": no matches for kind "Widget" in version "example.com/v1". What is the most likely cause?

AThe Custom Resource Definition (CRD) for kind Widget is not installed or not yet registered in the cluster.
BThe user does not have permission to create Custom Resources.
CThe Kubernetes API server is down and cannot process the request.
DThe YAML manifest has a syntax error in the spec section of the Custom Resource.
Attempts:
2 left
💡 Hint

Consider whether the cluster knows about the new resource kind before you create instances.