Browse Source

add create flags to each CRDs resources for a more fine-grained control

Eric Chan 4 years ago
parent
commit
efb75527e0
3 changed files with 24 additions and 5 deletions
  1. 10 5
      Makefile
  2. 4 0
      deploy/charts/external-secrets/README.md
  3. 10 0
      deploy/charts/external-secrets/values.yaml

+ 10 - 5
Makefile

@@ -174,15 +174,20 @@ helm.build: helm.generate ## Build helm chart
 	@mv $(OUTPUT_DIR)/chart/external-secrets-$(HELM_VERSION).tgz $(OUTPUT_DIR)/chart/external-secrets.tgz
 	@$(OK) helm package
 
-helm.generate: helm.docs ## Copy crds to helm chart directory
-	@cp $(BUNDLE_DIR)/*.yaml $(HELM_DIR)/templates/crds/
+helm.generate:
+# Split the generated bundle yaml file to inject control flags
+	@for i in $(BUNDLE_DIR)/*.yaml; do \
+		yq -Ns '"$(HELM_DIR)/templates/crds/" + .spec.names.singular' "$$i"; \
+	done
 # Add helm if statement for controlling the install of CRDs
-	@for i in $(HELM_DIR)/templates/crds/*.yaml; do \
+	@for i in $(HELM_DIR)/templates/crds/*.yml; do \
+		CRDS_FLAG_NAME="create$$(yq '.spec.names.kind' $$i)" && \
 		cp "$$i" "$$i.bkp" && \
-		echo "{{- if .Values.installCRDs }}" > "$$i" && \
+		echo "{{- if and (.Values.installCRDs) (.Values.crds.$$CRDS_FLAG_NAME) }}" > "$$i" && \
 		cat "$$i.bkp" >> "$$i" && \
 		echo "{{- end }}" >> "$$i" && \
-		rm "$$i.bkp"; \
+		rm "$$i.bkp" && \
+		mv "$$i" "$${i%.yml}.yaml"; \
 	done
 	@$(OK) Finished generating helm chart files
 

+ 4 - 0
deploy/charts/external-secrets/README.md

@@ -63,6 +63,10 @@ The command removes all the Kubernetes components associated with the chart and
 | certController.tolerations | list | `[]` |  |
 | concurrent | int | `1` | Specifies the number of concurrent ExternalSecret Reconciles external-secret executes at a time. |
 | controllerClass | string | `""` | If set external secrets will filter matching Secret Stores with the appropriate controller values. |
+| crds.createClusterExternalSecret | bool | `true` | If true, create CRDs for Cluster External Secret. |
+| crds.createClusterSecretStore | bool | `true` | If true, create CRDs for Secret Store. |
+| crds.createExternalSecret | bool | `true` | If true, create CRDs for External Secret. |
+| crds.createSecretStore | bool | `true` | If true, create CRDs for Secret Store. |
 | createOperator | bool | `true` | Specifies whether an external secret operator deployment be created. |
 | deploymentAnnotations | object | `{}` | Annotations to add to Deployment |
 | extraArgs | object | `{}` |  |

+ 10 - 0
deploy/charts/external-secrets/values.yaml

@@ -9,6 +9,16 @@ image:
 # -- If set, install and upgrade CRDs through helm chart.
 installCRDs: true
 
+crds:
+  # -- If true, create CRDs for Cluster External Secret.
+  createClusterExternalSecret: true
+  # -- If true, create CRDs for Secret Store.
+  createClusterSecretStore: true
+  # -- If true, create CRDs for External Secret.
+  createExternalSecret: true
+  # -- If true, create CRDs for Secret Store.
+  createSecretStore: true
+
 imagePullSecrets: []
 nameOverride: ""
 fullnameOverride: ""