Kubernetes YAML Kustomize and CRDs/Basic CustomResourceDefinition YAML

Define a namespaced custom API.

Section: CRDs and Custom Resources

Basic CustomResourceDefinition YAML

yaml
yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: widgets.example.com
spec:
  group: example.com
  names:
    plural: widgets
    singular: widget
    kind: Widget
    shortNames: ["wdg"]
  scope: Namespaced
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                size:
                  type: string
Explanation

CRDs let you extend the Kubernetes API with your own resource types and versions.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing CRDs and Custom Resources
Custom resource instance YAML
Create an object for the custom API.
OpenIn sheetyamlsame section
Explain a CRD schema path
Inspect CRD structure from kubectl.
OpenIn sheetbashsame section
Minimal kustomization.yaml
List resource YAML files managed together.
Patch replicas via overlay
Set environment-specific replica count.
Apply a kustomization directory
Use kubectl's built-in Kustomize support.
Generate ConfigMap from literals
Create config objects as part of the build.