github.com/koderover/helm@v2.17.0+incompatible/docs/chart_best_practices/custom_resource_definitions.md (about)

     1  # Custom Resource Definitions
     2  
     3  This section of the Best Practices Guide deals with creating and using Custom Resource Definition
     4  objects.
     5  
     6  When working with Custom Resource Definitions (CRDs), it is important to distinguish
     7  two different pieces:
     8  
     9  - There is a declaration of a CRD. This is the YAML file that has the kind `CustomResourceDefinition`
    10  - Then there are resources that _use_ the CRD. Say a CRD defines `foo.example.com/v1`. Any resource
    11    that has `apiVersion: example.com/v1` and kind `Foo` is a resource that uses the CRD.
    12  
    13  ## Install a CRD Declaration Before Using the Resource
    14  
    15  Helm is optimized to load as many resources into Kubernetes as fast as possible.
    16  By design, Kubernetes can take an entire set of manifests and bring them all
    17  online (this is called the reconciliation loop).
    18  
    19  But there's a difference with CRDs.
    20  
    21  For a CRD, the declaration must be registered before any resources of that CRDs
    22  kind(s) can be used. And the registration process sometimes takes a few seconds.
    23  
    24  ### Method 1: Separate Charts
    25  
    26  One way to do this is to put the CRD definition in one chart, and then put any
    27  resources that use that CRD in _another_ chart.
    28  
    29  In this method, each chart must be installed separately.
    30  
    31  ### Method 2: Crd-install Hooks
    32  
    33  To package the two together, add a `crd-install` hook to the CRD definition so
    34  that it is fully installed before the rest of the chart is executed.
    35  
    36  Note that if you create the CRD with a `crd-install` hook, that CRD definition
    37  will not be deleted when `helm delete` is run.