The vault-sync-operator includes intelligent secret rotation detection to optimize performance and reduce unnecessary Vault operations. This feature tracks Kubernetes Secret resource versions and only syncs to Vault when actual changes occur.
The operator automatically tracks the resourceVersion of each Kubernetes Secret it syncs to Vault. When a reconciliation occurs, it compares current secret versions with the last known versions stored in the syncing resource’s annotations (Deployment or Secret). Only when changes are detected will the operator perform a sync to Vault.
The operator uses the following annotations to control rotation detection:
vault-sync.io/rotation-checkControls how the operator handles secret rotation detection:
enabled (default): Normal rotation detection is activedisabled: Rotation detection is disabled, operator will always syncvault-sync.io/secret-versionsThis annotation is automatically managed by the operator and stores the last known resource versions of synced secrets. Do not modify this annotation manually.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
annotations:
vault-sync.io/path: "secret/data/my-app"
# rotation-check: enabled is the default
spec:
# ... deployment spec
The same annotation behavior applies to direct Secret sync mode:
apiVersion: v1
kind: Secret
metadata:
name: my-secret
annotations:
vault-sync.io/path: "secret/data/my-secret"
# rotation-check: enabled is the default
type: Opaque
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
annotations:
vault-sync.io/path: "secret/data/my-app"
vault-sync.io/rotation-check: "disabled"
spec:
# ... deployment spec
When rotation detection is disabled, the operator will sync to Vault on every reconciliation, regardless of whether secrets have changed.
The operator provides metrics to monitor rotation detection:
vault_sync_rotation_checks_total: Total number of rotation checks performedvault_sync_rotation_detected_total: Number of times rotation was detectedvault_sync_rotation_skipped_total: Number of times sync was skipped due to no changesIf you need to force a sync regardless of detected changes:
vault-sync.io/rotation-check: "disabled" temporarilyvault-sync.io/secret-versions annotation to trigger a fresh syncThe operator logs detailed information about rotation detection:
INFO secret rotation detected, syncing to vault
{"changed_secrets": ["my-secret", "another-secret"]}
INFO no secret changes detected, skipping vault sync
{"last_versions": {"my-secret": "123"}, "current_versions": {"my-secret": "123"}}
secret-versions annotation becomes corrupted, delete it to resetresourceVersion is actually changingThe operator stores secret versions in JSON format in the syncing resource annotation (Deployment or Secret):
{
"my-secret": "12345",
"another-secret": "67890"
}
resourceVersion with stored versiontrue if any changes detected, false otherwiseFor large deployments with many secrets, the operator: