mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Embed NoopNetworkPlugin into other network plugins
Let Noop handle common functions.
This commit is contained in:
parent
be8ce6c385
commit
f1323103db
@ -38,6 +38,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type cniNetworkPlugin struct {
|
type cniNetworkPlugin struct {
|
||||||
|
network.NoopNetworkPlugin
|
||||||
|
|
||||||
defaultNetwork *cniNetwork
|
defaultNetwork *cniNetwork
|
||||||
host network.Host
|
host network.Host
|
||||||
}
|
}
|
||||||
@ -96,9 +98,6 @@ func (plugin *cniNetworkPlugin) Init(host network.Host) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *cniNetworkPlugin) Event(name string, details map[string]interface{}) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (plugin *cniNetworkPlugin) Name() string {
|
func (plugin *cniNetworkPlugin) Name() string {
|
||||||
return CNIPluginName
|
return CNIPluginName
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type execNetworkPlugin struct {
|
type execNetworkPlugin struct {
|
||||||
|
network.NoopNetworkPlugin
|
||||||
|
|
||||||
execName string
|
execName string
|
||||||
execPath string
|
execPath string
|
||||||
host network.Host
|
host network.Host
|
||||||
@ -120,9 +122,6 @@ func (plugin *execNetworkPlugin) getExecutable() string {
|
|||||||
return path.Join(plugin.execPath, execName)
|
return path.Join(plugin.execPath, execName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *execNetworkPlugin) Event(name string, details map[string]interface{}) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (plugin *execNetworkPlugin) Name() string {
|
func (plugin *execNetworkPlugin) Name() string {
|
||||||
return plugin.execName
|
return plugin.execName
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type kubenetNetworkPlugin struct {
|
type kubenetNetworkPlugin struct {
|
||||||
|
network.NoopNetworkPlugin
|
||||||
|
|
||||||
host network.Host
|
host network.Host
|
||||||
netConfig *libcni.NetworkConfig
|
netConfig *libcni.NetworkConfig
|
||||||
cniConfig *libcni.CNIConfig
|
cniConfig *libcni.CNIConfig
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type kubenetNetworkPlugin struct {
|
type kubenetNetworkPlugin struct {
|
||||||
|
network.NoopNetworkPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPlugin() network.NetworkPlugin {
|
func NewPlugin() network.NetworkPlugin {
|
||||||
@ -35,8 +36,6 @@ func NewPlugin() network.NetworkPlugin {
|
|||||||
func (plugin *kubenetNetworkPlugin) Init(host network.Host) error {
|
func (plugin *kubenetNetworkPlugin) Init(host network.Host) error {
|
||||||
return fmt.Errorf("Kubenet is not supported in this build")
|
return fmt.Errorf("Kubenet is not supported in this build")
|
||||||
}
|
}
|
||||||
func (plugin *kubenetNetworkPlugin) Event(name string, details map[string]interface{}) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (plugin *kubenetNetworkPlugin) Name() string {
|
func (plugin *kubenetNetworkPlugin) Name() string {
|
||||||
return "kubenet"
|
return "kubenet"
|
||||||
|
@ -94,7 +94,7 @@ type Host interface {
|
|||||||
func InitNetworkPlugin(plugins []NetworkPlugin, networkPluginName string, host Host) (NetworkPlugin, error) {
|
func InitNetworkPlugin(plugins []NetworkPlugin, networkPluginName string, host Host) (NetworkPlugin, error) {
|
||||||
if networkPluginName == "" {
|
if networkPluginName == "" {
|
||||||
// default to the no_op plugin
|
// default to the no_op plugin
|
||||||
plug := &noopNetworkPlugin{}
|
plug := &NoopNetworkPlugin{}
|
||||||
if err := plug.Init(host); err != nil {
|
if err := plug.Init(host); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -137,12 +137,12 @@ func UnescapePluginName(in string) string {
|
|||||||
return strings.Replace(in, "~", "/", -1)
|
return strings.Replace(in, "~", "/", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
type noopNetworkPlugin struct {
|
type NoopNetworkPlugin struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const sysctlBridgeCallIptables = "net/bridge/bridge-nf-call-iptables"
|
const sysctlBridgeCallIptables = "net/bridge/bridge-nf-call-iptables"
|
||||||
|
|
||||||
func (plugin *noopNetworkPlugin) Init(host Host) error {
|
func (plugin *NoopNetworkPlugin) Init(host Host) error {
|
||||||
// Set bridge-nf-call-iptables=1 to maintain compatibility with older
|
// Set bridge-nf-call-iptables=1 to maintain compatibility with older
|
||||||
// kubernetes versions to ensure the iptables-based kube proxy functions
|
// kubernetes versions to ensure the iptables-based kube proxy functions
|
||||||
// correctly. Other plugins are responsible for setting this correctly
|
// correctly. Other plugins are responsible for setting this correctly
|
||||||
@ -159,21 +159,21 @@ func (plugin *noopNetworkPlugin) Init(host Host) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *noopNetworkPlugin) Event(name string, details map[string]interface{}) {
|
func (plugin *NoopNetworkPlugin) Event(name string, details map[string]interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *noopNetworkPlugin) Name() string {
|
func (plugin *NoopNetworkPlugin) Name() string {
|
||||||
return DefaultPluginName
|
return DefaultPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *noopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.DockerID) error {
|
func (plugin *NoopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.DockerID) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *noopNetworkPlugin) TearDownPod(namespace string, name string, id kubecontainer.DockerID) error {
|
func (plugin *NoopNetworkPlugin) TearDownPod(namespace string, name string, id kubecontainer.DockerID) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *noopNetworkPlugin) Status(namespace string, name string, id kubecontainer.DockerID) (*PodNetworkStatus, error) {
|
func (plugin *NoopNetworkPlugin) Status(namespace string, name string, id kubecontainer.DockerID) (*PodNetworkStatus, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user