-
Notifications
You must be signed in to change notification settings - Fork 1
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
cached
K8S CSI driver
#89
Conversation
7651505
to
b48e6ea
Compare
6b4d7cc
to
7ee43f7
Compare
cached
K8S CSI driver
ca00e2b
to
332fe4e
Compare
pkg/api/cachedcsi.go
Outdated
@@ -0,0 +1,203 @@ | |||
package api |
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 do these methods on Cached
exist in another file?
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.
I figured it was nice to separate them since its the CSI stuff vs our stuff, but if that's against convention I will merge them?
pkg/cli/cachedaemon.go
Outdated
if csiSocket != "" { | ||
go (func() { | ||
logger.Info(ctx, "start CSI server") | ||
err := s.ServeCSI(ctx, csiSocket) |
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.
I don't think this will cleanly stop on graceful shutdown. You likely want a cancellable context passed in here that we can abort on <-osSignals
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.
Would you mind terribly shooting me a diff? I feel like I could figure it out but it would take you approximately 10 seconds to do
pkg/cli/cachedaemon.go
Outdated
|
||
select { | ||
case err := <-errors: | ||
return err |
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.
If the CSI server caused this to fail, you need to also stop the GRPC server.
FYI, I'm going to push commits to this branch |
This makes
cached
able to operate in a new mode -- as a Kubernetes Container Storage Interface driver, where it can be the thing that powers K8S volumes directly! CSIs are usually used to implement strange and foreign storage interfaces, like GCP persistent disks or NFS or whatever weird mounts you can figure out in linux.In order for the hardlinks to be on the same device and thus actually improve performance, the cache daemon has to have privileged access to the the volumes that pods mount. We can do that with ninja editing stuff in /var/lib/kubernetes in a privileged container, or we can do it the safer way that k8s endorses! It actually still ends up modifying stuff in
/var/lib/kubernetes
and has the same escalated privileges, but, a big win is that the CSI daemon needs no network interface, and only actually communicates with other trusted components (the kubelet). In our case, we don't need to implement very much of the CSI interface (and we report as such with the fancy capabilities RPCs), we just want an emptyDir on the same device as wherever the cache is stored. Turns out, this is pretty easy!How this will work:
cached
as a daemonset throughout the cluster, running in CSI mode talking to the kubeletemptyDir
):cached
implementcached
won't actually mount anything, but instead just drop the cache in an empty folder and set the permissions up right (the kubelet actually mounts the folder into the docker container as it always does) using the existing implementation from the previous PRcached
gets another RPC, and removes the whole folder (but not the shared golden copy of the cache).Woop woop!