-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Auto import images for containerd image store #10973
Open
vitorsavian
wants to merge
20
commits into
k3s-io:master
Choose a base branch
from
vitorsavian:auto-import-embedded-registry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
53c36b5
Add auto import images
vitorsavian 9e3d00b
Fix vagrant for autoimport
vitorsavian 98fd1ec
Image watcher now uses event.Has for event operations
vitorsavian fee4fb4
Removing fmt track from e2e test
vitorsavian b2d0225
Change nadr file name
vitorsavian 74629a1
Add a better extension handling for image watcher
vitorsavian 55e1bd0
Add label for auto import when image is already pulled
vitorsavian 9558dd8
Add steps for pinned images
vitorsavian 6fe5cc8
Add more steps to verify restart
vitorsavian c7d8e1d
Add more steps to verify restart
vitorsavian 9cfc7e4
Remove daemonset from restart
vitorsavian ec26517
Remove auto import label
vitorsavian 926186d
Fix EOF error log when importing tarball files
vitorsavian 62b4244
Delaying queue
vitorsavian 6de98d9
Use two seconds instead of one
vitorsavian d9854b6
Change to event cache and file cache
vitorsavian e7659d0
Remove useless workqueue.Done
vitorsavian 2a71842
Refactor
vitorsavian 98f3c9b
Add parse for images
vitorsavian e5e2332
Addressing comments
vitorsavian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Easy way for auto adding images to k3s | ||
|
||
Date: 2024-10-2 | ||
|
||
## Status | ||
|
||
Proposed | ||
|
||
## Context | ||
|
||
Since the feature for embedded registry, the users appeared with a question about having to manually import images, specially in edge environments. | ||
|
||
As a result, there is a need for a folder who can handle this action, where every image there will be watched by a controller for changes or new images, this new images or new changes will be added to the containerd image store. | ||
|
||
The controller will watch the agent/images folder that is the default folder for the images, as the first iteration about the controller he will mainly work with the default image folder, but in the future we can set to watch more folders. | ||
|
||
The main idea for the controller is to create a map for the file infos maintaining the state for the files, with that we can see if a file was modified and if the size changed. | ||
|
||
### Map to handle the state from the files | ||
|
||
This map will have the entire filepath of the file in the `key` value, since we can get the value from the key with only the `event.Name` | ||
|
||
```go | ||
map[string]fs.FileInfo | ||
``` | ||
|
||
### Why use fsnotify | ||
|
||
With this library we can easily use for any linux distros without the need to port for a specify distro and can also run in windows. | ||
|
||
The main idea for the watch will be taking care of the last time that was modified the image file. | ||
|
||
fsnotify has a great toolset for handling changes in files, since the code will have a channel to receive events such as CREATE, RENAME, REMOVE and WRITE. | ||
|
||
### How the controller will work with the events | ||
|
||
When the controller receive a event saying that a file was created, he will add to the map and import the images if the event that he has received is not a directory and then import the image. | ||
|
||
When the controller receive a event saying that a file was writen, he will verify if the file has the size changed and if the file has the time modified based on the time and size from the state. | ||
|
||
When the controller receive a event saying that a file was renamed, or removed, he will delete this file from the state. when a file is renamed, it is created a new file with the same infos but with a the new name, so the watcher will sent for the controller a event saying that a file was created. | ||
|
||
## Decision | ||
|
||
- Decided | ||
|
||
## Consequences | ||
|
||
Good: | ||
- Better use of embedded containerd image store. | ||
- Fsnotify it's a indirect dependency that upstream uses | ||
|
||
Bad: | ||
- The need for another dependency |
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Why would users have to manually import images? Aren't they automatically pulled by containerd once the pod is scheduled in the node?