Add support for DaemonSet to AdvancedDaemonSet migration #131
Add support for DaemonSet to AdvancedDaemonSet migration #131GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@furykerry can you review it whenever feasible and suggest improvements wherever needed. Thanks! |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for migrating a native Kubernetes DaemonSet to a Kruise AdvancedDaemonSet, including both a creation-only path and a full migration path with orphan-deletion handoff.
- Introduces
pkg/creation/daemonsetandpkg/migration/daemonsetcontrols for DaemonSet→AdvancedDaemonSet - Extends
kubectl-kruise migrateto recognizeDaemonSet/AdvancedDaemonSetin CLI and API refs - Updates documentation and examples to demonstrate new flags (
--create,--copy,--max-surge)
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/migration/daemonset/daemonset_migration.go | Implements Submit and Query for full DaemonSet migration |
| pkg/creation/daemonset/daemonset_creation.go | Implements Create control for AdvancedDaemonSet from DaemonSet |
| pkg/cmd/migrate/migrate_daemonset.go | Adds migrateDaemonSet handler for CLI |
| pkg/cmd/migrate/migrate.go | Extends CLI parsing to support DaemonSet/AdvancedDaemonSet |
| pkg/api/api.go | Defines new ResourceRef constructors for both DaemonSet kinds |
| docs/kubectl-kruise_migrate.md | Updates migrate command examples for DaemonSet paths |
Comments suppressed due to low confidence (3)
pkg/api/api.go:107
- [nitpick] Using the CRD Kind
DaemonSetforAdvancedDaemonSetRefmay confuse tooling and users expectingAdvancedDaemonSetas the Kind. Consider aligning the Kind field with the CLI naming or documenting this discrepancy.
Kind: AdvancedDaemonSetKind.Kind,
docs/kubectl-kruise_migrate.md:26
- The indentation of this example line is inconsistent with other examples in the code block. Align the leading spaces to match the surrounding formatting for readability.
# Create an empty AdvancedDaemonSet from an existing DaemonSet.
pkg/migration/daemonset/daemonset_migration.go:1
- There are no unit tests covering the new DaemonSet→AdvancedDaemonSet migration logic. Consider adding tests for both successful and failure scenarios to ensure correctness and prevent regressions.
package daemonset
|
@hantmac can you review it again ? |
|
@GautamBytes do you have environment to the test migration operation? it seems that these two commands will not works in real enviroment |
docs/kubectl-kruise_migrate.md
Outdated
| kubectl-kruise migrate CloneSet --from Deployment -n default --src-name cloneset-name --dst-name deployment-name --replicas 10 --max-surge=2 | ||
|
|
||
| # Create an empty AdvancedDaemonSet from an existing DaemonSet. | ||
| kubectl-kruise migrate AdvancedDaemonSet --from DaemonSet -n default --dst-name ads-name --create |
There was a problem hiding this comment.
since daemonset does not have replica field, it is not possible to create "empty" daemon set , unless you hack the affinity of daemonset pod e.g. adding an non-existing affinity label or adding a pod anti-affinity rule. Alternatively, we can not support create empty advance daemonset at all
| }, | ||
| }, | ||
| } | ||
| if err := c.client.Create(context.Background(), ads); err != nil { |
There was a problem hiding this comment.
we should orphan delete the native daemonset first, otherwise advance daemonset will create another set of daemon pods before adopting the pods of original daemonset
There was a problem hiding this comment.
Sure , will make changes accordingly. Thanks!
ec1c00d to
9b30ef4
Compare
Signed-off-by: GautamBytes <manchandanigautam@gmail.com>
9b30ef4 to
dcaf0f8
Compare
Ⅰ. Describe what this PR does
This PR introduces the functionality to migrate a native Kubernetes
DaemonSetto a KruiseAdvancedDaemonSetvia thekubectl-kruise migratecommand.The implementation includes:
migratecommand now acceptsDaemonSetas a source (--from) andAdvancedDaemonSetas a destination.--createflag is supported to generate a newAdvancedDaemonSetfrom an existingDaemonSet's specification without migrating the pods.AdvancedDaemonSetand then performing an orphan deletion of the originalDaemonSet. This leaves the original pods running so they can be adopted by the newAdvancedDaemonSetcontroller, ensuring zero downtime.Example Usage:
Ⅱ. Does this pull request fix one issue?
fixes #129
Ⅲ. Special notes for reviews
This implementation is modeled after the existing
DeploymenttoCloneSetmigration to maintain consistency within the project.The core logic for the migration path relies on
DeletePropagationOrphanto ensure a safe handover of pods from the oldDaemonSetto the newAdvancedDaemonSet. The logic has been cleanly separated intopkg/creation/daemonsetandpkg/migration/daemonsetpackages for maintainability.