How From-Host Syncing Works
From-host syncing follows a different pattern than to-host syncing:- The syncer watches for resources in the host cluster (or specific namespaces)
- When a matching resource is found, it’s copied into the virtual cluster
- The virtual copy is kept in sync with the host original
- When the host resource is deleted, the virtual copy is removed
pkg/syncer/from_host_syncer.go:102:
Default Synced Resources
Events
Enabled by default - Syncs events from host to virtual cluster so users can see what’s happening with their workloads.Storage Resources (Auto-Enabled)
These resources are automatically enabled when the virtual scheduler is enabled:Optional Resources
These resources can be enabled as needed:Nodes
By default, vCluster creates fake nodes. You can sync real nodes from the host:IngressClasses
RuntimeClasses
PriorityClasses
VolumeSnapshotClasses
DeviceClasses
Mapped Resources
Some resources support namespace mappings to sync specific resources from host namespaces:ConfigMaps
Sync ConfigMaps from specific host namespaces:Secrets
Sync Secrets from host to virtual cluster:Mapping Syntax
ThebyName mapping syntax supports these patterns:
| Pattern | Description | Example |
|---|---|---|
"namespace/*" | All resources in namespace | "kube-system/*": "kube-system/*" |
"namespace/name" | Specific resource, same name | "default/config": "default/config" |
"namespace/name1" to different | Specific resource, rename | "default/host-name": "default/virt-name" |
"" or "/name" | From vCluster namespace | "/secret": "default/secret" |
"" with wildcard | All from vCluster namespace | "": "imported/*" |
Configuration Examples
Basic Setup (Defaults)
Advanced Node Syncing
Sync real nodes for better resource visibility:Full Storage Integration
Enable all storage-related resources:Import Host Configurations
Sync ConfigMaps and Secrets from host:Multi-Namespace Mapping
Import resources from multiple host namespaces:Implementation Details
Custom Manager for Mappings
When using namespace mappings, vCluster creates a custom physical manager that watches multiple namespaces (pkg/syncer/from_host_syncer.go:182):
Resource Copying
The from-host syncer copies specific fields from host to virtual resources (pkg/controllers/resources/configmaps/from_host_syncer.go:36):
Troubleshooting
Resource Not Appearing in Virtual Cluster
-
Verify resource exists in host cluster:
-
Check syncing is enabled:
-
Check vCluster logs:
-
Verify RBAC permissions:
Mapped Resources Not Syncing
- Check namespace permissions: The vCluster service account needs read access to mapped namespaces
-
Verify mapping syntax: Ensure
byNamemappings are correct -
Check for errors in logs:
Events Not Showing Up
Events are filtered to only show events related to synced resources. If a Pod is synced to the host, its events will be synced back to the virtual cluster.Security Considerations
- Namespace access: Mapped resources require additional RBAC permissions in host namespaces
- Secret exposure: Be cautious when syncing secrets from host to virtual cluster
- Node information: Consider using
clearImageStatus: trueto hide container images - Sync back changes: Keep
syncBackChanges: falsefor nodes unless specifically needed
Best Practices
- Start with defaults: The auto-enabled storage resources are usually sufficient
- Use specific mappings: Avoid wildcards like
"*/*"that sync everything - Limit node syncing: Use
selector.all: falseandselector.labelsto sync only needed nodes - Monitor permissions: Ensure vCluster has appropriate RBAC for mapped namespaces
- Document mappings: Keep track of what’s being synced and why
Next Steps
- Learn about syncing to the host cluster
- Configure custom resource syncing
- Review RBAC configuration