Solutions
Solution 1 — Reading and reasoning
- Custom Resource
apiVersion:
yaml
apiVersion: security.example.com/v1- kubectl get command:
bash
kubectl get accesspolicies- Namespace requirement:
- Yes. The CRD scope is
Namespaced, sometadata.namespaceis required.
- Correct CRD name format:
text
<plural>.<group> → accesspolicies.security.example.comSolution 2 — Fix the broken CRD
- What is wrong:
metadata.namedoes not matchspec.names.plural + "." + spec.group.
- Fixed CRD:
yaml
metadata:
name: accesspolicies.security.example.com- Why Kubernetes rejects the original:
- Kubernetes requires the CRD name to be exactly
plural.group; otherwise the API cannot be registered.
Solution 3 — FeatureToggle CRD and CR
CustomResourceDefinition
yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: featuretoggles.config.example.com
spec:
group: config.example.com
scope: Namespaced
names:
plural: featuretoggles
singular: featuretoggle
kind: FeatureToggle
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
enabled:
type: boolean
description:
type: stringCustom Resource
yaml
apiVersion: config.example.com/v1
kind: FeatureToggle
metadata:
name: new-ui
namespace: default
spec:
enabled: trueSolution 4 — Schema validation failure
- Why the CR is rejected:
- The value type does not match the CRD schema.
- Field causing the issue:
text
spec.enabled- Correct value type:
text
boolean (true or false)Solution 5 — kubectl explain
- Inspect the Custom Resource:
bash
kubectl explain featuretoggles- Inspect the
spec.enabledfield:
bash
kubectl explain featuretoggles.spec.enabled- Why this is useful in the exam:
- It shows field names, types, and descriptions without opening YAML files.
Solution 6 — Cluster vs Namespaced trap
- What will go wrong:
- The CR will be rejected because cluster-scoped resources cannot have a namespace.
- How to fix it:
- Remove
metadata.namespacefrom the CR.
- Which object is incorrect:
- The Custom Resource (CR), not the CRD.
Solution 7 — Fast recognition drill
Given:
text
CRD name: backups.storage.example.comGroup:
textstorage.example.comPlural:
textbackupsKind:
textBackupkubectl get command:
bashkubectl get backups