-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce support for Projected Volumes kubernetes ServiceAccount Tokens #416
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,18 +269,24 @@ sync() { | |
# previously observed SHA (updated with each file watch) and compare it | ||
# against the new file's SHA. If they differ, it means something has | ||
# changed. | ||
new_sha=$(sha256sum "${filepath}" | while read -r s _; do echo "$s"; done) | ||
if [ "$new_sha" != "$prev_sha" ]; then | ||
# Create but don't rm old one since we don't know if this will be configured | ||
# to run as _the_ cni plugin. | ||
log "New file [$filename] detected; re-installing" | ||
install_cni_conf "$filepath" | ||
if [[ -n "$prev_sha" ]]; then | ||
new_sha=$(sha256sum "${filepath}" | while read -r s _; do echo "$s"; done) | ||
if [ "$new_sha" != "$prev_sha" ]; then | ||
# Create but don't rm old one since we don't know if this will be configured | ||
# to run as _the_ cni plugin. | ||
log "New file [$filename] detected; re-installing" | ||
install_cni_conf "$filepath" | ||
else | ||
# If the SHA hasn't changed or we get an unrecognised event, ignore it. | ||
# When the SHA is the same, we can get into infinite loops whereby a file has | ||
# been created and after re-install the watch keeps triggering CREATE events | ||
# that never end. | ||
log "Ignoring event: $ev $filepath; no real changes detected" | ||
fi | ||
else | ||
# If the SHA hasn't changed or we get an unrecognised event, ignore it. | ||
# When the SHA is the same, we can get into infinite loops whereby a file has | ||
# been created and after re-install the watch keeps triggering CREATE events | ||
# that never end. | ||
log "Ignoring event: $ev $filepath; no real changes detected" | ||
# If there is no previous SHA (as in the case of the token), reinstall cni. | ||
log "Processing event for $filename with no SHA comparison needed." | ||
install_cni_conf "$DEFAULT_CNI_CONF_PATH" | ||
fi | ||
fi | ||
} | ||
|
@@ -298,6 +304,11 @@ monitor() { | |
cni_conf_sha="$(sha256sum "$directory/$filename" | while read -r s _; do echo "$s"; done)" | ||
fi | ||
fi | ||
done & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need to be careful with backgrounding these tasks -- we want to ensure that There are other changes we probably need to make to this script first, but we'll want to ensure that we preserve PIDs and |
||
inotifywait -m "/var/run/secrets/kubernetes.io/serviceaccount/token" -e create,delete,moved_to,modify | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In |
||
while read -r directory action filename; do | ||
log "Detected change in Service Account token: $action $filename" | ||
sync "$DEFAULT_CNI_CONF_PATH" "$action" "" | ||
done | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't be sure at this point if the config is held on
$DEFAULT_CNI_CONF_PATH
, which is a.conf
file, or a.conflist
file.