Skip to content

Commit c60d355

Browse files
committed
helm: install CRDs from a subchart
PROBLEM: 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 kubernetes-sigs#1637 Signed-off-by: cmontemuino <[email protected]>
1 parent 91f631b commit c60d355

File tree

9 files changed

+754
-0
lines changed

9 files changed

+754
-0
lines changed

deployment/helm/node-feature-discovery/Chart.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ keywords:
1313
- node-labels
1414
type: application
1515
version: 0.2.1
16+
dependencies:
17+
- name: crds
18+
version: 0.0.0
19+
condition: crds.install
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
apiVersion: v2
2+
name: crds
3+
version: 0.0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# crds
2+
3+
![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-informational?style=flat-square)
4+
5+
## Values
6+
7+
| Key | Type | Default | Description |
8+
|-----|------|---------|-------------|
9+
| annotations | object | `{}` | Define annotations for CRDs |

deployment/helm/node-feature-discovery/charts/crds/templates/nfd-api-crds.yaml

+719
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -- Define annotations for CRDs
2+
annotations: {}
3+
# argocd.argoproj.io/sync-options: Replace=false,ServerSideApply=true

deployment/helm/node-feature-discovery/values.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ featureGates:
1616

1717
priorityClassName: ""
1818

19+
## Custom resource configuration defined as a dependency chart
20+
crds:
21+
# -- 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)
22+
install: false
23+
# -- Annotations to be added to all CRDs
24+
annotations: {}
25+
1926
master:
2027
enable: true
2128
extraArgs: []

docs/deployment/helm.md

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ Chart parameters are available.
149149

150150
| Name | Type | Default | Description |
151151
| --------------------------------------------------- | ------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
152+
| `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) |
153+
| `crds.annotations` | object | {} | Annotations to be added to all CRDs |
152154
| `image.repository` | string | `{{ site.container_image \| split: ":" \| first }}` | NFD image repository |
153155
| `image.tag` | string | `{{ site.release }}` | NFD image tag |
154156
| `image.pullPolicy` | string | `Always` | Image pull policy |

hack/crds.annotations.snippet.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{- with .Values.annotations }}
2+
{{- toYaml . | nindent 4 }}
3+
{{- end }}

hack/update_codegen.sh

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ NFD_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
4444
controller-gen object crd output:crd:stdout paths=./api/... > deployment/base/nfd-crds/nfd-api-crds.yaml
4545
mkdir -p deployment/helm/node-feature-discovery/crds
4646
cp deployment/base/nfd-crds/nfd-api-crds.yaml deployment/helm/node-feature-discovery/crds
47+
mkdir -p deployment/helm/node-feature-discovery/charts/crds/templates
48+
for f in deployment/base/nfd-crds/*-crds.yaml; do
49+
sed '/controller-gen.kubebuilder.io\/version/ r hack/crds.annotations.snippet.txt' ${f} > deployment/helm/node-feature-discovery/charts/crds/templates/${f##*/}
50+
done
4751

4852
# Generate clientset and informers
4953
mv vendor ${TMP_VENDOR_DIR}

0 commit comments

Comments
 (0)