-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
backend/extension: Introduce new extension backend #701
Conversation
Pretty neat. Cool :) |
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.
a few changes
Documentation/extension.md
Outdated
* `Type` (string): `extension` | ||
* `PreStartupCommand` (string): Command to run before allocating a network to this host | ||
* The stdout of the process is captured and passed to the stdin of the SubnetAdd/Remove commands. | ||
* `PostStartupCommand` (string): Command to run before allocating a network to this host |
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.
before -> after
Documentation/extension.md
Outdated
* `SubnetAddCommand` (string): Command to run when a subnet is added | ||
* stdin - The output from `PreStartupCommand` is passed in. | ||
* The following environment variables are set | ||
* SUBNET - The subnet on the remote host that was added. |
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.
do you mean subnet of
instead of subnet on
?
Documentation/extension.md
Outdated
* `SubnetRemoveCommand`(string): Command to run when a subnet is removed | ||
* stdin - The output from `PreStartupCommand` is passed in. | ||
* The following environment variables are set | ||
* SUBNET - The subnet on the remote host that was removed. |
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.
on -> of?
backend/extension/extension.go
Outdated
@@ -0,0 +1,150 @@ | |||
// Copyright 2015 flannel authors |
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.
shouldn't the license headers be 2017
?
backend/extension/extension.go
Outdated
log.Infof("Ran command: %s\n Output: %s", n.postStartupCommand, cmd_output) | ||
} | ||
} else { | ||
log.Infof("No pre startup command configured - skipping") |
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.
this should be post startup
, not pre
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.
LGTM
The
extension
backend provides an easy way for prototyping new backend types for flannel.It is not recommended for production use, for example it doesn't have a built in retry mechanism.
This backend has the following configuration
Type
(string):extension
PreStartupCommand
(string): Command to run before allocating a network to this hostPostStartupCommand
(string): Command to run before allocating a network to this host* SUBNET - The subnet on the remote host that was added.
SubnetAddCommand
(string): Command to run when a subnet is addedPreStartupCommand
is passed in.SubnetRemoveCommand
(string): Command to run when a subnet is removedPreStartupCommand
is passed in.All commands are run through the
sh
shell and are run with the same permissions as the flannel daemon.Simple example (host-gw)
To replicate the functionality of the host-gw plugin, there's no need for a startup command.
The backend just needs to manage the route to subnets when they are added or removed.
An example
Complex example (vxlan)
VXLAN is more complex. It needs to store the MAC address of the vxlan device when it's created and to make it available to the flannel daemon running on other hosts.
The address of the vxlan device also needs to be set after the subnet has been allocated.
An example