-
Notifications
You must be signed in to change notification settings - Fork 0
Dev Mode
Development Mode provides a live file synchronization workflow for rapid iteration during development. It watches for file changes on your local machine and automatically syncs them to running pods in your Kubernetes cluster, eliminating the need for full container rebuilds on every change.
flowchart LR
subgraph local["Local Machine"]
editor["Code Editor"]
watcher["File Watcher"]
end
subgraph cluster["Kubernetes Cluster"]
pod["Running Pod"]
app["Application"]
end
editor -->|"Save file"| watcher
watcher -->|"Detect change"| sync["Sync Engine"]
sync -->|"hostpath/kubectl/configmap"| pod
pod --> app
app -->|"Hot reload"| browser["Browser"]
The Development Loop:
- You edit code in your favorite editor
- Dev mode detects the file change instantly
- Changes sync to running pods (no rebuild needed)
- Application picks up changes via hot reload
- You see results in your browser immediately
The displace project dev command starts a development session that:
- Watches local files for changes in real-time
- Syncs changes to running pods automatically
- Debounces rapid changes to prevent sync storms
- Excludes common non-essential files (node_modules, .git, etc.)
- Works with local k3d clusters or remote cloud clusters
This dramatically speeds up the development cycle by eliminating the build-push-deploy loop for code changes.
# Start dev mode with local k3d cluster (fastest)
displace project dev --localExpected output:
🔧 Starting development mode for: my-wordpress-site
📋 Template: wordpress
🎯 Target: displace-local (local) / namespace: my-wordpress-site
📁 Watch paths: [.]
🔄 Sync method: hostpath
🚀 Starting file watcher...
✨ Dev mode active! Watching 127 files
Press Ctrl+C to stop
💡 Tips:
- View pods: kubectl get pods -n my-wordpress-site
- View logs: kubectl logs -f -n my-wordpress-site -l app=my-wordpress-site
- Changes are synced automatically when you save files
Other common commands:
# Start dev mode with a specific cluster
displace project dev --cluster my-cluster
# Watch specific directories
displace project dev --local --watch ./src --watch ./config
# Use kubectl sync for cloud clusters
displace project dev --cluster my-eks-cluster --sync-method kubectlDevelopment mode supports three synchronization methods, each optimized for different scenarios:
flowchart TB
subgraph methods["Sync Method Comparison"]
direction LR
subgraph hostpath["hostpath"]
hp1["Fastest"]
hp2["Local k3d only"]
hp3["Volume mount"]
end
subgraph kubectl["kubectl"]
kc1["Universal"]
kc2["Any cluster"]
kc3["kubectl cp"]
end
subgraph configmap["configmap"]
cm1["Config files"]
cm2["K8s native"]
cm3["ConfigMap update"]
end
end
| Method | Speed | Cluster Support | Best For |
|---|---|---|---|
hostpath |
Instant | Local k3d only | Rapid local development |
kubectl |
Fast | Any cluster | Remote/cloud clusters |
configmap |
Fast | Any cluster | Configuration files |
Method: hostpath
Uses k3d volume mounts to share files directly between host and cluster. This is the fastest method but only works with local k3d clusters.
# Fastest option for local development
displace project dev --local --sync-method hostpathHow it works:
- k3d mounts your project directory into the cluster
- File changes are instantly visible inside pods
- No network transfer required
- Near-zero latency
Best for:
- Local k3d development
- Rapid iteration on code
- Testing configuration changes
Method: kubectl
Uses kubectl cp to copy changed files to running pods. Works with any cluster but has network latency.
# Works with any cluster (local or cloud)
displace project dev --cluster my-cluster --sync-method kubectlHow it works:
- Watches for local file changes
- Uses
kubectl cpto copy files to pods - Targets specific container if specified
- Syncs to all matching pods
Best for:
- Remote cloud clusters (EKS, GKE, AKS, DOKS)
- Development across network
- When hostpath not available
Method: configmap
Updates Kubernetes ConfigMaps with file contents. Ideal for configuration files that pods read at runtime.
# For syncing configuration files
displace project dev --sync-method configmapHow it works:
- Reads file contents when changed
- Creates or updates ConfigMaps in the cluster
- Pods automatically pick up ConfigMap changes
- Works well with config files and environment settings
Best for:
- Configuration file updates
- Environment variable changes
- Files mounted as ConfigMaps in pods
displace project dev [flags]| Flag | Short | Description |
|---|---|---|
--local |
-l |
Use local k3d cluster (fastest dev experience) |
--cluster |
-c |
Target cluster name |
--namespace |
-n |
Target Kubernetes namespace |
--sync-method |
Sync method: hostpath, kubectl, or configmap
|
|
--watch |
-w |
Paths to watch (can be used multiple times) |
--container |
Target container name in pod | |
--selector |
Pod selector (e.g., app=myapp) |
|
--no-sync |
Watch only, don't sync (for debugging) | |
--verbose |
-v |
Show detailed sync output |
# Basic local development
displace project dev --local
# Watch specific directories
displace project dev --local --watch ./src --watch ./public
# Target specific namespace
displace project dev --local --namespace my-app
# Sync to specific container
displace project dev --cluster prod --container php-fpm
# Use pod selector
displace project dev --local --selector app=wordpress
# Verbose output for debugging
displace project dev --local --verboseBy default, dev mode watches the current directory. Customize with --watch:
# Watch multiple directories
displace project dev --local \
--watch ./src \
--watch ./config \
--watch ./publicThe following patterns are automatically excluded from sync:
| Pattern | Description |
|---|---|
*.git* |
Git files and directories |
*.displace* |
Displace configuration |
node_modules/** |
Node.js dependencies |
vendor/** |
PHP/Go vendor dependencies |
__pycache__/** |
Python bytecode cache |
*.pyc |
Python compiled files |
.DS_Store |
macOS metadata |
*.swp, *.swo, *~
|
Editor swap files |
.env.local, .env*.local
|
Local environment files |
Dev mode implements smart debouncing to prevent sync storms:
- Delay: 500ms after last change before syncing
- Batching: Multiple rapid changes are grouped
- Deduplication: Same file changed multiple times syncs once
This prevents overwhelming the cluster during rapid edits like auto-save.
# Initialize Laravel project
displace project init laravel
# Deploy to local cluster
displace project deploy --cluster displace-local
# Start dev mode watching src directory
displace project dev --local --watch ./src
# Make changes to src/app/Http/Controllers/HomeController.php
# Changes automatically sync to running pods# Initialize static site
displace project init static
# Deploy locally
displace project deploy --cluster displace-local
# Start dev mode
displace project dev --local --watch ./content
# Edit content files - changes sync immediately# Start dev mode watching source files
displace project dev --local \
--watch ./src \
--watch ./pages \
--watch ./components
# Changes to React components sync to pods
# Hot reload picks up changesDev mode automatically selects the appropriate cluster:
-
Explicit cluster flag:
--cluster my-cluster -
Local flag:
--localselects local k3d cluster - Project deployment: Uses cluster where project is deployed
- Local deployment preferred: Prefers local over remote for dev
# If project is deployed to local cluster
displace project dev
# Automatically targets local deployment
# If deployed to multiple clusters, prefer local
displace project dev
# Uses local cluster for dev mode
# If only deployed to remote cluster
displace project dev
# Uses remote cluster with kubectl syncDev mode automatically finds pods matching your project:
# Finds pods with label matching project name
displace project dev --local
# Targets pods where app=<project-name># Target specific pods
displace project dev --local --selector app=frontend
# Target by deployment
displace project dev --local --selector deployment=my-appFor pods with multiple containers:
# Target specific container
displace project dev --local --container nginxError: no running pods found matching selector: app
Solution:
- Check project is deployed:
displace project info - Verify pods are running:
kubectl get pods -n <namespace> - Use explicit selector:
--selector app=<name>
kubectl cp failed: ...
Solutions:
- Check kubectl access:
kubectl get pods - Verify container has tar: Some minimal images lack it
- Check file permissions in container
- Use verbose mode:
--verbose
Error: host path mount not configured
Solution: k3d cluster needs volume mount. Create with:
k3d cluster create my-cluster --volume /path/to/project:/appOr use kubectl sync method:
displace project dev --sync-method kubectlCheck:
- File isn't in excluded patterns
- Watch path includes the directory
- Sync method is appropriate for cluster type
- Run with
--verboseto see file events
Solutions:
- Narrow watch scope:
--watch ./srcinstead of. - Check for recursive symlinks
- Exclude large directories: node_modules, vendor
- Use hostpath sync for fastest iteration
- Watch only necessary directories to reduce CPU
-
Use local wildcard DNS for easy access:
http://myapp.local.displace.tech
- Use kubectl sync for cloud clusters
- Target specific directories to minimize transfer
- Consider network latency when making rapid changes
- Start with verbose mode to understand sync behavior
- Use pod selector when project has multiple deployments
- Combine with hot reload for best experience
- Keep watch paths minimal for performance
-
Use
displace project restartto pick up ConfigMap changes that require pod restart
Each template is optimized for dev mode:
- Watches
./contentdirectory - Instant content updates via hostpath
- Watches
./wp-contentfor theme/plugin changes - PHP changes reflected immediately
- Watches
./srcfor application code - Controllers, views, and routes sync instantly
- Assets may need rebuild (use
npm run devlocally)
- Kubernetes cluster running and accessible
- kubectl configured and working
- Project deployed to target cluster
- Docker running for local k3d clusters
Related Documentation:
- Local Providers - Setting up local k3d clusters
- Application Templates - Template-specific development
-
Quick Start Guide - Getting started with Displace (includes
project restart) - Container Registry - Building and pushing images
- WordPress Customization - Dev mode with themes and plugins