CKAD field manual

k8s CRD YAML example

A CRD is the type. The custom resource is an instance. Same short name can exist in two groups.

A holomap plant in a neon jungle — a new kind on the table. A holomap plant in a neon jungle — a new kind on the table.
Find
kubectl get crd
kubectl api-resources -o name | grep example.io
kubectl get backups.example.io -A
CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: backups.example.io
spec:
  group: example.io
  scope: Namespaced
  names:
    plural: backups
    singular: backup
    kind: Backup
    shortNames: ["bak"]
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                keep:
                  type: integer
Instance
apiVersion: example.io/v1
kind: Backup
metadata:
  name: nightly
  namespace: app
spec:
  keep: 7

Fields

name
metadata.name must be <plural>.<group>. backups.example.io.
group
The API group. Distinguishes two CRDs that share a kind name.
scope
Namespaced or Cluster. Same idea as Role vs ClusterRole.
storage
Exactly one version is storage: true. The others can be served.
kubectl api-resources
kubectl api-resources -o name | grep example.io. Use the full name if short names collide.

Watch

  • metadata.name is plural.group — backups.example.io. Wrong and the CRD never establishes.
  • Two CRDs can share kind Backup. Disambiguate with the full name: backups.mycompany.io.
  • kubectl get backup uses the short name. If two groups serve it, specify the full name.

Official docs Custom Resources

Practice these objects on a live cluster →