mongodb / helm-charts

Apache License 2.0
99 stars 92 forks source link

community-operator-crds should have the custom resource definition in the "crds" subdirectory #282

Closed bbergquist0930 closed 9 months ago

bbergquist0930 commented 1 year ago

Helm 3.0 specifies that a custom resource definition should be located within the crds subdirectory. When located there, Helm will install the custom resource definition before the rest of the chart.

With the current location within the templates subdirectory, this chart cannot be used effectively as a subchart with the parent chart using the custom resource as the custom resource is not installed early enough.

Steps to reproduce the behavior:

  1. Create a helm chart that will have the community-operator as a subchart
    helm create crds-test
    cd crds-test
    rm -rf templates/*
    delete customresourcedefinitions.apiextensions.k8s.io mongodbcommunity.mongodbcommunity.mongodb.com
  2. Add in the community-operator as a dependency
    echo "
    dependencies:
    - name: community-operator
    version: 0.8.3
    repository: https://mongodb.github.io/helm-charts
    " >>Chart.yaml
  3. Build the chart dependencies
    helm repo add mongodb https://mongodb.github.io/helm-charts
    helm dependency build
  4. Add a usage of the custom resource definition to the parent chart
    curl https://raw.githubusercontent.com/mongodb/mongodb-kubernetes-operator/master/config/samples/mongodb.com_v1_mongodbcommunity_cr.yaml --output templates/mongodb.com_v1_mongodbcommunity_cr.yaml
  5. Try to install the chart
6. See error
>Error: INSTALLATION FAILED: unable to build kubernetes objects from release manifest: resource mapping not found for name: "example-mongodb" namespace: "" from "": no matches for kind "MongoDBCommunity" in version "mongodbcommunity.mongodb.com/v1"
>ensure CRDs are installed first

**What did you expect?**
The custom resource definition should have been installed before the custom resource referenced it.

**What happened instead?**
The custom resource definition was not installed and then the reference to it failed when the custom resource reference it.

**Additional context**
Locally I have locally repackaged the community-operator-crds chart with the custom resource definition within the `crds` directory and locally repackaged the community-operator chart pointing to this local community-operator-crds.  

cat Chart.yaml apiVersion: v2 name: parent-chart description: A Helm chart for Kubernetes

A chart can be either an 'application' or a 'library' chart.

#

Application charts are a collection of templates that can be packaged into versioned archives

to be deployed.

#

Library charts provide useful utilities or functions for the chart developer. They're included as

a dependency of application charts to inject those utilities and functions into the rendering

pipeline. Library charts do not define any templates and therefore cannot be deployed.

type: application

This is the chart version. This version number should be incremented each time you make changes

to the chart and its templates, including the app version.

Versions are expected to follow Semantic Versioning (https://semver.org/)

version: 0.1.0

This is the version number of the application being deployed. This version number should be

incremented each time you make changes to the application. Versions are not expected to

follow Semantic Versioning. They should reflect the version the application is using.

It is recommended to use it with quotes.

appVersion: "1.16.0"

dependencies:

bbergquist0930 commented 1 year ago

crds-test.zip

ZIP file of the project that follows the instructions above

github-actions[bot] commented 10 months ago

This issue is being marked stale because it has been open for 60 days with no activity. Please comment if this issue is still affecting you. If there is no change, this issue will be closed in 30 days.

github-actions[bot] commented 9 months ago

This issue was closed because it became stale and did not receive further updates. If the issue is still affecting you, please re-open it, or file a fresh Issue with updated information.