Ejemplo n.º 1
0
// ProbeNetworkPlugins collects all compiled-in plugins
func ProbeNetworkPlugins(pluginDir string) []network.NetworkPlugin {
	allPlugins := []network.NetworkPlugin{}

	// for each existing plugin, add to the list
	allPlugins = append(allPlugins, exec.ProbeNetworkPlugins(pluginDir)...)
	allPlugins = append(allPlugins, cni.ProbeNetworkPlugins(pluginDir)...)

	return allPlugins
}
Ejemplo n.º 2
0
// This kubelet network plugin shim only exists to grab the knetwork.Host
// Everything else is simply proxied directly to the kubenet CNI driver.
func (node *OsdnNode) Init(host knetwork.Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, mtu int) error {
	plugins := kcni.ProbeNetworkPlugins(kcni.DefaultNetDir, kcni.DefaultCNIDir)
	if len(plugins) == 0 {
		return fmt.Errorf("openshift-sdn CNI network plugin config could not be found in %v", kcni.DefaultNetDir)
	} else if len(plugins) > 1 {
		return fmt.Errorf("multiple CNI network plugins found; only one can be used")
	}
	node.host = host
	node.kubeletCniPlugin = plugins[0]

	return node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)
}
Ejemplo n.º 3
0
// ProbeNetworkPlugins collects all compiled-in plugins
func ProbeNetworkPlugins(pluginDir, cniConfDir, cniBinDir string) []network.NetworkPlugin {
	allPlugins := []network.NetworkPlugin{}

	// for backwards-compat, allow pluginDir as a source of CNI config files
	if cniConfDir == "" {
		cniConfDir = pluginDir
	}
	// for each existing plugin, add to the list
	allPlugins = append(allPlugins, cni.ProbeNetworkPlugins(cniConfDir, cniBinDir)...)
	allPlugins = append(allPlugins, kubenet.NewPlugin(pluginDir))

	return allPlugins
}
Ejemplo n.º 4
0
// This kubelet network plugin shim only exists to grab the knetwork.Host
// Everything else is simply proxied directly to the kubenet CNI driver.
func (node *OsdnNode) Init(host knetwork.Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, mtu int) error {
	plugins := kcni.ProbeNetworkPlugins(kcni.DefaultNetDir, kcni.DefaultCNIDir)
	if len(plugins) == 0 {
		return fmt.Errorf("openshift-sdn CNI network plugin config could not be found in %v", kcni.DefaultNetDir)
	} else if len(plugins) > 1 {
		return fmt.Errorf("multiple CNI network plugins found; only one can be used")
	}
	node.host = host
	node.kubeletCniPlugin = plugins[0]

	err := node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)

	// Let initial pod updates happen if they need to
	glog.V(5).Infof("openshift-sdn CNI plugin initialized")
	close(node.kubeletInitReady)

	return err
}
// NOTE: Anything passed to DockerService should be eventually handled in another way when we switch to running the shim as a different process.
func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot string, podSandboxImage string, streamingConfig *streaming.Config, pluginSettings *NetworkPluginSettings, cgroupsName string) (DockerService, error) {
	c := dockertools.NewInstrumentedDockerInterface(client)
	ds := &dockerService{
		seccompProfileRoot: seccompProfileRoot,
		client:             c,
		os:                 kubecontainer.RealOS{},
		podSandboxImage:    podSandboxImage,
		streamingRuntime: &streamingRuntime{
			client: client,
			// Only the native exec handling is supported for now.
			// TODO(#35747) - Either deprecate nsenter exec handling, or add support for it here.
			execHandler: &dockertools.NativeExecHandler{},
		},
		containerManager: cm.NewContainerManager(cgroupsName, client),
	}
	if streamingConfig != nil {
		var err error
		ds.streamingServer, err = streaming.NewServer(*streamingConfig, ds.streamingRuntime)
		if err != nil {
			return nil, err
		}
	}
	// dockershim currently only supports CNI plugins.
	cniPlugins := cni.ProbeNetworkPlugins(pluginSettings.PluginConfDir, pluginSettings.PluginBinDir)
	cniPlugins = append(cniPlugins, kubenet.NewPlugin(pluginSettings.PluginBinDir))
	netHost := &dockerNetworkHost{
		pluginSettings.LegacyRuntimeHost,
		&namespaceGetter{ds},
	}
	plug, err := network.InitNetworkPlugin(cniPlugins, pluginSettings.PluginName, netHost, pluginSettings.HairpinMode, pluginSettings.NonMasqueradeCIDR, pluginSettings.MTU)
	if err != nil {
		return nil, fmt.Errorf("didn't find compatible CNI plugin with given settings %+v: %v", pluginSettings, err)
	}
	ds.networkPlugin = plug
	glog.Infof("Docker cri networking managed by %v", plug.Name())
	return ds, nil
}