Skip to content
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

Support for external daemon plugins #39615

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ehazlett
Copy link
Contributor

@ehazlett ehazlett commented Jul 26, 2019

This adds support for external daemon plugins (currently GRPC). This is a light port of the containerd plugin model where plugins can Register as a daemon plugin. These are then initialized at init and can operate directly with the daemon. This is useful, for example, if a plugin needs to operate on an internal system such as the content store that is not accessible via the API.

An example plugin could be something like this:

// local implements the api/server/router/grpc.Backend interface
type local struct {}

func init() {
        plugin.Register(&plugin.PluginRegistration{
                Type: plugin.GRPCPlugin,
                ID:   "foo",
                InitFn: func(ic *plugin.PluginContext) (interface{}, error) {
                        return &local{}, nil
                },
        })
}

Then plugins can simply be included at build time with a blank import:

import (
        ...
        _ "github.com/ehazlett/foo/plugin"
)

@thaJeztah
Copy link
Member

Just quickly glancing over, but this allows plugins to register their own endpoints? should those custom endpoints be namespaced (taking the odd case into account that someone uses an authz plug-in or other means to blacklist endpoints)?

Might have to be described somewhere in https://github.com/moby/moby/blob/master/docs/api/version-history.md

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some quick questions after looking at this from my phone 🤗

cmd/dockerd/daemon.go Outdated Show resolved Hide resolved
cmd/dockerd/daemon.go Outdated Show resolved Hide resolved
@ehazlett ehazlett force-pushed the daemon-plugins branch 2 times, most recently from 807b39e to 269b3ce Compare July 26, 2019 23:47
@ehazlett
Copy link
Contributor Author

should those custom endpoints be namespaced

Each daemon plugin is namespaced (by default <type>.<id> for example io.docker.grpc.v1.foo). This could be used as a whitelist / blacklist but since these are compile time I'm not sure it's vital. I can see that being more useful if we added runtime loading.


const (
// GRPCPlugin implements a grpc service
GRPCPlugin Type = "io.docker.grpc.v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if we should use com.docker... instead of io.docker.... Looking through the codebase, it looks like we use com.docker.. for swarmkit labels, libnetwork options, and some other places, so it might be more consistent.

Copy link
Member

@andrewhsu andrewhsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

In terms of adding ability to bring in new functionality for the daemon endpoints, this looks like a desirable PR. I'm expecting this does not imply bringing over all of the current HTTP endpoints of the daemon into gRPC.

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
@AkihiroSuda
Copy link
Member

needs rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants