Skip to content

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

@bbergquist0930

Description

@bbergquist0930

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
  1. 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
  1. Build the chart dependencies
helm repo add mongodb https://mongodb.github.io/helm-charts
helm dependency build
  1. 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
  1. Try to install the chart

  1. 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:
  - name: community-operator-cp
    version: 0.8.3
    repository: "@smm-chart-db-local"

With no other changes, the parent chart can be installed

helm install crds-test .
NAME: crds-test
LAST DEPLOYED: Sun Nov 19 08:10:20 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions