Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cicd-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ jobs:
VERSION: "v0.8.0-check"
CHART_NAME: "kubeblocks"
CHART_DIR: "deploy/helm"
HELM_SET: "installationChecks.kubeblocksCRDs.enabled=false,installationChecks.volumeSnapshotCRDs=false"
APECD_REF: "v0.1.43"
MAKE_OPS_POST: "install"
GO_VERSION: "1.25"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cicd-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ jobs:
VERSION: "v0.8.0-check"
CHART_NAME: "kubeblocks"
CHART_DIR: "deploy/helm"
HELM_SET: "installationChecks.kubeblocksCRDs.enabled=false,installationChecks.volumeSnapshotCRDs=false"
APECD_REF: "v0.1.43"
MAKE_OPS_POST: "install"
GO_VERSION: "1.25"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-helm-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
VERSION: "${{ needs.release-version.outputs.release-version }}"
CHART_NAME: "kubeblocks"
CHART_DIR: "deploy/helm"
HELM_SET: "installationChecks.kubeblocksCRDs.enabled=false,installationChecks.volumeSnapshotCRDs=false"
APECD_REF: "v0.1.96"
MAKE_OPS_POST: "install"
GO_VERSION: "1.25"
Expand Down
41 changes: 41 additions & 0 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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") -}}

Copy link
Copy Markdown
Contributor

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/helm now fails in offline/GitOps rendering when the CRDs are not already installed, and .github/workflows/release-crds.yml still runs that command with default values to generate kubeblocks.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.

{{- $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") -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be gated by dataProtection.enabled. If users explicitly install only the core controller with dataProtection.enabled=false, VolumeSnapshot CRDs should not be required. Otherwise an optional DP dependency becomes a global installation prerequisite, which breaks lightweight/development installs.

{{- $requiredAPIs := list
(dict "api" "snapshot.storage.k8s.io/v1/VolumeSnapshotClass" "crd" "volumesnapshotclasses.snapshot.storage.k8s.io")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 snapshot.storage.k8s.io/v1beta1 through VOLUMESNAPSHOT_API_BETA and the compat client. A v1beta1-only cluster that previously worked would now be blocked at install time. The check should match the existing runtime contract by accepting either v1 or v1beta1, unless this PR intentionally removes v1beta1 support with a compatibility note.

(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 }}
1 change: 1 addition & 0 deletions deploy/helm/templates/installation-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "kubeblocks.installationChecks" . -}}
9 changes: 9 additions & 0 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ client:
# default is 256
burst: ""

## Installation checks.
##
## @param installationChecks.kubeblocksCRDs.enabled - fail installation when required KubeBlocks core CRDs are unavailable.
## @param installationChecks.volumeSnapshotCRDs - fail installation when required VolumeSnapshot CRDs are unavailable.
installationChecks:
kubeblocksCRDs:
enabled: true
volumeSnapshotCRDs: true

## @param nameOverride
##
nameOverride: ""
Expand Down
Loading