From c53c3411d308f98d275fe893fb6834c6fdbc9b26 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 10 May 2024 12:51:03 +0100 Subject: [PATCH] Move CRDs into templates Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- chart/openfaas/README.md | 8 ++++---- .../iam.openfaas.com_jwtissuers-crd.yaml} | 4 ++++ .../iam.openfaas.com_policies-crd.yaml} | 5 +++++ .../iam.openfaas.com_roles-crd.yaml} | 5 +++++ .../openfaas.com_functioningresses-crd.yaml} | 5 +++++ .../openfaas.com_functions-crd.yaml} | 5 +++++ .../openfaas.com_profiles-crd.yaml} | 4 ++++ hack/update-crds.sh | 7 ++++++- 8 files changed, 38 insertions(+), 5 deletions(-) rename chart/openfaas/{crds/iam.openfaas.com_jwtissuers.yaml => templates/iam.openfaas.com_jwtissuers-crd.yaml} (98%) rename chart/openfaas/{crds/iam.openfaas.com_policies.yaml => templates/iam.openfaas.com_policies-crd.yaml} (98%) rename chart/openfaas/{crds/iam.openfaas.com_roles.yaml => templates/iam.openfaas.com_roles-crd.yaml} (98%) rename chart/openfaas/{crds/openfaas.com_functioningresses.yaml => templates/openfaas.com_functioningresses-crd.yaml} (99%) rename chart/openfaas/{crds/openfaas.com_functions.yaml => templates/openfaas.com_functions-crd.yaml} (99%) rename chart/openfaas/{crds/openfaas.com_profiles.yaml => templates/openfaas.com_profiles-crd.yaml} (99%) diff --git a/chart/openfaas/README.md b/chart/openfaas/README.md index 9d48fd251..e97b553cd 100644 --- a/chart/openfaas/README.md +++ b/chart/openfaas/README.md @@ -174,15 +174,16 @@ kubectl apply -f ./faas-netes/namespaces.yml kubectl apply -f ./faas-netes/artifacts/crds/ ``` -Now, your application team can install OpenFaaS with a Role instead of a ClusterRole. They will also need to pass the `--skip-crds` flag to the helm command. +Now, your application team can install OpenFaaS with a Role instead of a ClusterRole, along with the `skipCRDs` flag. *values-role.yaml* ```yaml clusterRole: false +skipCRDs: true ``` -Next, your application team can update and upgrade OpenFaaS using the chart by adding `--skip-crds` to the `helm` command, along with `-f values-role.yaml`, for example: +Next, your application team can update and upgrade OpenFaaS using the chart by adding `-f values-role.yaml` to the `helm upgrade` command. ```bash helm repo update \ @@ -190,8 +191,7 @@ helm repo update \ --install openfaas/openfaas \ --namespace openfaas \ -f values-pro.yaml \ - -f values-role.yaml \ - --skip-crds + -f values-role.yaml ``` ## Test changes for the helm chart diff --git a/chart/openfaas/crds/iam.openfaas.com_jwtissuers.yaml b/chart/openfaas/templates/iam.openfaas.com_jwtissuers-crd.yaml similarity index 98% rename from chart/openfaas/crds/iam.openfaas.com_jwtissuers.yaml rename to chart/openfaas/templates/iam.openfaas.com_jwtissuers-crd.yaml index 2cba8efef..3211c274c 100644 --- a/chart/openfaas/crds/iam.openfaas.com_jwtissuers.yaml +++ b/chart/openfaas/templates/iam.openfaas.com_jwtissuers-crd.yaml @@ -1,3 +1,5 @@ +{{- if .Values.createCRDs }} + apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -75,3 +77,5 @@ spec: served: true storage: true subresources: {} + +{{- end }} \ No newline at end of file diff --git a/chart/openfaas/crds/iam.openfaas.com_policies.yaml b/chart/openfaas/templates/iam.openfaas.com_policies-crd.yaml similarity index 98% rename from chart/openfaas/crds/iam.openfaas.com_policies.yaml rename to chart/openfaas/templates/iam.openfaas.com_policies-crd.yaml index d8a68d1a8..616f27a02 100644 --- a/chart/openfaas/crds/iam.openfaas.com_policies.yaml +++ b/chart/openfaas/templates/iam.openfaas.com_policies-crd.yaml @@ -1,3 +1,5 @@ +{{- if .Values.createCRDs }} + apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -96,3 +98,6 @@ spec: served: true storage: true subresources: {} + + +{{- end }} \ No newline at end of file diff --git a/chart/openfaas/crds/iam.openfaas.com_roles.yaml b/chart/openfaas/templates/iam.openfaas.com_roles-crd.yaml similarity index 98% rename from chart/openfaas/crds/iam.openfaas.com_roles.yaml rename to chart/openfaas/templates/iam.openfaas.com_roles-crd.yaml index 0e1cd6d01..a820b71a8 100644 --- a/chart/openfaas/crds/iam.openfaas.com_roles.yaml +++ b/chart/openfaas/templates/iam.openfaas.com_roles-crd.yaml @@ -1,3 +1,5 @@ +{{- if .Values.createCRDs }} + apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -92,3 +94,6 @@ spec: served: true storage: true subresources: {} + + +{{- end }} \ No newline at end of file diff --git a/chart/openfaas/crds/openfaas.com_functioningresses.yaml b/chart/openfaas/templates/openfaas.com_functioningresses-crd.yaml similarity index 99% rename from chart/openfaas/crds/openfaas.com_functioningresses.yaml rename to chart/openfaas/templates/openfaas.com_functioningresses-crd.yaml index bfee97670..ae17f4412 100644 --- a/chart/openfaas/crds/openfaas.com_functioningresses.yaml +++ b/chart/openfaas/templates/openfaas.com_functioningresses-crd.yaml @@ -1,3 +1,5 @@ +{{- if .Values.createCRDs }} + apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -124,3 +126,6 @@ spec: served: true storage: true subresources: {} + + +{{- end }} \ No newline at end of file diff --git a/chart/openfaas/crds/openfaas.com_functions.yaml b/chart/openfaas/templates/openfaas.com_functions-crd.yaml similarity index 99% rename from chart/openfaas/crds/openfaas.com_functions.yaml rename to chart/openfaas/templates/openfaas.com_functions-crd.yaml index 78b57c90c..b9a8f88b2 100644 --- a/chart/openfaas/crds/openfaas.com_functions.yaml +++ b/chart/openfaas/templates/openfaas.com_functions-crd.yaml @@ -1,3 +1,5 @@ +{{- if .Values.createCRDs }} + apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -196,3 +198,6 @@ spec: storage: true subresources: status: {} + + +{{- end }} \ No newline at end of file diff --git a/chart/openfaas/crds/openfaas.com_profiles.yaml b/chart/openfaas/templates/openfaas.com_profiles-crd.yaml similarity index 99% rename from chart/openfaas/crds/openfaas.com_profiles.yaml rename to chart/openfaas/templates/openfaas.com_profiles-crd.yaml index 06265db31..f98a5d60f 100644 --- a/chart/openfaas/crds/openfaas.com_profiles.yaml +++ b/chart/openfaas/templates/openfaas.com_profiles-crd.yaml @@ -1,3 +1,5 @@ +{{- if .Values.createCRDs }} + apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -1432,3 +1434,5 @@ spec: type: string served: true storage: true + +{{- end }} \ No newline at end of file diff --git a/hack/update-crds.sh b/hack/update-crds.sh index cb419fd90..01643318c 100755 --- a/hack/update-crds.sh +++ b/hack/update-crds.sh @@ -15,4 +15,9 @@ fi paths=./pkg/apis/... \ output:dir=./artifacts/crds -echo "Run \"cp ./artifacts/crds/* ./chart/openfaas/crds/\" to sync with the chart" + +@for f in ./artifacts/crds/*.yaml; do \ + echo "Annotating helm.sh/resource-policy: keep to: $$f"; \ + kubectl annotate --overwrite -f $$f --local=true -o yaml helm.sh/resource-policy: keep +done +