Skip to content

Commit

Permalink
feat: install CRDs from a subchart
Browse files Browse the repository at this point in the history
ROBLEM: Helm 3 only install CRDs during the chart installation. Both
deletes and upgrades are not handled by Helm 3. It requires manual
intervention. Additionally, it is not possible to template CRDs. This is
especially important when installing the chart with an Argo CD
application.

SOLUTION: add the possibility to install the CRDs from a dependency
subchart. This allows clean uninstall, possibility for automated
upgrades, and templating. This feature comes disabled by default.

closes #1637

Signed-off-by: cmontemuino <[email protected]>
  • Loading branch information
cmontemuino committed Oct 22, 2024
1 parent 91f631b commit 2ec2038
Show file tree
Hide file tree
Showing 9 changed files with 754 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deployment/helm/node-feature-discovery/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ keywords:
- node-labels
type: application
version: 0.2.1
dependencies:
- name: crds
version: 0.0.0
condition: crds.install
3 changes: 3 additions & 0 deletions deployment/helm/node-feature-discovery/charts/crds/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: v2
name: crds
version: 0.0.0
9 changes: 9 additions & 0 deletions deployment/helm/node-feature-discovery/charts/crds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# crds

![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-informational?style=flat-square)

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| annotations | object | `{}` | Define annotations for CRDs |

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -- Define annotations for CRDs
annotations: {}
# argocd.argoproj.io/sync-options: Replace=false,ServerSideApply=true
7 changes: 7 additions & 0 deletions deployment/helm/node-feature-discovery/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ featureGates:

priorityClassName: ""

## Custom resource configuration defined as a dependency chart
crds:
# -- Toggle to install and upgrade CRDs from a subchart. Make sure to use it with `--skip-crds` to avoid conflicts. [More info about limitations on CRDs in Helm 3](https://helm.sh/docs/topics/charts/#limitations-on-crds)
install: false
# -- Annotations to be added to all CRDs
annotations: {}

master:
enable: true
extraArgs: []
Expand Down
2 changes: 2 additions & 0 deletions docs/deployment/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ Chart parameters are available.

| Name | Type | Default | Description |
| --------------------------------------------------- | ------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `crds.install` | bool | false | Toggle to install and upgrade CRDs from a subchart. Make sure to use it with `--skip-crds` to avoid conflicts. [More info about limitations on CRDs in Helm 3](https://helm.sh/docs/topics/charts/#limitations-on-crds) |
| `crds.annotations` | object | {} | Annotations to be added to all CRDs |
| `image.repository` | string | `{{ site.container_image \| split: ":" \| first }}` | NFD image repository |
| `image.tag` | string | `{{ site.release }}` | NFD image tag |
| `image.pullPolicy` | string | `Always` | Image pull policy |
Expand Down
3 changes: 3 additions & 0 deletions hack/crds.annotations.snippet.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- with .Values.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
4 changes: 4 additions & 0 deletions hack/update_codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ NFD_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
controller-gen object crd output:crd:stdout paths=./api/... > deployment/base/nfd-crds/nfd-api-crds.yaml
mkdir -p deployment/helm/node-feature-discovery/crds
cp deployment/base/nfd-crds/nfd-api-crds.yaml deployment/helm/node-feature-discovery/crds
mkdir -p deployment/helm/node-feature-discovery/charts/crds/templates
for f in deployment/base/nfd-crds/*-crds.yaml; do
sed '/controller-gen.kubebuilder.io\/version/ r hack/crds.annotations.snippet.txt' ${f} > deployment/helm/node-feature-discovery/charts/crds/templates/${f##*/}
done

# Generate clientset and informers
mv vendor ${TMP_VENDOR_DIR}
Expand Down

0 comments on commit 2ec2038

Please sign in to comment.