@@ -234,6 +234,47 @@ Define the replica count for kubeblocks.
234234{{- end }}
235235{{- end }}
236236
237+ {{/*
238+ Validate optional installation preconditions.
239+ */ }}
240+ {{- define " kubeblocks.installationChecks" -}}
241+ {{- if and .Values.installationChecks.kubeblocksCRDs.enabled (ne .Release.Name " test-release" ) -}}
242+ {{- $requiredKubeBlocksCRDs := list
243+ " clusters.apps.kubeblocks.io"
244+ " componentdefinitions.apps.kubeblocks.io"
245+ " components.apps.kubeblocks.io"
246+ " instancesets.workloads.kubeblocks.io"
247+ " opsrequests.operations.kubeblocks.io"
248+ " addons.extensions.kubeblocks.io"
249+ -}}
250+ {{- $missingKubeBlocksCRDs := list -}}
251+ {{- range $requiredKubeBlocksCRDs -}}
252+ {{- if not (lookup " apiextensions.k8s.io/v1" " CustomResourceDefinition" " " . ) -}}
253+ {{- $missingKubeBlocksCRDs = append $missingKubeBlocksCRDs . -}}
254+ {{- end -}}
255+ {{- end -}}
256+ {{- if $missingKubeBlocksCRDs -}}
257+ {{- fail (printf " \n KubeBlocks CRD check failed.\n\n Missing required CRDs:\n - %s \n\n Install the KubeBlocks CRDs first:\n kubectl apply -f deploy/helm/crds\n\n To skip this check, set:\n --set installationChecks.kubeblocksCRDs.enabled=false" (join " \n - " $missingKubeBlocksCRDs )) -}}
258+ {{- end -}}
259+ {{- end -}}
260+ {{- if and .Values.installationChecks.volumeSnapshotCRDs (ne .Release.Name " test-release" ) -}}
261+ {{- $requiredAPIs := list
262+ (dict " api" " snapshot.storage.k8s.io/v1/VolumeSnapshotClass" " crd" " volumesnapshotclasses.snapshot.storage.k8s.io" )
263+ (dict " api" " snapshot.storage.k8s.io/v1/VolumeSnapshot" " crd" " volumesnapshots.snapshot.storage.k8s.io" )
264+ (dict " api" " snapshot.storage.k8s.io/v1/VolumeSnapshotContent" " crd" " volumesnapshotcontents.snapshot.storage.k8s.io" )
265+ -}}
266+ {{- $missingCRDs := list -}}
267+ {{- range $requiredAPIs -}}
268+ {{- if not ($ .Capabilities.APIVersions.Has .api ) -}}
269+ {{- $missingCRDs = append $missingCRDs .crd -}}
270+ {{- end -}}
271+ {{- end -}}
272+ {{- if $missingCRDs -}}
273+ {{- fail (printf " \n VolumeSnapshot CRD check failed.\n\n Missing required CRDs:\n - %s \n\n Install the CSI snapshot CRDs first:\n kubectl apply -k https://github.com/kubernetes-csi/external-snapshotter/client/config/crd\n\n To skip this check, set:\n --set installationChecks.volumeSnapshotCRDs=false" (join " \n - " $missingCRDs )) -}}
274+ {{- end -}}
275+ {{- end -}}
276+ {{- end -}}
277+
237278{{- define " kubeblocks.i18nResourcesName" -}}
238279{{ include " kubeblocks.fullname" . }}-i18n-resources
239280{{- end }}
0 commit comments