Skip to content

Remove Kubernetes < 1.35 fallback, require ImageVolume (K8s 1.35+)#275

Open
WentingWu666666 wants to merge 6 commits intodocumentdb:mainfrom
WentingWu666666:users/wentingwu/remove-combined-mode
Open

Remove Kubernetes < 1.35 fallback, require ImageVolume (K8s 1.35+)#275
WentingWu666666 wants to merge 6 commits intodocumentdb:mainfrom
WentingWu666666:users/wentingwu/remove-combined-mode

Conversation

@WentingWu666666
Copy link
Collaborator

@WentingWu666666 WentingWu666666 commented Feb 28, 2026

Summary

Removes the legacy single-image deployment fallback that was used on Kubernetes clusters older than 1.35 (where the ImageVolume feature was not yet GA). The operator now exclusively uses ImageVolume to mount the DocumentDB extension image separately from the PostgreSQL base image.

A startup validation is added so the operator fails fast with a clear error if the cluster is running Kubernetes < 1.35.

Changes

Operator Source

  • constants.go — Removed DEFAULT_COMBINED_DOCUMENTDB_IMAGE, COMBINED_IMAGE_POSTGRES_UID, COMBINED_IMAGE_POSTGRES_GID, and MinK8sMinorVersionForImageVolume. Added MinK8sMinorVersion = 35.
  • documentdb_controller.go — Removed ImageVolumeSupported field and detectImageVolumeSupport() method. Added validateK8sVersion() called from SetupWithManager() to enforce K8s >= 1.35 at startup.
  • cnpg_cluster.go — Removed useImageVolume parameter from GetCnpgClusterSpec() and the single-image fallback branch.
  • util.go — Simplified GetDocumentDBImageForInstance() to always return the ImageVolume-based image.

Tests

  • documentdb_controller_test.go — Replaced detectImageVolumeSupport tests with validateK8sVersion tests (7 cases covering K8s 1.34, 1.35, 1.36+, nil Clientset, "+" suffix, ServerVersion error, non-numeric minor).
  • cnpg_cluster_test.go — Removed useImageVolume parameter from all GetCnpgClusterSpec call sites; deleted the single-image test block.
  • util_test.go — Removed single-image test cases and updated call signatures.

Documentation & CI

  • docs/.../index.md — Changed ImageVolume from "recommended" to "required"; removed fallback mention.
  • CHANGELOG.md — Updated deployment section; added breaking change note.
  • test-E2E.yml — Removed K8s v1.34.0 matrix entries (amd64 and arm64).

Breaking Changes

  • Kubernetes 1.35+ is now required. The operator will refuse to start on older clusters with a clear error message explaining the requirement.
  • The single-image deployment path (which bundled PostgreSQL + DocumentDB extensions in one image) has been removed. All deployments now use ImageVolume to mount extensions separately.

How It Works

On K8s < 1.35, the operator logged this at startup in SetupWithManager:

kubernetes version 1.XX is not supported: the DocumentDB operator requires
Kubernetes 1.35+ for ImageVolume support (GA in K8s 1.35). Please upgrade your cluster

This causes the manager to call os.Exit(1), and the pod enters CrashLoopBackOff. Users can see the error via kubectl logs.

Remove the legacy combined-image deployment mode for Kubernetes < 1.35.
The operator now requires Kubernetes 1.35+ and uses ImageVolume exclusively
to mount the DocumentDB extension image.

Changes:
- Remove combined mode constants (DEFAULT_COMBINED_DOCUMENTDB_IMAGE, UID/GID)
- Remove useImageVolume parameter from GetCnpgClusterSpec and GetDocumentDBImageForInstance
- Remove ImageVolumeSupported field and detectImageVolumeSupport from controller
- Add validateK8sVersion check in SetupWithManager to fail early on K8s < 1.35
- Remove combined mode tests and add validateK8sVersion tests
- Remove K8s 1.34 entries from E2E test matrix
- Update documentation to require K8s 1.35+

Closes documentdb#269

Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
…r path

Add tests to improve patch coverage from 73.7% to 100%:
- SetupWithManager: test error return when K8s version validation fails
- Reconcile: integration test exercising the full happy path through
  upgradeDocumentDBIfNeeded with a pre-existing CNPG cluster

Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
@WentingWu666666 WentingWu666666 marked this pull request as ready for review February 28, 2026 01:53
Copilot AI review requested due to automatic review settings February 28, 2026 01:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the legacy “combined image” fallback path used for Kubernetes clusters < 1.35 and makes ImageVolume-based extension mounting the only supported deployment mode, enforcing Kubernetes 1.35+ at operator startup.

