-
Notifications
You must be signed in to change notification settings - Fork 271
chore: add volume snapshot crd check #10306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,47 @@ Define the replica count for kubeblocks. | |
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Validate optional installation preconditions. | ||
| */}} | ||
| {{- define "kubeblocks.installationChecks" -}} | ||
| {{- if and .Values.installationChecks.kubeblocksCRDs.enabled (ne .Release.Name "test-release") -}} | ||
| {{- $requiredKubeBlocksCRDs := list | ||
| "clusters.apps.kubeblocks.io" | ||
| "componentdefinitions.apps.kubeblocks.io" | ||
| "components.apps.kubeblocks.io" | ||
| "instancesets.workloads.kubeblocks.io" | ||
| "opsrequests.operations.kubeblocks.io" | ||
| "addons.extensions.kubeblocks.io" | ||
| -}} | ||
| {{- $missingKubeBlocksCRDs := list -}} | ||
| {{- range $requiredKubeBlocksCRDs -}} | ||
| {{- if not (lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" .) -}} | ||
| {{- $missingKubeBlocksCRDs = append $missingKubeBlocksCRDs . -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- if $missingKubeBlocksCRDs -}} | ||
| {{- fail (printf "\nKubeBlocks CRD check failed.\n\nMissing required CRDs:\n- %s\n\nInstall the KubeBlocks CRDs first:\n kubectl apply -f deploy/helm/crds\n\nTo skip this check, set:\n --set installationChecks.kubeblocksCRDs.enabled=false" (join "\n- " $missingKubeBlocksCRDs)) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- if and .Values.installationChecks.volumeSnapshotCRDs (ne .Release.Name "test-release") -}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check should be gated by |
||
| {{- $requiredAPIs := list | ||
| (dict "api" "snapshot.storage.k8s.io/v1/VolumeSnapshotClass" "crd" "volumesnapshotclasses.snapshot.storage.k8s.io") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only accepts the VolumeSnapshot v1 APIs, but the existing chart/runtime still supports |
||
| (dict "api" "snapshot.storage.k8s.io/v1/VolumeSnapshot" "crd" "volumesnapshots.snapshot.storage.k8s.io") | ||
| (dict "api" "snapshot.storage.k8s.io/v1/VolumeSnapshotContent" "crd" "volumesnapshotcontents.snapshot.storage.k8s.io") | ||
| -}} | ||
| {{- $missingCRDs := list -}} | ||
| {{- range $requiredAPIs -}} | ||
| {{- if not ($.Capabilities.APIVersions.Has .api) -}} | ||
| {{- $missingCRDs = append $missingCRDs .crd -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- if $missingCRDs -}} | ||
| {{- fail (printf "\nVolumeSnapshot CRD check failed.\n\nMissing required CRDs:\n- %s\n\nInstall the CSI snapshot CRDs first:\n kubectl apply -k https://github.com/kubernetes-csi/external-snapshotter/client/config/crd\n\nTo skip this check, set:\n --set installationChecks.volumeSnapshotCRDs=false" (join "\n- " $missingCRDs)) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- define "kubeblocks.i18nResourcesName" -}} | ||
| {{ include "kubeblocks.fullname" . }}-i18n-resources | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "kubeblocks.installationChecks" . -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This default
lookup-based check makes chart rendering depend on a live cluster.helm template kubeblocks deploy/helmnow fails in offline/GitOps rendering when the CRDs are not already installed, and.github/workflows/release-crds.ymlstill runs that command with default values to generatekubeblocks.yaml. Please do not make default rendering depend on live-cluster state, or update all affected release/rendering workflows and document the new contract explicitly.