Skip to content

feature(sync): Implement syncing across replicas in a Deployment,ReplicaSet,StatefulSet#3189

Open
atidyshirt wants to merge 3 commits intodevspace-sh:mainfrom
atidyshirt:main
Open

feature(sync): Implement syncing across replicas in a Deployment,ReplicaSet,StatefulSet#3189
atidyshirt wants to merge 3 commits intodevspace-sh:mainfrom
atidyshirt:main

Conversation

@atidyshirt
Copy link
Copy Markdown

@atidyshirt atidyshirt commented Mar 28, 2026

What issue type does this pull request address? (keep at least one, remove the others)

/kind feature
/kind enhancement
/kind test

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)

resolves #1250 (Closed issue, but I can create a separate issue detailing use-cases where this is useful)

Please provide a short message that should be published in the DevSpace release notes

Support multi-pod sync over Kubernetes deployments (ReplicaSet, Deployments, StatefulSet)

What else do we need to know?

  • Feature is Opt-in: syncReplicas: boolean in config and/or --sync-replicas on dev sync
  • Non-primary replicas: upload-only, no download (by design)
    • Primary pod selection: defined as the newest pod
    • Secondary pod restrictions: configured with upload only to stop infinite sync loops.
  • Pod replacement: preserves replica count when any sync has syncReplicas: true
  • Adds E2E test with sync-replicas testdata
  • Breaking changes: none expected for default configurations.

Note from me

The goal of this change is to make dev pipeline options (image, command, and the rest) not mutually exclusive with syncing multiple replicas—something that today is only achievable via bespoke bash scripting outside of Devspace.

I am fairly new to Go, so feedback on style and structure is very welcome. If this PR does not align with the goals of the application, feel free to drop it entirely.

Thanks

Implements multi-replica sync as discussed in devspace-sh#1250

Sync all pods in the selected Deployment, with additional replicas upload-only
and OnUpload cleared on those targets to avoid feedback loops.

Existing sync flags remain respected where applicable; the intentional exception
is that non-primary replicas are not full bidirectional sync (no download /
downstream parity with the primary).

Changes/Details:

- Add dev.sync[*].syncReplicas and cmd/sync --sync-replicas
  * (pick disabled when the flag is set).
- Target expansion uses pod owner refs to resolve the Deployment and list
  matching pods; primary is the newest pod.
- Secondaries never download; drift from the primary on those pods must be
  corrected by changing files locally so they upload again.
Split out target selection into a separate file and add some test cases
to show the behaviour of the target selection.
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 28, 2026

Deploy Preview for devspace-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit a464460
🔍 Latest deploy log https://app.netlify.com/projects/devspace-docs/deploys/69c75026963a4b00097b5748

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.

When using multiple replica for a deployment, synchronization only applies to one pod

1 participant