Changes:

  • Enforces Kubernetes >= 1.35 at startup via validateK8sVersion() and removes ImageVolumeSupported detection/fallback behavior.
  • Simplifies CNPG cluster spec generation and image selection to always use ImageVolume-mounted extension images.
  • Updates unit tests, docs, changelog, and CI E2E matrix to reflect the new Kubernetes 1.35+ requirement.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
operator/src/internal/utils/util_test.go Updates tests for GetDocumentDBImageForInstance() after removing the mode parameter.
operator/src/internal/utils/util.go Simplifies GetDocumentDBImageForInstance() to always return the extension image path.
operator/src/internal/utils/constants.go Removes combined-mode constants and introduces MinK8sMinorVersion = 35.
operator/src/internal/controller/documentdb_controller_test.go Replaces ImageVolume detection tests with Kubernetes version validation tests and adjusts controller tests accordingly.
operator/src/internal/controller/documentdb_controller.go Removes ImageVolume support flag, always runs upgrade logic, and adds startup Kubernetes version validation.
operator/src/internal/cnpg/cnpg_cluster_test.go Updates call sites for GetCnpgClusterSpec() after removing the useImageVolume parameter and deletes combined-mode tests.
operator/src/internal/cnpg/cnpg_cluster.go Removes combined-mode spec branch; always configures ImageVolume extension mounting.
docs/operator-public-documentation/preview/index.md Updates quickstart prerequisites to require Kubernetes 1.35+ and removes fallback guidance.
CHANGELOG.md Updates unreleased notes to reflect ImageVolume-only mode and the breaking Kubernetes 1.35+ requirement.
.github/workflows/test-E2E.yml Removes Kubernetes v1.34 entries from the E2E test matrix.

@WentingWu666666 WentingWu666666 force-pushed the users/wentingwu/remove-combined-mode branch from 54cfbaa to 797b148 Compare March 1, 2026 02:04
- Parse K8s major version in validateK8sVersion so future major
  versions (>1) are treated as supported instead of rejected.
  Non-numeric major versions now return a clear error.
- Replace hardcoded "GA in K8s 1.35" in the unsupported-version error
  message with the MinK8sMinorVersion constant for consistency.
- Fail fast in SetupWithManager when Clientset is nil and the default
  SQLExecutor is used, catching misconfiguration at startup instead
  of a nil-pointer panic during reconciliation.
- Fix existing SetupWithManager test to supply a Clientset, and add a
  dedicated test for the new Clientset-nil guard.
- Add test cases for major version > 1 and non-numeric major version.

Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
Hoist the Clientset nil check to the top of SetupWithManager so both
the default SQLExecutor assignment and validateK8sVersion are protected
by a single guard. This eliminates the duplicated nil check that was
previously inside validateK8sVersion.

- SetupWithManager now returns an error immediately when Clientset is
  nil, before any other initialization logic runs.
- validateK8sVersion drops its own nil-Clientset early-return; its doc
  comment now states callers must ensure Clientset is non-nil.
- Test "should not override pre-set SQLExecutor" supplies a Clientset
  via kubefake.NewSimpleClientset() to satisfy the new guard.
- Removed the "should skip validation when Clientset is nil" test for
  validateK8sVersion  that path no longer exists and is already
  covered by the SetupWithManager nil-Clientset test.

Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
- **ImageVolume Deployment**: The operator uses ImageVolume (GA in Kubernetes 1.35) to mount the DocumentDB extension as a separate image alongside a standard PostgreSQL base image.

### Breaking Changes
- **Removed combined mode support**: The legacy combined-image deployment mode for Kubernetes < 1.35 has been removed. Kubernetes 1.35+ is now required.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note, we should cut a major release in March for this breaking change.
From 0.1.3 to 1.0.0.

But if we don't want to go to 1.0.0 before GA, then a minor cut is Ok- need more discussion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I remember 1.0.0 means GA. Since we are not yet GA, I believe any breaking change is acceptable in preview and could be included in the next minor release, right?

Remove documentDBImage, gatewayImage, and documentDBVersion from
playground scripts, deployment examples, samples, and docs so the
operator defaults handle image selection.

Changes span:
- documentdb-playground/ (aks-setup, aws-setup, telemetry, tls,
  multi-cloud-deployment, aks-fleet-deployment)
- operator/src/config/samples/
- operator/src/scripts/deployment-examples/
- docs/developer-guides/

Also removes related script infrastructure: env vars, CLI flags,
sed substitutions, and YAML template placeholders that fed the
now-removed fields.

The operator-upgrade-guide test-documentdb-versioned.yaml retains
its pinned version intentionally (that is the purpose of the test).

Verified on kind K8s 1.35: a DocumentDB CR with no image overrides
starts successfully with operator defaults.

Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants