Improvement. Automatic synchronization of changes from 'linked' secrets#160
Open
tr-aheiev wants to merge 1 commit intozakkg3:masterfrom
Open
Improvement. Automatic synchronization of changes from 'linked' secrets#160tr-aheiev wants to merge 1 commit intozakkg3:masterfrom
tr-aheiev wants to merge 1 commit intozakkg3:masterfrom
Conversation
axel7083
reviewed
Jan 21, 2025
| elif name == body['data']['valueFrom']['secretKeyRef']['name'] and namespace == body['data']['valueFrom']['secretKeyRef']['namespace']: | ||
| logger.info(f'Secret {name} in namespace {namespace}, which linked with ClusterSecret {cached_cluster_secret.name} was changed. Re-syncing') | ||
| for ns in cached_cluster_secret.synced_namespace: | ||
| sync_secret(logger, ns, body, v1) |
Collaborator
There was a problem hiding this comment.
might need to add a test in https://github.com/zakkg3/ClusterSecret/blob/master/conformance/tests.py to ensure this feature is working as expected
Author
There was a problem hiding this comment.
Thanks for review! Yes, I plan to add test soon.
Copilot AI
added a commit
that referenced
this pull request
Mar 15, 2026
…secret auto-sync (#160) Co-authored-by: zakkg3 <25042095+zakkg3@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a long-requested and missing feature: automatically updating all secrets when there are changes in secrets referenced by 'secretKeyRef'. A kopf decorator is used to send all secret update events to a new function called 'on_secret_update'. In this function, I parse all ClusterSecrets from the in-memory cache (it's very fast) and check whether they have a 'valueFrom' field in their data. Next, for those ClusterSecrets that have a 'valueFrom' field, I simply compare the name and namespace of the updated secret with the corresponding values in 'valueFrom'. If they match, a resync is initiated for each previously synced namespace.
It will solve 36